-
I'd like to parse Markdown, mutate the AST and then obtain a Markdown string again, preserving original formatting. Is that possible, please? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Not with Comrak — it doesn't preserve the original formatting details in its AST (per upstream cmark). So, e.g. It is guaranteed to roundtrip stably, however; i.e. given some input A, when converted back to Markdown you'll get A' (which may or may not be equal to A); when converting A' you will again get A'. |
Beta Was this translation helpful? Give feedback.
Not with Comrak — it doesn't preserve the original formatting details in its AST (per upstream cmark). So, e.g.
_a_
will instead roundtrip to*a*
; the output Markdown when using CommonMark output will preserve the meaning of the input, but not any precise formatting.It is guaranteed to roundtrip stably, however; i.e. given some input A, when converted back to Markdown you'll get A' (which may or may not be equal to A); when converting A' you will again get A'.