micromark-extension-bracketed-spans
v1.0.1
Published
A micromark syntax extension for Pandoc-style bracketed spans.
Readme
micromark-extension-bracketed-spans
A syntax extension for the micromark markdown parser that provides pandoc-style bracketed spans.
You probably shouldn't use this package directly, but instead use mdast-util-bracketed-spans with mdast or remark-bracketed-spans-2 with remark.
Usage
import { micromark } from "micromark";
import { bracketedSpanHtml } from "micromark-extension-bracketed-spans";
import { bracketedSpanSyntax } from "micromark-extension-bracketed-spans";
let serialized = micromark('[This is some text]{#id .cls key="value"}', {
extensions: [bracketedSpanSyntax()],
htmlExtensions: [bracketedSpanHtml()]
});The serialized result will be the following. To get an abstract syntax tree, use mdast-util-bracketed-spans instead.
<p><span id="id" class="cls" key="value">This is some text</span></p>Differences from Pandoc
The parser used for the attributes is the same as used by micromark-extension-directive. This leads to a few edge-cases where this plugin behaves differently from Pandoc.
For instance, the following does not parse using micromark-extension-bracketed-spans:
[This is some text]{key="value}Pandoc happily parses this and renders it to
<p><span key=""value">This is some text</span></p>I believe these small incompatibilities with Pandoc are worth the compatibility with the popular micromark-extension-directive plugin.
