In case all all CDATA tags contain the same syntax, you may use something like …
Packages/User/XML (PHP).sublime-syntax
%YAML 1.2
---
name: XML (PHP)
scope: text.xml.php
contexts:
main:
- include: cdata
- include: scope:text.xml
cdata:
- match: (<!\[)(CDATA)(\[)
scope: meta.tag.sgml.cdata.xml
captures:
1: punctuation.definition.tag.begin.xml
2: keyword.declaration.cdata.xml
3: punctuation.definition.tag.begin.xml
embed: scope:embedding.php
embed_scope: meta.tag.sgml.cdata.xml
escape: ']]>'
escape_captures:
0: meta.tag.sgml.cdata.xml punctuation.definition.tag.end.xml
Note:
-
scope:embedding.php is embedded as I already saw PHP tags.
- You may also use
scope:text.html instead if only <script type="text/javascript"> is to be supported.
- You may use
scope:source.js in case CDATA tags contain JavaScript only.
- This solution removes
string scope from all CDATA tags.