For example, I create an inline match for latex which includes the build-in latex grammar.
"latex-inline":
name: "markup.latex.inline"
patterns: [{include: "text.tex#math"}]
begin: "(\\$)"
end: "(\\$)"
beginCaptures:
1: name: "punctuation.boundary.latex"
endCaptures:
1: name: "punctuation.boundary.latex"
However, this does not work well as it cannot correctly highly the following,
All string inside the outer pair of $ should be colored green. This is a valid latex with nested $ … {$…$} … $, where the brackets ‘{’ ‘}’ help escape the inside ‘$’ pair. However, my grammar above obviously cannot capture this and wrongly recognize it as two pieces of latex code. How do I make a correct highlight with such escaping brackets?