Reputation: 20437
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:
I have tried:
match
(no change)meta.paragraph.markdown
instead of text.html.markdown
: "injectionSelector": "L:meta.paragraph.markdown"
(doesn't add nested scopes as expected)Upvotes: 3
Views: 425
Reputation: 20437
I have found that changing my match pattern resolves the issue.
Did not work in the nested case:
^[ \t]*o .*
Works great for all cases I've tested:
(^|\G)[ \t]*o .*
Docs say:
\G asserts position at the end of the previous match or the start of the string for the first match
What does this mean in the context of multiple scope selectors trying to be matched by vscode/textmate? I'm not sure. Please chime in if you know!
Upvotes: 1