This Engineering Notebook post discusses adding syntax coloring for section references and Leo directives to leoInteg. It will be of interest mainly to Félix.
*Background* At present, leoInteg only syntax colors Leonine syntax. In *addition*, we want leoInteg to color language-specif constructs. *Syntax description files* drive syntax coloring in vs code. There is (probably) one such file for each language that vs code can color. Various plugins add their own syntax description files. The *syntax* of syntax description files is json. A TextMate grammar <https://macromates.com/manual/en/language_grammars> specifies the valid *contents *(semantics) of these files. In python, parsing a json file is very easy. If "contents" is the contents of a .json file, the following parses the file: import json ... d = json.loads(contents) For TextMate grammar files, d will be a top-level python dict, whose values are inner dicts, lists, strings, etc. Please read the TextMate grammar <https://macromates.com/manual/en/language_grammars> carefully before reading further. The documentation is good, but it took me awhile to get my head around all the details. *Merging Leo's rules into existing grammar rules* The task is to create Leonine versions of all existing syntax description files. For each existing file, we must create a new file that adds Leo's constructs. It's important to automate this process with Leo script. Let's call this script the *description script*. There are, *maybe, *two ways forward. The description script could either *copy* Leonine rules into existing description files, or it could *reference* Leonine rules. A few experiments should tell if reference a separate (embedded) *Leo language description* will work. If not, the description script will copy (merge), say, leo.json into the existing language description file. *Summary* Vs code uses language description files, in json format, to drive syntax coloring. Parsing these files is easy. A TextMate grammar <https://macromates.com/manual/en/language_grammars> specifies the format of language description files. A *language description script* will create a new, Leonine, language description file for every existing language description file. Merging Leo's syntax coloring rules into the existing description should be fairly straightforward. However, some hand tweaks may be necessary. I am about to start work on this script. Once it works for one language, it is likely to work for most languages. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/471e0dc0-64e2-4e6e-8099-aae0447f4973o%40googlegroups.com.
