Sublime Forum

Color highlight latex commands within html file

#1

I use Mathjax for math equations within an html document. Mathjax uses Latex commands within the document to add equations. I would like to assign a color to Latex commands such as \begin and \end. I think this involves building a new syntax and scope and assigning a color to that scope. However, I haven’t figured out the steps in order to do that. Can someone help.

0 Likes

#2

If you just want to highlight latex within HTML content it is as easy as creating a Packages/User/HTML (MathJax).sublime-syntax with the following content.

%YAML 1.2
---
name: HTML (MathJax)
scope: text.html.mathjax

file_extensions:
  - html
  - htm
  - shtml
  - xhtml

contexts:
  main:
    - include: scope:text.tex.latex
    - include: scope:text.html.basic
0 Likes

#3

That worked. Both HTML and LaTex commands are highlighted. One small problem is that my html file icons have disappeared.

0 Likes

#4

You can override the normal HTML file by renaming top-level scope to text.html.basic.

Unfortunatelly A File Icon can’t override normal file_type_markup which is bound to text.html due to a shortcomming (https://github.com/sublimehq/sublime_text/issues/4107)

0 Likes

#5

I’ve been trying to get brackethighlighter to work in an html file with syntax HTML (MathJax). I added “HTML (MathJax)” to the list of syntaxes under “mode”: “html” in bh_tag.sublime-settings. It still doesn’t highlight or match html tags. Any suggestions would be appreciated.

0 Likes

#6

[Problem Solved] See solution

0 Likes

Is it possible to use two syntaxes/themes at the same time?