Closed puterleat closed 8 years ago
I figured out a simple hack to include latex highlighting inline. seems to work well so far.
Inline math with e.g. $f(x) = x^2$ works.
Display math works also, with
$$ f(x) = x^2 $$
However, if I do \begin{equation} .... \end{equation} it screws up the highlighting for the rest of the document. Typically, I just use $$ anyways...
I haven't tested it extensively... but most latex commands (section, def, ref, cite etc...) display fine. And markdown code blocks are not affected (don't want latex highlighting in your python code!)
The hack is, at line 1788, there is a the inline
key parameter. I simply added:
<dict>
<key>include</key>
<string>text.tex.latex</string>
</dict>
to the end of the array of patterns.
i.e.:
<key>inline</key>
<dict>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#escape</string>
</dict>
<dict>
<key>include</key>
<string>#ampersand</string>
</dict>
<dict>
<key>include</key>
<string>#bracket</string>
</dict>
<dict>
<key>include</key>
<string>#raw</string>
</dict>
<dict>
<key>include</key>
<string>#bold</string>
</dict>
<dict>
<key>include</key>
<string>#italic</string>
</dict>
<dict>
<key>include</key>
<string>#line-break</string>
</dict>
<dict>
<key>include</key>
<string>#image-inline</string>
</dict>
<dict>
<key>include</key>
<string>#link-inline</string>
</dict>
<dict>
<key>include</key>
<string>#link-inet</string>
</dict>
<dict>
<key>include</key>
<string>#link-email</string>
</dict>
<dict>
<key>include</key>
<string>#image-ref</string>
</dict>
<dict>
<key>include</key>
<string>#link-ref-literal</string>
</dict>
<dict>
<key>include</key>
<string>#link-ref</string>
</dict>
<dict>
<key>include</key>
<string>text.tex.latex</string>
</dict>
</array>
</dict>
closing due to age
That would be a really usefull feature since one of the software which make me write markdown is pandoc. And pandoc allows raw LaTex commands.
Could you at least add syntax and color features for two things:
$ inline equation $
or $$ multiline equation $$
[@my_bib_key]
Thank you !
@hadim can you open a new issue to discuss? thanks
Using inline latex is a pretty common pattern in markdown documents destined for conversion with pandoc.
For example, one might include the command \textsc{small caps text} in a pandoc markdown doc because markdown has no native syntax for small caps.
However at present I can't work out how to get both markdown and latex syntax highlighting active at the same time. It would also be nice if the document tree (for ctrl-R) recognised both markdown headings and \part{} \chapter{} and \section{} commands.