Skip to content

Commit

Permalink
[LaTeX] Add support for IEEEarray environments (#4123)
Browse files Browse the repository at this point in the history
This commit...

1. adds support for `\begin{IEEEeqnarray}` math environments.
   specified by: https://moser-isi.ethz.ch/docs/typeset_equations.pdf
   inspired by: SublimeText/LaTeXTools#1413
2. fixes `meta.environment.math.block` scope by removing incomplete `.be`.
3. fixes `\end` scope using `keyword.control.flow.end.latex`.
  • Loading branch information
deathaxe authored Jan 13, 2025
1 parent 83da0ee commit 62ef832
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 9 deletions.
19 changes: 17 additions & 2 deletions LaTeX/LaTeX.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -634,16 +634,31 @@ contexts:
4: variable.parameter.function.latex
5: punctuation.definition.group.brace.end.tex
push: block-math-begin-end-command-body
- match: |-
(?x)
((\\)begin)
\s* (\{) \s* ( IEEEeqnarray\*? ) \s* (\})
(?: \s* (\{) \s* ( {{letter}}+ ) \s* (\}) )?
captures:
1: support.function.begin.latex keyword.control.flow.begin.latex
2: punctuation.definition.backslash.latex
3: punctuation.definition.group.brace.begin.tex
4: variable.parameter.function.latex
5: punctuation.definition.group.brace.end.tex
6: punctuation.definition.group.brace.begin.tex
7: variable.parameter.function.latex
8: punctuation.definition.group.brace.end.tex
push: block-math-begin-end-command-body
block-math-begin-end-command-body:
- meta_content_scope: meta.environment.math.block.be.latex markup.math.block
- meta_content_scope: meta.environment.math.block.latex markup.math.block
- include: block-math-begin-end-command-end
- include: math-content

block-math-begin-end-command-end:
- match: ((\\)end)(\{)\s*(\4)\s*(\})
captures:
1: support.function.end.latex keyword.control.flow.begin.latex
1: support.function.end.latex keyword.control.flow.end.latex
2: punctuation.definition.backslash.latex
3: punctuation.definition.group.brace.begin.tex
4: variable.parameter.function.latex
Expand Down
61 changes: 54 additions & 7 deletions LaTeX/tests/syntax_test_latex.tex
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,13 @@ \subsubsection{name}
% ^^^^^^^^^^ markup.math.inline - string
% ^ punctuation.definition.string.end.tex - markup.math.inline
$\verb!$! \alpha$
%^ meta.environment.math.inline.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex
% ^^^^^^^^^^^^^^^ meta.environment.math.inline.dollar.tex markup.math.inline
% ^ markup.raw.verb.latex
% ^^^^^^ keyword.other.math.greek.tex
% ^ meta.environment.math.inline.dollar.tex string.other.math.tex punctuation.definition.string.end.tex
$$f(x) = x^2$$
%^^ string.other.math.tex punctuation.definition.string.begin.tex
%^^^^^^^^^^^^^^ meta.environment.math.block.dollar.tex
Expand Down Expand Up @@ -838,21 +845,61 @@ \subsubsection{name}
% ^^^^^^^^ variable.parameter.function.latex
% ^ punctuation.definition.group.brace.end.tex
f(x) = x^2
% <- meta.environment.math.block.be.latex variable.other.math.tex
% <- meta.environment.math.block.latex variable.other.math.tex
%^^^^^^^^^ meta.environment.math.block
\end{equation}
% <- support.function.end.latex keyword.control.flow.begin.latex punctuation.definition.backslash.latex
%^^^ support.function.end.latex keyword.control.flow.begin.latex
% <- support.function.end.latex keyword.control.flow.end.latex punctuation.definition.backslash.latex
%^^^ support.function.end.latex keyword.control.flow.end.latex
% ^ punctuation.definition.group.brace.begin.tex
% ^^^^^^^^ variable.parameter.function.latex
% ^ punctuation.definition.group.brace.end.tex
\begin{equation*}
% <- support.function.begin.latex keyword.control.flow.begin.latex punctuation.definition.backslash.latex
%^^^^^ support.function.begin.latex keyword.control.flow.begin.latex
% ^ punctuation.definition.group.brace.begin.tex
% ^^^^^^^^^ variable.parameter.function.latex
% ^ punctuation.definition.group.brace.end.tex
f(x) = x^2
% <- meta.environment.math.block.latex variable.other.math.tex
%^^^^^^^^^ meta.environment.math.block
\end{equation*}
% <- support.function.end.latex keyword.control.flow.end.latex punctuation.definition.backslash.latex
%^^^ support.function.end.latex keyword.control.flow.end.latex
% ^ punctuation.definition.group.brace.begin.tex
% ^^^^^^^^^ variable.parameter.function.latex
% ^ punctuation.definition.group.brace.end.tex
$\verb!$! \alpha$
%^^^^^^^^^^^^^^^ meta.environment.math.inline.dollar.tex markup.math.inline
% ^ markup.raw.verb.latex
% ^^^^^^ keyword.other.math.greek.tex
\begin{IEEEeqnarray}
%^^^^^ support.function.begin.latex keyword.control.flow.begin.latex
% ^ punctuation.definition.group.brace.begin.tex
% ^^^^^^^^^^^^ variable.parameter.function.latex
% ^ punctuation.definition.group.brace.end.tex
f(x) = x^2
% <- meta.environment.math.block.latex variable.other.math.tex
%^^^^^^^^^ meta.environment.math.block
\end{IEEEeqnarray}
%^^^ support.function.end.latex keyword.control.flow.end.latex
% ^ punctuation.definition.group.brace.begin.tex
% ^^^^^^^^^^^^ variable.parameter.function.latex
% ^ punctuation.definition.group.brace.end.tex
\begin{IEEEeqnarray}{c}
%^^^^^ support.function.begin.latex keyword.control.flow.begin.latex
% ^ punctuation.definition.group.brace.begin.tex
% ^^^^^^^^^^^^ variable.parameter.function.latex
% ^ punctuation.definition.group.brace.end.tex
% ^ punctuation.definition.group.brace.begin.tex
% ^ variable.parameter.function.latex
% ^ punctuation.definition.group.brace.end.tex
f(x) = x^2
% <- meta.environment.math.block.latex variable.other.math.tex
%^^^^^^^^^ meta.environment.math.block
\end{IEEEeqnarray}
%^^^ support.function.end.latex keyword.control.flow.end.latex
% ^ punctuation.definition.group.brace.begin.tex
% ^^^^^^^^^^^^ variable.parameter.function.latex
% ^ punctuation.definition.group.brace.end.tex
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Boxes
Expand Down

0 comments on commit 62ef832

Please sign in to comment.