Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve LaTeX support #164

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,25 @@ See [gray-matter](https://github.com/assemble/gray-matter)
![image](https://f.cloud.github.com/assets/383994/2179172/82a6dc1c-9694-11e3-89f1-772bedf02384.png)


## LaTeX Math Support in Markdown Extended

All standard LaTeX math environments (including amsmath) are supported. That is, the following enters the latex scope.

```
$...$

$$...$$

\[...\]

\begin{equation}
...
\end{equation}
```

The supported `\begin{}` environments are `equation`, `align`, `gather`, `alignat`, `flalign`, `multiline`, and the corresponding starred version (e.g. `equation*`).


## Authors

**Jon Schlinkert**
Expand Down
100 changes: 95 additions & 5 deletions Syntaxes/Markdown Extended.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,6 @@ contexts:
scope: markup.heading.2.markdown
captures:
1: punctuation.definition.heading.markdown
- include: latex-display
html_comment:
- match: <!--
captures:
Expand Down Expand Up @@ -1035,6 +1034,7 @@ contexts:
6: constant.other.reference.link.markdown
7: punctuation.definition.constant.markdown
inline:
- include: latex
- include: escape
- include: ampersand
- include: bracket
Expand All @@ -1050,7 +1050,6 @@ contexts:
- include: image-ref
- include: link-ref-literal
- include: link-ref
- include: latex-inline
italic:
- match: |-
(?x)
Expand Down Expand Up @@ -1279,18 +1278,109 @@ contexts:
- include: link-ref-literal
- include: link-ref

latex-inline:
latex:
# $..$
- match: '(?=\$)'
push:
- meta_scope: text.tex.latex
- match: '(?<=\$)'
pop: true
- include: scope:text.tex.latex

latex-display:
# $$..$$
- match: '(?=\$\$)'
push:
- meta_scope: text.tex.latex
- match: '(?<=\$\$)'
pop: true
- include: scope:text.tex.latex
# \[..\]
- match: '(?=\\\[)'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\\])'
pop: true
- include: scope:text.tex.latex
# equation
- match: '(?=\\begin{equation})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{equation})'
pop: true
- include: scope:text.tex.latex
# equation*
- match: '(?=\\begin{equation\*})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{equation\*})'
pop: true
- include: scope:text.tex.latex
# align
- match: '(?=\\begin{align})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{align})'
pop: true
- include: scope:text.tex.latex
# align*
- match: '(?=\\begin{align\*})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{align\*})'
pop: true
- include: scope:text.tex.latex
# gather
- match: '(?=\\begin{gather})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{gather})'
pop: true
- include: scope:text.tex.latex
# gather*
- match: '(?=\\begin{gather\*})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{gather\*})'
pop: true
- include: scope:text.tex.latex
# alignat
- match: '(?=\\begin{alignat})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{alignat})'
pop: true
- include: scope:text.tex.latex
# alignat*
- match: '(?=\\begin{alignat\*})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{alignat\*})'
pop: true
- include: scope:text.tex.latex
# flalign
- match: '(?=\\begin{flalign})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{flalign})'
pop: true
- include: scope:text.tex.latex
# flalign*
- match: '(?=\\begin{flalign\*})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{flalign\*})'
pop: true
- include: scope:text.tex.latex
# multiline
- match: '(?=\\begin{multiline})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{multiline})'
pop: true
- include: scope:text.tex.latex
# multiline*
- match: '(?=\\begin{multiline\*})'
push:
- meta_scope: text.tex.latex
- match: '(?<=\\end{multiline\*})'
pop: true
- include: scope:text.tex.latex