blackfriday icon indicating copy to clipboard operation
blackfriday copied to clipboard

How to render back to markdown?

Open jcorbin opened this issue 4 years ago • 4 comments

Trying to write a program that's mostly an AST transformer, but I can't seem to find any way to turn a (v2) node back into markdown text ( short of writing my own markdown renderer that is, which I'd like to avoid? or at worst, contribute to the library, rather than maintain in my project? )

jcorbin avatar Jun 26 '20 18:06 jcorbin

You might find https://github.com/jsternberg/markdownfmt to be relevant.

dmitshur avatar Oct 05 '20 21:10 dmitshur

Try https://github.com/JohannesKaufmann/html-to-markdown

inliquid avatar Apr 28 '21 18:04 inliquid

Is there an answer for this? I'm also keen to render a blackfriday.Node back to markdown.

suessflorian avatar Oct 30 '21 06:10 suessflorian

I imported github.com/jsternberg/markdownfmt/markdown and used it as here: https://github.com/Vaelatern/mdbook-d2-go/blob/ace29af66b63df6f54abc66973104b49bb0d6c4f/main.go#L186-L192 to go from blackfriday's AST back to markdown

also pictured, an example of mutating an AST before returning it to markdown.

Vaelatern avatar Jan 11 '23 19:01 Vaelatern