remark-highlight-mark
What is this?
This package contains extensions that add support for highlight-mark(==abc==) to micromark, mdast and remark.
Inspired by micromark-extension-gfm-strikethrough, mdast-util-gfm-strikethrough and remark-gfm
Install
This package is ESM only.
npm install remark-highlight-mark
When to use this
This project is useful when you want to support highlight-mark(==abc==) in markdown.
When you need to support micromark, you need to use the exported highlightMarkHtml and highlightMark from the package.
import { highlightMarkHtml, highlightMark } from 'micromark-extension-highlight-mark'
micromark('a ==b==', {
extensions: [defaults],
htmlExtensions: [html],
})
When you need to support mdast, you need to use the exported highlightMarkFromMarkdown and highlightMarkToMarkdown from the package.
import { highlightMarkFromMarkdown, highlightMarkToMarkdown } from 'mdast-util-highlight-mark'
fromMarkdown('a ==b== c.', {
extensions: [highlightMark()],
mdastExtensions: [highlightMarkFromMarkdown],
})
toMarkdown(
{
type: 'paragraph',
children: [
{ type: 'text', value: 'a ' },
{ type: 'mark', children: [{ type: 'text', value: 'b' }] },
{ type: 'text', value: ' c.' },
],
},
{ extensions: [highlightMarkToMarkdown] }
)
When you need to support remark, you need to use the exported remarkHighlightMark from the package.
import { remarkHighlightMark } from 'remark-highlight-mark'
export const remark = () =>
unified().use(remarkParse).use(remarkStringify).use(remarkGfm).use(remarkHighlightMark)
Types
This package is fully typed with TypeScript.
HTML
When tilde sequences match, they together relate to the <mark> element in
HTML.
See § 4.5.23 The mark element in the HTML spec for more info.