unified

Project: remarkjs/remark-textr

Package: remark-textr@4.0.0

  1. Dependencies: 2·Dependents: 9
  2. remark plugin to integrate with Textr
  1. remark 195
  2. unified 167
  3. markdown 135
  4. plugin 130
  5. mdast 88
  6. remark-plugin 74
  7. text 18
  8. typography 3
  9. typographic 2

remark-textr

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to make your typography better with Textr.

Note!

This plugin is ready for the new parser in remark (remarkjs/remark#536). No change is needed: it works exactly the same now as it did before!

Install

npm:

npm install remark-textr

Use

Say we have the following file, example.md:

## spread operator...

```js
function(...args) { return args; }
```

And our script, example.js, looks as follows:

var vfile = require('to-vfile')
var remark = require('remark')
var textr = require('remark-textr')

remark()
  .use(textr, {plugins: [ellipses]})
  .process(vfile.readSync('example.md'), function(err, file) {
    if (err) throw err
    console.log(String(file))
  })

// Textr plugin: just a function to replace triple dots to ellipses.
function ellipses(input) {
  return input.replace(/\.{3}/gim, '…')
}

Yields:

## spread operator…

```js
function(...args) { return args; }
```

API

remark().use(textr[, config])

Make your typography better with Textr.

config
config.plugins

List of Textr plugins (Array.<string|Function>?). If strings are passed in, those are loaded with require. Textr plugins are available on npm, labelled with textr keyword. You can also create them yourself, as shown in the example above.

config.options

Textr options (Object?). For example, you may want to set the ISO 639 locale code of the content, which is important for stuff like the correct primary and secondary quotes.

Security

Use of remark-textr does not involve rehype (hast) or user content so there are no openings for cross-site scripting (XSS) attacks. Textr operates on text nodes, which are always escaped by remark.

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Denys Dovhan