Is there any way to transform AST tree back to markdown?

Thanks for quick feedback for prev answer. Current question will be also about AST.

Is there any way to transform AST tree back to markdown?

For example, I have an md doc, I processed content of it’s AST nodes with kind of typographic tool, and then I want to rewrite original md doc with result of prev step. I have no question about first two steps, but asking you for help about last one.

+++ matmuchrapna [Apr 13 15 13:56 ]:

[1]matmuchrapna [2]Vladimir Starkov
April 13

Thanks for quick feedback for prev answer. Current question will be
also about AST.

Is there any way to transform AST tree back to markdown?

For example, I have an md doc, I processed content of it’s AST nodes
with kind of typographic tool, and then I want to rewrite original md
doc with result of prev step. I have no question about first two steps,
but asking you for help about last one.

The C library (cmark) has a CommonMark renderer. This could be ported over to commonmark.js (the code would be fairly similar), but I haven’t done it yet.

Thanks, for response. Do you plan to port CommonMark render? I really appreciate you help here and your contribution to commonmark on github. I’m not good with C lang, but maybe I can help with smth about porting commonmark render?

Sounds like you’re doing a WYSIWYG editor, looking forward to it!

No, I’m doing typographic engine. And want to use it on markdown, so I want this one in pseudo-code:

md = MDfromAST(ProcessTextNodesFromAST(ASTfromMD(md)));

It’s off-topic but I’m curious, what do you mean with typographic engine? It’s the automatic conversion of ©, ®, ", ™, --,… to the corresponding glyph?

yep, and to eliminate typewriters habits. Checkout packages in my github https://github.com/iamstarkov?tab=repositories and this engine https://github.com/shuvalov-anton/textr