Goldmark renderer, that renders goldmark AST back into markdown. Can be useful for programmatic markdown editing or formatting.
Rendered markdown should be semantically equivalent to the original markdown parsed by goldmark
.
In practice, it means that
markdown input
-> goldmark parser AST
-> goldmark HTML render
and
markdown input
-> goldmark parser AST
-> goldmark-markdown rendered markdown
-> goldmark parser AST
-> goldmark HTML render
should be identical, since the canonical markdown target is HTML.
Features:
-
Correctly renders all examples in commonmark 0.31.2 spec.
-
Correctly renders all examples in GitHub Flavored Markdown 0.29 spec
-
Correctly renders a wide variety of markdown documents.
-
Supports rendering all markdown elements
- TODO: indented code blocks are replaced by fenced code blocks. It's hard to calculate appropriate padding that doesn't conflict with lazy list continuations.
-
Supports rendering all GitHub Flavored Markdown elements
-
Handles all edge cases.
- Known issue: not all emphasis rules are followed, some unnatural nested emphasis sequences change their meaning.
- Currently, the escaping is overly eager
-
In-depth customization. Choose your preferred heading, hr, code block styles, emphasis characters, etc.
go build ./examples/mdformat
./mdformat -i README.md -o README2.md