REditorSupport / sublime-ide-r

R-IDE: Make Sublime Text a perfect IDE for R
MIT License
112 stars 7 forks source link

Syntax highlighting in Rmd: LaTeX equations with \(\) and \[\] #47

Open rcragun opened 3 years ago

rcragun commented 3 years ago

The RMarkdown syntax highlighting does not seem to recognize \( \) and \[ \] as math delimiters.

Here is an example Rmd file to illustrate, and I have attached a screenshot of how the syntax highlighting looks.

---
title: "Sublime Text 4 R-IDE Rmd syntax highlighting problem"
author: "Randy Cragun"
output: html_document
---

Correct syntax highlighting:

  * Inline equation: $\overline{Y}_{g,t}$
  * Display equations:
      $$\overline{Y}_{g,t}$$
      \begin{equation}\overline{Y}_{g,t}\end{equation}

Possibly incorrect highlighting: inline equation: \(Y_{g,t}\)

Incorrect highlighting:

  * Inline equation: \(\overline{Y}_{g,t}\) (everything after _ is treated as italic, which is possibly a second issue)
  * Display equation:
      \[\overline{Y}_{g,t}\]

I left two line breaks at the end of the file to illustrate that the highlighting suggests that there is an un-closed delimiter at the end. SublimeRmdMathDelim

\( \) should be treated as math delimiters. RMarkdown supports it. Pandoc supports it. Furthermore, $ $ is supposedly deprecated (see this answer, for example). I think the problem of underscore being treated as starting a section of italics will be solved if \( \) and \[ \] are recognized as math delimiters.

My system: