remark-smartypants
Version:
remark plugin to implement SmartyPants
61 lines (41 loc) • 1.48 kB
Markdown
[][npm]
[][npm]
[] plugin to implement [SmartyPants]. Now with 100% more ESM!
```sh
npm install remark-smartypants
yarn add remark-smartypants
```
Example using [remark]:
```js
import remark from "remark";
import smartypants from "remark-smartypants";
const result = await remark().use(smartypants).process("# <<Hello World!>>");
console.log(String(result));
// # «Hello World!»
```
I created this plugin because I wanted to add SmartyPants to [MDX]:
```js
import mdx from "@mdx-js/mdx";
import smartypants from "remark-smartypants";
const result = await mdx("# ---Hello World!---", {
remarkPlugins: [smartypants],
});
```
Note that angle quotes in the former example (`<<...>>`) are probably impossible in MDX because there they are invalid syntax.
This plugin uses [retext-smartypants](https://github.com/retextjs/retext-smartypants) under the hood, so it takes the same options:
```js
const result = await remark()
.use(smartypants, { dashes: "oldschool" })
.process("en dash (--), em dash (---)");
```
[](./LICENSE)
[]: https://www.npmjs.com/package/remark-smartypants
[]: https://remark.js.org
[]: https://daringfireball.net/projects/smartypants
[]: https://mdxjs.com