SublimeText-Markdown / MarkdownEditing

Powerful Markdown package for Sublime Text with better syntax understanding and good color schemes.
MIT License
3.17k stars 649 forks source link

Use pygments for syntax highlighting in code block #740

Closed ncarboni closed 8 months ago

ncarboni commented 8 months ago

While the list of supported languages for code blocks is quite long, some are still missing (ex: SPARQL). I was wondering it if it is possible to use pygments as syntax highlighter instead (or other ones).

Alternatively, as the syntax of some of the language I used are already available for ST, do any know of any guide on how to add them to MarkdownEditing? I would love to use them in code blocks.

deathaxe commented 8 months ago

Highlighting text/source fully relies on ST's syntax engine. It is not possible to use pygments, tree-sitter or any other highlighting engine.

What is needed to highlight fenced code blocks, is:

  1. a syntax definition that ST understands (e.g.: <Name>.sublime-syntax)
  2. a context in Markdown.sublime-syntax which embeds that syntax.

    e.g.: https://github.com/SublimeText-Markdown/MarkdownEditing/blob/38bb41157433808ff265d5298edfd40f202804a1/syntaxes/Markdown.sublime-syntax#L1846C1-L1866

ncarboni commented 8 months ago

Thank you! I will make some tests and, If I manage to make something work, I will do a pull request