Hi, I’ve been trying to add python syntax highlighting withing certain xml tags to the general xml syntax highlighting. I copied the default tag definition in the main context, and changed it so it matches my target tags and applies the python highlighting:
- match: '(<)(exec|virtual|condition|validate)([^/>\s]*)'
captures:
1: punctuation.definition.tag.begin.xml
2: entity.name.tag.localname.xml
push:
- meta_scope: meta.tag.xml
- include: tag-stuff
- match: '>'
scope: punctuation.definition.tag.end.xml
set: Packages/Python/Python.sublime-syntax
with_prototype:
- match: (</)(exec|virtual|condition|validate)
captures:
1: punctuation.definition.tag.begin.xml
2: entity.name.tag.localname.xml
push:
- meta_scope: meta.tag.xml
- include: tag-stuff
- match: '>'
scope: punctuation.definition.tag.end.xml
pop: true
pop: true
This highlights the python code fine, but I am running in the following problem - when both the opening and closing tags are on the same line, it sometimes fails to pop the python syntax. Here are some example with the the scopes on the closing tag:
<exec> a = 2</exec> <!--pops: text.xml punctuation.definition.tag.begin.xml-->
<exec> a = b </exec> <!--pops: text.xml punctuation.definition.tag.begin.xml-->
<exec> a = b</exec> <!--does not pop with space removed: text.xml source.python meta.qualified-name.python punctuation.definition.tag.begin.xml-->
<exec> import test </exec> <!--does not pop: text.xml source.python meta.statement.import.python punctuation.definition.tag.begin.xml-->
I think this has something to do with the meta scopes since the “meta.tag.xml” is not applied to the closing tag regardless of anything at this point. I don’t really know how to add that, maybe it tries to find it in the python syntax file and that fails? Anyways any help would be appreciated here…