markdown icon indicating copy to clipboard operation
markdown copied to clipboard

Serializing to markdown

Open matthew-carroll opened this issue 4 years ago • 5 comments

This package parses markdown strings into an AST. Is this package intended to offer a path in the reverse, to serialize markdown structure to a string?

If it is, can someone add an example to the README?

If not, can that ability be added? Or, would it make sense to extract the AST from this package into a more core package and adjust the API to make such a thing possible?

I'm using this package to parse markdown into my own document structure. I also need to support serialization from my document structure to a markdown string. Currently I'm doing that by hand.

matthew-carroll avatar Apr 01 '21 08:04 matthew-carroll

Not yet. I just wrote a proof-of-concept for what you are describing, and hope to implement it this Spring. :D :D :D

srawlins avatar Apr 01 '21 15:04 srawlins

The original markers are removed when parsing markdown strings into AST structure, it means there are no markers stored in AST nodes. So maybe it is impossible to reverse with current Element model.

chenzhiguang avatar Mar 25 '22 16:03 chenzhiguang

I am going to enhance the AST structure in the coming few weeks, the enhanced AST structure will save the markdown markers which will make it possible to reverse AST structure to it's original markdown string or to beautify markdown string. Also it will be possible to render markdown string to WYSIWYM markdown editor input with the markers highlighted etc.

chenzhiguang avatar Apr 06 '22 10:04 chenzhiguang

Do you plan to add an easy/clean way to update the AST structure (inserting/deleting nodes...) ? (probably part of a new issue but this one is presumably required before)

RichardFevrier avatar Feb 07 '23 17:02 RichardFevrier

@RichardFevrier Yep, maybe you could create an new issue to describe the requirement in detail?

chenzhiguang avatar Feb 08 '23 08:02 chenzhiguang