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?
How can I simultaneously use Latex and Markdown syntax highlighting in Sublime Text 2 or TextMate 2?
Asked
Active
Viewed 1,175 times
5
-
1Consolidate the `*.tmLanguage` files for both Markdown and LaTeX. – lawlist Nov 05 '13 at 01:34
1 Answers
5
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:
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'; }
Use injection grammars. You can read more about those on the TextMate blog.
Hope this helps!

Dirk Geurs
- 2,392
- 19
- 24
-
Apologies for the delay, however it's not clear to me where this snippet should sit... It looks like Json which might be converted to a plist, but isn't valid json. Guidance for ST2 would be most helpful. – bjw Dec 11 '13 at 09:35
-
OK, so I found this page on syntax definitions in ST2 using yaml: http://sublime-text-unofficial-documentation.readthedocs.org/en/sublime-text-2/reference/syntaxdefs.html and I've tried this: https://gist.github.com/puterleat/7907963 to no avail... nothing gets highlighted when that definition is activated. – bjw Dec 11 '13 at 10:07
-
I'm not sure about Sublime (I don't use it), but in Textmate 2 you can choose Bundles -> Edit Bundles from the menu. Either create a new language grammar in an existing bundle or create a new bundle. Check out the documentation on how to write grammars: http://manual.macromates.com/en/language_grammars#language_grammars – Dirk Geurs Dec 11 '13 at 14:47