jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
189 stars 61 forks source link

Support "include" element in list contexts (e.g., Javascript included in Typescript) #124

Closed fuhrmanator closed 2 years ago

fuhrmanator commented 3 years ago

Because some language syntaxes "include" others, e.g., Typescript includes Javascript, the highlighting must also follow these links via the include element. For example with Typescript:

https://github.com/KDE/syntax-highlighting/blob/4e1203e2d985e84e8016ca3211c1f33ce71299e0/data/syntax/typescript.xml#L76-L83

<!-- Include all JavaScript keywords! -->
<list name="controlflow">
    <include>controlflow##JavaScript</include>
    <item>goto</item>
</list>
<list name="keywords">
    <include>keywords##JavaScript</include>
</list>
    ...

The current "bug" is that if you use Typescript as a language, it won't include the Javascript keywords, and so highlighting isn't very useful.

See https://github.com/jgm/skylighting/issues/57#issuecomment-859199801 for more details and workarounds.