language-markdown
language-markdown copied to clipboard
Support proper notations for math/equations
Using $$ ... $$ for display-style equations is not recommended in LaTeX. Instead, users are supposed to use the following notations:
\[ ... \]\begin{equation*} ... \end{equation*}\begin{equation} ... \end{equation}
They work well with MathJax. So I tried adding them to grammars/repositories/flavors/math-block.cson:
key: 'math-block'
patterns: [
{
name: 'block.math.markup.md'
begin: '\\['
end: '\\]'
patterns: [{ include: 'text.tex.latex' }]
beginCaptures:
1: name: 'punctuation.md'
endCaptures:
1: name: 'punctuation.md'
}
{
name: 'block.math.markup.md'
begin: '\\begin{equation}'
end: '\\end{equation}'
patterns: [{ include: 'text.tex.latex' }]
beginCaptures:
1: name: 'punctuation.md'
endCaptures:
1: name: 'punctuation.md'
}
]
After compiling and reloading, Atom recognizes \\[ ... \\] as a math block, but ignores \[ ... \] and \begin{equation} ... \end{equation}. I may be misunderstanding how regex works in Atom.
Could you add a link to documentation that supports your request?
It is written in the first page of "Short Math Guide for LaTeX" from http://www.ams.org/publications/authors/tex/amslatex but their FTP server seems not working now. Here is my copy: short-math-guide.pdf.
Also I found a discussion in Stack Exchange: https://tex.stackexchange.com/questions/503/why-is-preferable-to
Thanks!
To get this working, I think you need to escape the { and } in the second pattern as well. If your change doesn't cause any regressions/issues with the other elements of the grammar, please submit this a PR.
begin: '\\begin\{equation\}'
end: '\\end\{equation\}'
Thanks, but it didn't work. Those single backslashes are removed in the compiled language-markdown.json:
{
"name": "block.math.markup.md",
"begin": "\\begin{equation}",
"end": "\\end{equation}",
"patterns": [
Double backslashes in cson remain double in the compiled json:
begin: '\\begin\\{equation\\}'
end: '\\end\\{equation\\}'
Of course it didn't match \begin{equation} in markdown.
Let me know if and when you've got it figured out. I'm heading into a meeting now.
Now I understand we need \\\\\\[ for a regex pattern in JSON string to match \[.