Similarly to Syntax highlighter from atom to sublime, I wanted to convert the SmPL syntax from an Atom extension, that is also used by GitHub’s syntax hightlighting.
Indeed, one of the formats Atom supports is TextMate’s grammar represented as CoffeScript’s variant of JSON. So I first had to convert the CSON syntax to something more usable.
I found https://github.com/relaxdiego/relaxdiego-sublime-tools, which promised to convert YAML files into the plist format tmlLanguage
expects.
So I converted the CSON syntax into JSON (which works as subset of YAML) using https://www.convertsimple.com/convert-cson-to-json/ and saved it into my working directory with tmLanguage.yml
@relaxdiego’s tools expect.
Then I downloaded the tools and after fixing it slightly, it produced a TextMate syntax.
git clone git@github.com:relaxdiego/relaxdiego-sublime-tools.git
ruby relaxdiego-sublime-tools/lib/translate_yaml_to_tmlanguage.rb SmPL.tmLanguage.yml
Unfortunately, copying the produced SmPL.tmLanguage
file to ~/.config/sublime-text-3/Packages/User/
did not work, with the following error appearing in Sublime Text’s console:
error parsing lexer: Packages/User/SmPL.tmLanguage: Unexpected capture value
Looking briefly at the JSON file, I noticed that it includes etc#comma
and etc#string
, which refers to the Atom package. So I also converted https://github.com/Alhadis/language-etc/blob/669f7b1ca0d1a37bf63754b9df7c53bd89ba4fd9/grammars/etc.cson to etc.tmLanguage
. Unfortunately, that one also fails to parse with:
error parsing lexer: Packages/User/etc.tmLanguage: Expected key name
So I tried manually copying the the necessary items from the etc’s repository
into SaML’s repository and updating the includes. Unfortunately, that did not do anything. The error was still “Unexpected capture value”.
Is there a way to get more information on why the parsing failed?
The grammar I managed to produce: https://gist.github.com/jtojnar/ae41fdf515d7ed91e5bfdb50107d1772#file-saml-tmlanguage