Skip to content

Instantly share code, notes, and snippets.

@deathaxe
Created July 24, 2021 13:19
Show Gist options
  • Save deathaxe/752711dada1622f390158840003a6dd7 to your computer and use it in GitHub Desktop.
Save deathaxe/752711dada1622f390158840003a6dd7 to your computer and use it in GitHub Desktop.
XML syntax for Sublime Text 4 with python syntax highlighting in <exec>...</exec> tags.
%YAML 1.2
---
name: XML (Python)
scope: text.xml.python
version: 2
extends: Packages/XML/XML.sublime-syntax
# file_extensions:
# - xml
contexts:
###[ XML TAGS ]###############################################################
tag:
- meta_prepend: true
- include: python-tags
###[ PYTHON XML TAGS ]########################################################
python-tags:
- match: (<)(exec|virtual|condition|validate)(?=[/<>\s])
captures:
1: punctuation.definition.tag.begin.xml
2: entity.name.tag.localname.xml
push: python-tag-content
python-tag-content:
- meta_scope: meta.tag.xml
- match: '>'
pop: 1
scope: meta.tag.xml punctuation.definition.tag.end.xml
embed_scope: meta.embedded.python.xml source.python.embedded.xml
embed: Packages/Python/Python.sublime-syntax
escape: (?=(</)(exec|virtual|condition|validate)[/<>\s])
- match: />
scope: punctuation.definition.tag.end.xml
pop: 1
- match: \?>
scope: invalid.illegal.bad-tag-end.xml
pop: 1
- include: tag-end-missing-pop
- include: tag-attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment