Sublime Forum

Add Latex equations and override Markdown syntax highlight

#1

Hi,

I’ve been trying to find a nice syntax highlighting format for R Markdown files (.Rmd) in Sublime Text 3.
It turns out that the Monokai Bright color scheme theme is almost a great match, since it does the proper syntax highlight for code chucks and plain markdown. So I thought it be easy to modify this existing one?

However, .Rmd files are compatible with Latex equations, which are either flagged with a single $ (in-text equation) or $$ (display equation). I’ve looked at the .tmTheme for Monokai bright, but I have no idea how to implement the latex equation flagging. Also, importantly, once those equations are flagged, it’d be great if it could override underscores, which normally italicise text under the Markdown syntax highlight. Below is an example of a .Rmd file using Monokai Bright color scheme in ST3 (upper box) and RStudio (proper highlighting, lower box):

See how the underscore overrides the equation (i.e. everything in between underscores turned pink) using Monokai Bright? Any ideas on how to implement this type of highlighting from the Monokai Bright color scheme? Thanks for the support.
Best,
Diego

0 Likes

#2

There’s a package for Sublime called R-Box that has syntax definitions for R Markdown. I tested your sample code and it looks like it works pretty well. That way you can use any color scheme you’d like and it will still highlight everything correctly. Hope that helps!

1 Like

#3

Works perfectly! Thanks very much for your quick reply!
All the best,
Diego

1 Like