gt-remark
v1.0.12
Published
Remark plugin for processing MDX/Markdown by escaping HTML-sensitive characters in text nodes.
Downloads
227,403
Maintainers
Readme
gt-remark
Remark plugin for escaping HTML-sensitive characters in MDX/Markdown text nodes.
Installation
npm install gt-remarkUsage
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkStringify from 'remark-stringify';
import escapeHtmlInTextNodes from 'gt-remark';
const file = await unified()
.use(remarkParse)
.use(escapeHtmlInTextNodes)
.use(remarkStringify)
.process('Hello & <world>');For translated MDX that may contain literal markdown-control characters inside JSX text nodes, use the named MDX JSX text plugin before stringifying:
import { escapeMarkdownInMdxJsxTextNodes } from 'gt-remark';
import remarkMdx from 'remark-mdx';
const file = await unified()
.use(remarkParse)
.use(remarkMdx)
.use(escapeMarkdownInMdxJsxTextNodes)
.use(remarkStringify)
.process('<p>*literal translated text*</p>');See the full documentation for guides and API reference.
