Recommended approach for altering Markdown formatting

Hello!

I’m creating a plugin for Obsidian and am traversing the Markdown document with a SyntaxTree.

Let’s assume that during traversal, I encounter a bolded node and want to remove the bold formatting on the node’s text.

To do so, I know I can find the location of the node within the document and manually remove the asterisks that “start” and “end” the bolded section.

This feels a bit messy, though - I’m already working with the SyntaxTree - is there a way to simply modify the SyntaxTree to remove the bolding? That way, I don’t have to do any manual transformations on the underlying Markdown.

My guess is that this isn’t possible - As far as I can tell, CodeMirror/Lezer is a one-way parser; I’m guessing there isn’t a way to modify the SyntaxTree and render it back into Markdown. Is my guess correc?

Also, if the “SyntaxTree mutation” approach isn’t feasible, is modifying the document itself (e.g. removing the asterisks denoting “bold”) the recommended approach? Or, is there another approach you’d recommend?

Thanks in advance for any guidance you can provide!

Correct.

Yes, that should work.

Thank you very much for your quick response!

While we’re talking about it, can you think of any project(s) off of the top of your head doing something similar that I should check out?

It would be better to contribute to an existing project than to start my own!

I’m not aware of any.