unified

Project: Mavrin/remark-typograf

Package: @mavrin/remark-typograf@2.2.0

  1. Dependencies: 0·Dependents: 0
  2. Plugin for remark to make your typography better with typograf
  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

remarkjs-typograf

Plugin for remark to make your typography better with typograf

Example https://mavrin.github.io/remark-typograf/

Install

npm:

npm install @mavrin/remark-typograf remark

Use

Say we have the following file, example.md:

## spread operator `...`

It is test...

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

You probably want to use it on the CLI through a config file:

  …
  "remarkConfig": {
    "plugins": [
      [
        "@mavrin/remark-typograf",
        {
          "locale": ["ru"]
        }
      ]
    ]
  }
…

Or use it on the CLI directly (ru locale will be used as default)

remark -u @mavrin/remark-typograf example.md -o processed-example.md

Or use this on the API:

const fs = require("fs");
const path = require("path");
const remark = require("remark");
const remarkTypograf = require("@mavrin/remark-typograf");

const processed = remark()
  .use(remarkTypograf, { locale: ["en-US"], keywords: [":)"] })
  .processSync(fs.readFileSync(path.resolve(__dirname, "example.md")));

fs.writeFileSync(path.resolve(__dirname, "processed-example.md"), processed);

or with custom typograf:

const fs = require("fs");
const path = require("path");
const remark = require("remark");
const remarkTypograf = require("@mavrin/remark-typograf");
const Typograf = require("typograf");

const processed = remark()
  .use(remarkTypograf, {
    typograf: new Typograf({ locale: ["en-US"] }),
    keywords: [":)"],
    builtIn: false,
  })
  .processSync(fs.readFileSync(path.resolve(__dirname, "example.md")));

fs.writeFileSync(path.resolve(__dirname, "processed-example.md"), processed);

Yields:

## spread operator `...`

It is test…

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

Example source code