jakeboone02 / vscode-language-mediawiki

Syntax highlighting for Mediawiki markup
MIT License
12 stars 2 forks source link

Nesting Bold and Italics #1

Open BobChao87 opened 7 years ago

BobChao87 commented 7 years ago

Nesting bold and italics inside of each other produces unexpected results and causes faulty syntax highlighting.

As an example:

'''''Note:''' Some italics only text here '''restore bold,''' bold is over.''

This ends up being rendered as

screenshot from 2017-03-14 19 15 48

Interestingly, the initial bold/italics tick marks seem to be ordered randomly. Sometimes two italics first, sometimes three bold first.

While I understand if for technical reasons you cannot both italics and bold the font (i.e. "Note" and "restore bold,"), it would be nice if the extension correctly started and terminated portions of the string that should be rendered in italics only and are not being bolded in the final product.

Notably, switching the markers produces correct markup as least so far as applying the correct single styling to portions that are only single-styled. Obviously it's still off for double-styled portions as that case doesn't seem to be handled.

screenshot from 2017-03-14 19 21 26

After this bug occurs, text apparently becomes permanently italics as the parser likely thinks the trailing '' is an opening marker, not a closing one.

jakeboone02 commented 7 years ago

Thanks. I've noticed that bug myself but haven't tried to fix it. Honestly I've never touched the syntax code itself. I just copied it from the TextMate bundle and published it to the VS Marketplace.

Seems like an easy fix in regex terms, but TM grammars are strange things.

Feel free to submit a PR if you want to try to fix it. I think it may have involve adding some boundary-type regex code around the ''' and '' begin/end markers.