Closed wooorm closed 3 years ago
What I just experienced is that ---
is serialized as ***
.
const mdSyntaxTree = markdownToMdAst(markdown);
console.log(toMarkdown(mdSyntaxTree));
function markdownToMdAst(markdown) {
const mdAstTree = unified()
.use(remarkParse)
.parse(markdown)
return mdAstTree;
}
one
---
two
@benwoodward what you're describing is different, unrelated, and expected behavior. Both are thematic breaks https://astexplorer.net/#/gist/526a859153287c044491fa011ed08a14/c4ae05f5e409472ddf66386f216bf29a0681be4d
MDAST is an AST, not a CST. Meaning it will preserve structure, it was a thematic break before, it still is a thematic break, but it may not preserve the exact formatting as before (which a CST would).
Another example related to this, lists with a thematic break inside also collapse into just a thematic break
- * **
Another variation of this
- -
-
- -
compiles to
* *
* * *
which appears to trigger the issue again, even in latest
Could you make this reproducible? Or is it literally this way in this projects tests? I’m hoping that this was already fixed, because the tests seem to indicate it: https://github.com/syntax-tree/mdast-util-to-markdown/commit/0148aa6e0318116cf5d2102cd8be28486be9d737.
thanks! released too!
Subject of the issue
Your environment
n/a
Steps to reproduce
The following uncommon markdown is three empty lists/list items in each other.
Expected behavior
🤷♂️
Actual behavior
Given that
bullet
is set to a value that can also be used for a thematic break (-
or*
),from-markdown
will serialize as* * *
or- - -
, which is then parsed again as a thematic break.