I'd like to add some additional syntax highlighting to markdown.
I defined an injection grammar:
{
"scopeName": "markdown.mytodos",
"injectionSelector": "L:text.html.markdown",
"patterns": [
{ "include": "#todo" }
],
"repository": {
"todo": {
"match": "^[ \t]*o .*",
"_comment": "Line start, tabs or spaces, then literal `o` and a space",
"name": "entity.name.tag.css"
}
}
}
Result:
I expected to see my rule for both of these examples, but it only works for the first one:
foo
o bar <- correct scope
foo
o bar <- wrong scope (meta.paragraph.markdown)
So it looks like my scope isn't taking, even though the regex matches (tested in isolation).
I looked it up, and Markdown defines meta.paragraph.markdown
with this begin
rule:
(^|\\G)[ ]{0,3}(?=\\S)
and this while
rule:
(^|\\G)((?=\\s*[-=]{3,}\\s*$)|[ ]{4,}(?=\\S))
My current theory is that this unclosed while
is blocking my rule.
Question:
- Does an open rule block any other matches from happening?
- How can I tell my vscode/textmate grammar that I want it to "win" all the time, even inside of a different scope?
I have tried:
- Using begin/end rules instead of
match
(no change) - Defining the language as a subset of
meta.paragraph.markdown
instead oftext.html.markdown
:"injectionSelector": "L:meta.paragraph.markdown"
(doesn't add nested scopes as expected)