Bad rendering on MultiMarkdown Syntax Highlighting

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.

2 Likes