icyleaf / markd

Yet another markdown parser, Compliant to CommonMark specification, written in Crystal.
MIT License
109 stars 31 forks source link

Markdown renderer #57

Open devnote-dev opened 1 year ago

devnote-dev commented 1 year ago

A renderer for markdown (markdown -> markdown, instead of just markdown -> HTML). This would be useful if you just want to insert/edit/remove parts of a markdown document (e.g. setting a default language for fenced code blocks).

straight-shoota commented 1 year ago

Just a note on that use case: Markdown syntax has quite a lot ambiguities and alternative styles to express the same thing. So the process parse -> mutate AST -> stringify can introduce syntactic changes besides the ones that you actually intent to do. Maybe this doesn't matter much for your use case, but it's an annoyance (at least) for many applications. To avoid this you would need some way to convey information about syntax variations from the parser to the stringifier. Currently the AST is not capable of that.

devnote-dev commented 1 year ago

I see what you mean, for my use-case I'm setting the default language for doc comments in Crystal to crystal but that might cause issues if someone uses a tilde-based code block instead of a back tick one. At the same time, I'm not sure if it's worth implementing support for the variants as that specific edge case is unlikely.