Work around likely micromark bug in sliceSerialize (link to GitHub issue in code).

This commit is contained in:
David Anson 2023-01-13 19:37:17 -08:00
parent 000281e2f0
commit 5038f6e154

View file

@ -41,11 +41,15 @@ function micromarkParse(markdown) {
const history = [ current ];
for (const event of events) {
const [ kind, token, context ] = event;
const { type, start, end, _container } = token;
const { type, start, end } = token;
const { "column": startColumn, "line": startLine } = start;
const { "column": endColumn, "line": endLine } = end;
// sliceSerialize throws when called for a _container
const text = _container ? null : context.sliceSerialize(token);
let text = null;
try {
text = context.sliceSerialize(token);
} catch {
// https://github.com/micromark/micromark/issues/131
}
if (kind === "enter") {
const previous = current;
history.push(previous);