Bad rendering on MultiMarkdown Syntax Highlighting

I believe I may have found a bug in the MultiMarkdown Syntax highlighter. I’m currently studying an intro level JS course and adding a whole bunch of code blocks in MultiMarkdown draft. As I add more and more, it seems like the on-screen rendering gets confused and starts showing everything below a certain portion as code env if the code block has been closed off. Usually this goes away by switching to a different Draft and then coming back but now it seems like it’s broken.

I can provide the .md file if desired (not allowed to attach here in the forum). Here’s a screenshot illustrating the problem.

Note from below, if you render to HTML, it looks fine

Sort of a bug, sort of a performance trade off.

To do syntax highlighting, you have to scan the text. To truly be correct in a longer document with a lot of code blocks like this, you have to rescan the entire text to find the paired sets of ticks. Unfortunately, that can be really slow to rescan the entire document for every change. This is less of problem with shorter documents, and less of a problem on Mac than on iOS, but to minimize the performance issues, the default syntax definition for MultiMarkdown is currently configured to look around a text change up to 1000 characters ahead and behind to evaluate syntax.

This means you can get in a case like you describe where you end up with mismatched block elements in the scope of the evaluation. If you reselect the draft from the list, the full text is evaluated, and the variance corrected.

This is configurable in Drafts syntax engine. Once custom syntaxes become available later this year, you could configure an alternate MMD syntax that always evaluated the full text. As it stands, I don’t think it’s a good default, because it longer documents it can create a real noticeable lag when typing.

Hopefully that made some sense.

1 Like

That makes perfect sense. Thanks for the quick response!