1

Is there a method to import a tmLanguage.json into Sphinx to add support for a new/custom language for RST?

Ajani Bilby
  • 112
  • 10

1 Answers1

2

There is not directly; if necessary you'll have to write a lexer for a new language in Python. I say if necessary because Sphinx's syntax highlighting is provided under the hood by Pygments, which supports a huge number of languages; you just need to turn support on in Sphinx using the highlight_language config value. The short names for all the various lexers are shown here.

If, somehow, your language doesn't have a lexer already, there are instructions on how to write your own. It's largely (but not entirely) a process of translating the Oniguruma regexes in the .tmLanguage.json file to Python-flavored ones.

One would also hope that you'd contribute it to the pygments Github project, too.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • I was hoping there might be some tools to convert a tmLang into python to save on dev time as there other things that have higher priority. But a good list of links that will surely help in the future – Ajani Bilby Jun 14 '21 at 03:16