Example syntax I’m trying to highlight looks like this:
...
script {
javascript goes here
}
...
The problem is that javascript inside the script section can (obviously) also contain }
. Which means that I can’t simply do:
- match: 'script \{'
push: "Packages/JavaScript/JavaScript.sublime-syntax"
with_prototype:
- match: '\}'
pop: true
What I came up with is the following:
- match: 'script \{'
push: script
script:
- match: ''
set: Packages/JavaScript/JavaScript.sublime-syntax
with_prototype:
- match: \{
push: script
- match: \}
pop: true
This works… to an extent. Since parser consumes {
and }
, JSON objects are not detected. Even worse - sometimes javascript parser also doesn’t like what I’m doing:
This is probably happening because the text field1: "value"
is not a valid javascript.
Am I missing something and there’s an easier way to pass highlighting to the JS highlighter and get back when JS pops out its last context?