Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I simultaneously use Latex and Markdown syntax highlighting in Sublime Text 2 or TextMate 2?

I use Pandoc which allows mixing of markdown and latex. It would be nice to have syntax highlighting working for both. Any thoughts on the best way to achieve this?

like image 589
bjw Avatar asked Nov 04 '13 23:11

bjw


1 Answers

You should create a new language grammar for Pandoc files that incorporates the Markdown and LaTeX grammars. There are two ways to include rules from other grammars:

  1. Use an include rule and reference elements from the other grammars. For example this would reference include the complete LaTeX and Markdown grammars:

    { patterns = ( 
      { include = 'text.html.markdown'; },
      { include = 'text.tex.latex'; },
      ); 
    }
    

    It is also possible to cherry pick rules from the grammars repository by using this form:

    { include = 'text.html.markdown#block'; }
    
  2. Use injection grammars. You can read more about those on the TextMate blog.

Hope this helps!

like image 92
Dirk Geurs Avatar answered Sep 28 '22 07:09

Dirk Geurs