Closed crystalfp closed 4 years ago
Workaround. Call both fromMarkdown()
with the same option object. But before the second call add:
options.extensions[0] = syntax({type: "yaml", marker: {open: "-", close: "."}});
I don't like it, options should not carry status in my opinion, but at least I can continue with my experiments.
Thanks that helped, pretty deep down, but working on a fix!
Tested. It works without my workaround! Thanks!
Subject of the issue
Calling
mdast-util-from-markdown
withmdast-util-frontmatter
andmicromark-extension-frontmatter
twice in sequence returns YAML front matter only for the first file.Your environment
Steps to reproduce
The input file
example.md
contains:Does not matter if the two
fromMarkdown()
are called with the same or with different inputs.Expected behavior
Both parse should return a block of
"type": "yaml"
.Actual behavior
1) Calling both
fromMarkdown()
withoptions0
fails. The yaml block from the first file is parsed as"type": "yaml"
as it should. Instead the second time it is parsed as"type": "thematicBreak" + "type": "paragraph"
2) Calling secondfromMarkdown()
withoptions1
succeeds (completely separated option objects) 3) Calling secondfromMarkdown()
withoptions2
succeeds (they share the call tomdast-util-frontmatter
) 3) Calling secondfromMarkdown()
withoptions3
fails (they share the call tomicromark-extension-frontmatter
) as case 1. This seems to point to something not reset insyntax()
, but equally could be a problem withmdast-util-from-markdown
for whichfromMarkdown()
does not re-initialize extensions at each call.