Skip to content

devonnuri/remark-smartquote

Repository files navigation

remark-smartquote

This is a remark plugin to make plain quotation marks (', ") content-aware. Inspired by smartquote from typst.

Example

When using remark-smartquote, given the following markdown:

"I thought it was 'If a body catch a body,'" I said.

...remark will output:

“I thought it was ‘If a body catch a body,’” I said.

Usage

import { remark } from 'remark';
import smartquote from 'remark-smartquote';

const input = `"I thought it was 'If a body catch a body,'" I said.`;

remark()
  .use(smartquote)
  .process(input, (err, file) => {
    if (err) {
      console.error(err);
    } else {
      console.log(String(file));
    }
  });

Options

options.quotes

Type: [string, string, string, string]

Default: ['‘', '’', '“', '”']

An array of qutoes to use. [opening-single, closing-single, opening-double, closing-double]

remark()
  .use(smartquote, { quotes: ['‚', '‘', '„', '“'] })
  .process(input, (err, file) => {
    if (err) {
      console.error(err);
    } else {
      console.log(String(file));
    }
  });

About

Context-aware quote plugin for Remark

Resources

License

Stars

Watchers

Forks

Packages

No packages published