retext plugin to implement SmartyPants
npm install retext-smartypants[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
[retext][] plugin to apply [SmartyPants][].
* What is this?
* When should I use this?
* Install
* Use
* API
* [unified().use(retextSmartypants[, options])](#unifieduseretextsmartypants-options)
* Options
* QuoteCharacterMap
* Types
* Compatibility
* Contribute
* License
This package is a [unified][] ([retext][]) plugin to apply [SmartyPants][] to
the syntax tree.
It replaces straight/typewriter punctuation marks and symbols with smart/curly
marks and symbols.
You can use this plugin any time there straight marks and symbols in prose,
but you want to use smart ones instead.
This package is [ESM only][esm].
In Node.js (version 16+), install with [npm][]:
``sh`
npm install retext-smartypants
In Deno with [esm.sh][esmsh]:
`js`
import retextSmartypants from 'https://esm.sh/retext-smartypants@6'
In browsers with [esm.sh][esmsh]:
`html`
`js
import {retext} from 'retext'
import retextSmartypants from 'retext-smartypants'
const file = await retext()
.use(retextSmartypants)
.process('He said, "A \'simple\' english sentence. . ."')
console.log(String(file))
`
Yields:
`txt`
He said, “A ‘simple’ english sentence…”
This package exports no identifiers.
The default export is [retextSmartypants][api-retext-smartypants].
Replace straight punctuation marks with curly ones.
###### Parameters
* options ([Options][api-options], optional)
— configuration
###### Returns
Transform ([Transformer][unified-transformer]).
Configuration (TypeScript type).
###### Fields
* backticks (boolean or 'all', default: true)true
— transform backticks;
when , turns double backticks into an opening double quote and'all'
double straight single quotes into a closing double quote;
when , does that and turns single backticks into an openingquotes: false
single quote and a straight single quotes into a closing single smart
quote;
must be used with backticks: 'all'closingQuotes
* ([QuoteCharacterMap][api-quote-character-map], default:{double: '”', single: '’'}
)dashes
— closing quotes to use
* ('inverted' or 'oldschool' or boolean, default: true)true
— transform dashes;
when , turns two dashes into an em dash character;'oldschool'
when , turns three dashes into an em dash and two into an en'inverted'
dash;
when , turns three dashes into an en dash and two into an emellipses
dash
* ('spaced' or 'unspaced' or boolean, default: true)'spaced'
— transform triple dots;
when , turns triple dots with spaces into ellipses;'unspaced'
when , turns triple dots without spaces into ellipses;true
when , turns triple dots with or without spaces into ellipsesopeningQuotes
* ([QuoteCharacterMap][api-quote-character-map], default:{double: '“', single: '‘'}
)quotes
— opening quotes to use
* (boolean, default: true)
— transform straight quotes into smart quotes
Quote characters (TypeScript type).
###### Fields
* double (string)single
— character to use for double quotes
* (string)
— character to use for single quotes
This package is fully typed with [TypeScript][].
It exports the additional types [Options][api-options] andQuoteCharacterMap
[][api-quote-character-map].
Projects maintained by the unified collective are compatible with maintained
versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, retext-smartypants@^6,
compatible with Node.js 16.
See [contributing.md][contributing] in [retextjs/.github][health] for wayssupport.md`][support] for ways to get help.
to get started.
See [
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
[MIT][license] © [Titus Wormer][author]
[build-badge]: https://github.com/retextjs/retext-smartypants/workflows/main/badge.svg
[build]: https://github.com/retextjs/retext-smartypants/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/retextjs/retext-smartypants.svg
[coverage]: https://codecov.io/github/retextjs/retext-smartypants
[downloads-badge]: https://img.shields.io/npm/dm/retext-smartypants.svg
[downloads]: https://www.npmjs.com/package/retext-smartypants
[size-badge]: https://img.shields.io/bundlejs/size/retext-smartypants
[size]: https://bundlejs.com/?q=retext-smartypants
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/retextjs/retext/discussions
[npm]: https://docs.npmjs.com/cli/install
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[esmsh]: https://esm.sh
[typescript]: https://www.typescriptlang.org
[health]: https://github.com/retextjs/.github
[contributing]: https://github.com/retextjs/.github/blob/main/contributing.md
[support]: https://github.com/retextjs/.github/blob/main/support.md
[coc]: https://github.com/retextjs/.github/blob/main/code-of-conduct.md
[license]: license
[author]: https://wooorm.com
[smartypants]: https://daringfireball.net/projects/smartypants
[retext]: https://github.com/retextjs/retext
[unified]: https://github.com/unifiedjs/unified
[unified-transformer]: https://github.com/unifiedjs/unified#transformer
[api-options]: #options
[api-quote-character-map]: #quotecharactermap
[api-retext-smartypants]: #unifieduseretextsmartypants-options