I need to get the content of a CM textArea as html. This needs to include any syntax highlighting, marked text and any changes made by renderLine (ie hanging indent). What will be the best way to achieve this ?
Is there a way to loop through the lines and get their post-renderLine element ?
Nope, there isn’t. You could set the
viewportMargin to Infinity to ensure everything is rendered and take the result of
editor.display.lineDiv.querySelectorAll("pre"). In general, CodeMirror considers it’s DOM structures to belong only inside the editor, and doesn’t provide intefaces for retrieving them—and with good reason, because it’ll be hugely fiddly to get such DOM structures to display properly outside of an editor.
Is setting viewportMargin to Infinity different/better than calling refresh() ?