How to mark already parsed nodes

As the MarkdownParser doesn’t accept html as input (it requires and parse only text) and i still need to parse markdown in my editor , i had to iterate over all its document’s content text nodes and parse their text using the MarkdownParser and then replacing them using tr.replaceWith().

As i need to repeat this process after each edit, i need to prevent re-parsing the same nodes everytime and only parse any new added content which may have unparsed markdown on it.

It’s not only for the matter of optimisation (although that’s very important too). Actually i also had some problems when reparsing the same nodes again (their content sometimes is wrong in a second parse)

Is it possible somehow to flag already parsed nodes to avoid reparsing them ?

The way to do this would be either to check the step maps in a given transaction to determine which range of the document changed, or to use a function like this to only iterate through parts of the document that are different from the previous document tree.

Thanks. I’ve tried the changedDescendants() and it works well.

But let me share my experience with markdown parsing on editing.

Acutally i didn’t know all markdown codes spec. I got lots of problem when editing. For example while trying to type some of them in the editor such as :

  • **bold**, i get a list inserted just after the first typed *.

  • When i type a white space after any character, the parser will replace the 'x ’ with a ‘x’ (the white space is removed).

Right now i was looking at this spec to understand the reasons of such bad user experience when using the editor and parsing the markdown in real time.