microsoft / vscode-markdown-tm-grammar

VS Code built-in markdown extension's Textmate grammar
MIT License
63 stars 50 forks source link

Tildes in attributes of fenced code block break highlighting for the rest of the file #126

Closed a-stewart closed 1 year ago

a-stewart commented 1 year ago

Fenced code blocks fail if there is a tilde (or backtick) in the attributes of a fenced codeblock.

For example, the following markdown highlights as expected.

```sh {higlight="content:/$foo"}
cd ~/$foo
```

But as soon as you add a tilde to the filepath, syntax highlighting stops working:

```sh {higlight="content:~/$foo"}
cd ~/$foo
```

This works with github, for example:

cd ~/$foo

But in VS Code, the opening of the code block is not recognised, which results in the closing of the code block being recognised as an opening which breaks highlighting for the remainder of the file.

I have tried to find why backticks and tildes are excluded here, but they date back to the initial commit, so I am not fully sure of the reasoning for excluding them. Other than perhaps to avoid matching something like ~~~foo~~~ which should be matched by a different rule? In which case perhaps we could instead block on 3 or more?