zhaouv / vscode-markdown-everywhere

Embed and highlight and preview markdown in any language which support line-comment or block-comment for vscode.
https://marketplace.visualstudio.com/items?itemName=zhaouv.vscode-markdown-everywhere
Apache License 2.0
10 stars 4 forks source link

The way to fix following first line wrongly highlighted as comment in LRSM #25

Open yoshioka-naoki opened 1 day ago

yoshioka-naoki commented 1 day ago

About the comment in readme below on LRSM rule:

There is bug for this case. The following first line will be highlighted as comment. I haven't figured out the mechanism yet. So please put a empty line after these.

This is solved by commenting out whole "if (getRuleType(rule) == LRSM) {..}" in generateGrammar.js. But I don't know if it's Ok. Could you fix it in a right way?

    let injectionAtom = s => 'L:' + s + ' -string -comment -meta.embedded.block.everywhere.md'
   // if (getRuleType(rule) == LRSM) {
   //     injectionAtom = s => 'L:' + s + ' -string -meta.embedded.block.everywhere.md'
   // }
zhaouv commented 1 day ago

left is -string -comment, right is -string.
This change will fix the behavior in line 2 and line 6.
However, the issue described in issue2 still remains: if this if statement is commented out, LRSM will not work in some languages, such as LaTeX and MATLAB.

Anyway, it is a great discovery to identify that this target leads to the "following first line bug".

A choice must be made: either give up LRSM support for some languages or accept the bug.

I will try to find a better way. If no good solution is found, it will roll back the fix of issue 2. The "following first line bug" is widespread in Python. LRSM of LaTeX and MATLAB seems not very useful.

image image