How to derive syntax from XML?


I work with files named, say, xyz_*.xml, and the content is a special kind of XML where all CDATA sections are JavaScript code. So I would like to create a little package for myself that does the following:

  • Define a new syntax based on XML where CDATA sections are marked as JavaScript code.
  • Tell Atom to use this syntax for files with the appropriate name (note that checking the extension will not be sufficient).

I have no idea how to go about this. Is there some example I could study? It would be nice if I didn’t have to copy all the syntax patterns for XML but could just override the CDATA behavior in my derived syntax definition.


I briefly wrote about a way do that in that topic: