From 718926acebabe14385a5a24f0c727de2042cd420 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 12 Nov 2022 18:59:51 +0100 Subject: [PATCH 01/46] [LaTeX] Inherit LaTeX from TeX --- LaTeX/LaTeX.sublime-syntax | 84 +++++++------------------------------ LaTeX/TeX.sublime-syntax | 4 ++ LaTeX/syntax_test_latex.tex | 15 +++++-- 3 files changed, 30 insertions(+), 73 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index 0f1adb8955..a76bf2ad83 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -4,6 +4,8 @@ name: LaTeX scope: text.tex.latex +extends: TeX.sublime-syntax + file_extensions: - tex - ltx @@ -14,18 +16,13 @@ first_line_match: |- ) contexts: - prototype: - - include: comments main: - - include: unique-latex + - meta_prepend: true + - include: latex - include: packages - - include: plain-tex - - include: begin-end-commands - - include: general-commands - - include: global-braces - unique-latex: + latex: - include: preamble - include: structure - include: includes @@ -39,19 +36,7 @@ contexts: - include: graphics - include: lists - plain-tex: - - include: macros - - include: scope:text.tex#controls - - include: scope:text.tex#catcode - - include: boxes - - include: block-math - - include: inline-math - - include: general-constants - - comments: - - include: scope:text.tex#comments - - global-braces: + braces: - match: \{ scope: punctuation.definition.group.brace.begin.latex push: @@ -72,7 +57,7 @@ contexts: pop: true - include: general-constants - include: general-commands - - include: global-braces + - include: braces - match: '[A-Za-z[:digit:]-]*(?=\s*\=)' scope: variable.parameter.bracket.latex @@ -83,20 +68,6 @@ contexts: pop: true - include: main - # matches any nospace and pops the context - else-pop: - - match: (?=\S) - pop: true - - immediately-pop: - - match: '' - pop: true - - # pops out of the current context if there is a new paragraph - paragraph-pop: - - match: ^(?=\s*$) - pop: true - argument: - match: \{ scope: punctuation.definition.group.brace.begin.latex @@ -121,7 +92,7 @@ contexts: - include: macro-braces macros: - - include: scope:text.tex#macros + - meta_append: true - match: (\\)(?:new|renew|provide)command(?:\*|(?![A-Za-z@])) scope: keyword.declaration.function.latex storage.modifier.newcommand.latex captures: @@ -246,6 +217,7 @@ contexts: - include: else-pop general-constants: + - meta_prepend: true - match: (\\\\)(?:(\[)\s*-?((?:[[:digit:]]|\.)*)\s*(\w*)\s*(\]))? captures: 1: constant.character.newline.latex @@ -253,9 +225,9 @@ contexts: 3: constant.numeric.newline.latex 4: keyword.other.newline.latex 5: punctuation.definition.group.bracket.begin.newline.latex - - include: scope:text.tex#general-constants general-commands: + - include: begin-end-commands - match: (\\)[A-Za-z@]+ scope: support.function.general.latex captures: @@ -495,33 +467,16 @@ contexts: - include: math-content math-content: - # unique to latex + - meta_prepend: true + - match: (?=\}) + pop: true - include: verb - include: text-decorators - include: references - include: begin-end-commands - # extended from tex - - include: scope:text.tex#math-builtin - - include: scope:text.tex#math-brackets - - include: math-braces - - include: boxes - - include: scope:text.tex#math-commands - - include: scope:text.tex#math-operators - - include: scope:text.tex#math-characters - - include: scope:text.tex#math-numerics - - include: general-constants - - match: (?=\}) - pop: true inline-math: - - match: \$ - scope: string.other.math.latex punctuation.definition.string.begin.latex - push: - - meta_scope: meta.environment.math.inline.dollar.latex - - match: \$ - scope: string.other.math.latex punctuation.definition.string.end.latex - pop: true - - include: math-content + - meta_append: true - match: ((\\)ensuremath)(\{) captures: 1: support.function.ensuremath.latex @@ -547,15 +502,7 @@ contexts: - include: math-content block-math: - - match: \$\$ - scope: string.other.math.latex punctuation.definition.string.begin.latex - push: - - meta_scope: meta.environment.math.block.dollar.latex - - match: \$\$ - scope: string.other.math.latex punctuation.definition.string.end.latex - pop: true - - include: math-content - + - meta_append: true - match: (\\\[) scope: string.other.math.latex punctuation.definition.string.begin.latex push: @@ -564,7 +511,6 @@ contexts: scope: string.other.math.latex punctuation.definition.string.end.latex pop: true - include: math-content - - match: |- (?x) ((\\)begin)(\{)\s*((?: diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 667f1e5388..4a7277cbf6 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -85,6 +85,10 @@ contexts: - match: (?=\S) pop: true + immediately-pop: + - match: '' + pop: true + # pops out of the current context if there is a new paragraph paragraph-pop: - match: ^(?=\s*$) diff --git a/LaTeX/syntax_test_latex.tex b/LaTeX/syntax_test_latex.tex index 390a7bbfc0..7e051ca234 100644 --- a/LaTeX/syntax_test_latex.tex +++ b/LaTeX/syntax_test_latex.tex @@ -704,16 +704,16 @@ \subsubsection{name} % <- - meta.environment.math $f(x) = \} {} y$ -% ^^^^^^^^^^^^^ meta.environment.math.inline.dollar.latex +% ^^^^^^^^^^^^^ meta.environment.math.inline.dollar.tex $\alpha \cdot \beta \leq \cos( 5 )$ %^ punctuation.definition.backslash.tex %^^^^^^ keyword.other.math.greek.tex -% ^ punctuation.definition.backslash.tex +% ^ punctuation.definition.backslash.tex % ^^^^^ keyword.other.math.binary-operator.tex % ^^^^ keyword.other.math.relation.tex -% -$s \gets \sum_{\imath = 0}^10 \langle \hat{x}, x \rangle$ +% +$s \gets \sum_{\imath = 0}^10 \langle \hat{x}, x \rangle$ % ^^^^^ keyword.other.math.arrow.tex % ^^^^ keyword.other.math.large-operator.tex % ^^^^^^ keyword.other.math.symbol.tex @@ -721,6 +721,13 @@ \subsubsection{name} % ^^^^ keyword.other.math.accent.tex % ^^^^^^^ keyword.other.math.delimiter.tex +$$ + \begin{foo} +% ^^^^^^ keyword.control.flow.begin.latex + \end{foo} +% ^^^^ keyword.control.flow.end.latex +$$ + \end{document} % ^ support.function.end.latex keyword.control.flow.end.latex % ^ variable.parameter.function.latex From ccc0ab89b34142756b75832f51ce97ae3a870932 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 13 Nov 2022 11:45:54 +0100 Subject: [PATCH 02/46] [Haskell] Fix Lterate Haskell This commit extends LaTeX's `begin-end-commands` context to support Haskell's `\begin{code} ... \end{code}` blocks. Formerly used `plain-tex` does no longer exist. --- Haskell/Literate Haskell.sublime-syntax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Haskell/Literate Haskell.sublime-syntax b/Haskell/Literate Haskell.sublime-syntax index 1c993ebdc8..a947b402ba 100644 --- a/Haskell/Literate Haskell.sublime-syntax +++ b/Haskell/Literate Haskell.sublime-syntax @@ -10,7 +10,7 @@ file_extensions: - lhs contexts: - plain-tex: + begin-end-commands: - meta_prepend: true - include: haskell-code From 9c49c1631052dc702f895a4458760718da5a7736 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 13 Nov 2022 12:18:14 +0100 Subject: [PATCH 03/46] [LaTeX] Remove macro-braces The same context with identical content is already defined in TeX. --- LaTeX/LaTeX.sublime-syntax | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index a76bf2ad83..6df1549da2 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -78,19 +78,6 @@ contexts: - include: general-optional-arguments - include: else-pop - # used in macros to prevent matching of \begin{env}...\end{env} - macro-braces: - - match: \{ - scope: punctuation.definition.group.brace.begin.latex - push: - - meta_scope: meta.group.brace.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true - - include: general-constants - - include: general-commands - - include: macro-braces - macros: - meta_append: true - match: (\\)(?:new|renew|provide)command(?:\*|(?![A-Za-z@])) From 96d16df15dbe57d71663e385bd1bcb854c534462 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 13 Nov 2022 14:00:38 +0100 Subject: [PATCH 04/46] [TeX] Move most basic prototype like contexts to the end Apply an top-down principle to have most basic contexts at the end of a document and the organizational ones at the beginning - just like a tree. Readability may be improved by grouping contexts visually via delimiter comments. See also: Java, PHP, ... --- LaTeX/TeX.sublime-syntax | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 4a7277cbf6..4de13c1de2 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -80,20 +80,6 @@ contexts: - include: general-constants - include: general-commands - # matches any nospace and pops the context - else-pop: - - match: (?=\S) - pop: true - - immediately-pop: - - match: '' - pop: true - - # pops out of the current context if there is a new paragraph - paragraph-pop: - - match: ^(?=\s*$) - pop: true - general-commands: - match: (\\){{letter}}+ scope: support.function.general.tex @@ -399,3 +385,19 @@ contexts: scope: string.other.math.tex punctuation.definition.string.end.tex pop: true - include: math-content + +###[ PROTOTYPES ]############################################################## + + # matches any nospace and pops the context + else-pop: + - match: (?=\S) + pop: true + + immediately-pop: + - match: '' + pop: true + + # pops out of the current context if there is a new paragraph + paragraph-pop: + - match: ^(?=\s*$) + pop: true From d3fcbff8faf74e474ef467959e52e4c01681f336 Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Wed, 16 Nov 2022 12:15:44 +0200 Subject: [PATCH 05/46] added a brace-pop utility context --- LaTeX/LaTeX.sublime-syntax | 84 ++++++++++---------------------------- LaTeX/TeX.sublime-syntax | 26 +++++------- 2 files changed, 32 insertions(+), 78 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index 6df1549da2..e670f72657 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -306,9 +306,7 @@ contexts: 3: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.include.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop sections: - match: |- @@ -337,9 +335,7 @@ contexts: push: - meta_scope: meta.section.latex - meta_content_scope: entity.name.section.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: main structure: @@ -448,9 +444,7 @@ contexts: scope: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.group.brace.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: math-content math-content: @@ -472,9 +466,7 @@ contexts: push: - meta_scope: meta.function.ensuremath.latex - meta_content_scope: meta.environment.math.inline.ensuremath.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: math-content - match: (\\\() @@ -568,9 +560,7 @@ contexts: push: - meta_scope: meta.function.emph.latex - meta_content_scope: markup.italic.emph.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: main - match: ((\\)textit)(\{) captures: @@ -580,9 +570,7 @@ contexts: push: - meta_scope: meta.function.textit.latex - meta_content_scope: markup.italic.textit.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: main - match: ((\\)textbf)(\{) captures: @@ -592,9 +580,7 @@ contexts: push: - meta_scope: meta.function.textbf.latex - meta_content_scope: markup.bold.textbf.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: main - match: ((\\)texttt)(\{) captures: @@ -604,9 +590,7 @@ contexts: push: - meta_scope: meta.function.texttt.latex - meta_content_scope: markup.raw.texttt.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: main - match: ((\\)textsl)(\{) captures: @@ -616,9 +600,7 @@ contexts: push: - meta_scope: meta.function.textsl.latex - meta_content_scope: markup.italic.textsl.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: main - match: ((\\)text)(\{) captures: @@ -626,9 +608,7 @@ contexts: 2: punctuation.definition.backslash.latex 3: punctuation.definition.group.brace.begin.latex push: - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: main - match: ((\\)underline)(\{) captures: @@ -638,9 +618,7 @@ contexts: push: - meta_scope: meta.function.underline.latex - meta_content_scope: markup.underline.underline.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: main footnote: @@ -656,9 +634,7 @@ contexts: set: - meta_scope: meta.function.footnote.latex meta.group.brace.latex - meta_content_scope: markup.italic.footnote.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: main - match: (?=\S) pop: true @@ -710,9 +686,7 @@ contexts: - meta_scope: meta.group.brace.latex - match: '[a-zA-Z0-9\.:/*!^_-]+' scope: constant.other.citation.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - match: '' pop: true - match: |- @@ -734,9 +708,7 @@ contexts: - meta_scope: meta.function.reference.latex meta.group.brace.latex - match: '[a-zA-Z0-9\.:/*!^_-]+' scope: constant.other.reference.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - match: '' pop: true - match: ((\\)label)(\{) @@ -748,9 +720,7 @@ contexts: - meta_scope: meta.function.label.latex - match: '[a-zA-Z0-9\.:/*!^_-]+' scope: entity.name.label.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop begin-end-commands: - match: ((\\)begin)(\{)\s*(\w*)\*?\s*(\}) @@ -1577,9 +1547,7 @@ contexts: push: - meta_include_prototype: false - meta_scope: meta.function.newcolumntype.latex - - match: '\}' - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: array-preamble @@ -1623,9 +1591,7 @@ contexts: - match: \{ scope: punctuation.definition.group.brace.begin.latex push: - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: general-constants - include: general-commands - include: array-preamble @@ -1645,9 +1611,7 @@ contexts: 2: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.function.before-column-decl.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: general-constants - include: general-commands - include: macro-braces @@ -1658,9 +1622,7 @@ contexts: 2: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.function.after-column-decl.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: general-constants - include: general-commands - include: macro-braces @@ -1674,9 +1636,7 @@ contexts: 2: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.function.inter-column-decl.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: general-constants - include: general-commands - include: macro-braces @@ -1687,9 +1647,7 @@ contexts: 2: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.function.inter-column-decl.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true + - include: brace-pop - include: general-constants - include: general-commands - include: macro-braces diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 4de13c1de2..e1ba93d9fd 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -156,9 +156,7 @@ contexts: scope: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.group.brace.tex - - match: \} - scope: punctuation.definition.group.brace.end.tex - pop: true + - include: brace-pop - include: main # within macros, it is possible that only part of some nested struture @@ -169,9 +167,7 @@ contexts: scope: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.group.brace.tex - - match: \} - scope: punctuation.definition.group.brace.end.tex - pop: true + - include: brace-pop - include: general-constants - include: general-commands - include: macro-braces @@ -184,9 +180,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.box.tex - - match: \} - scope: punctuation.definition.group.brace.end.tex - pop: true + - include: brace-pop - include: main macros: @@ -244,9 +238,7 @@ contexts: def-definition-body: - meta_scope: meta.function.body.tex meta.group.brace.tex - - match: \} - scope: punctuation.definition.group.brace.end.tex - pop: 1 + - include: brace-pop - include: general-constants - include: general-commands - include: macro-braces @@ -332,9 +324,7 @@ contexts: scope: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.group.brace.tex - - match: \} - scope: punctuation.definition.group.brace.end.tex - pop: true + - include: brace-pop - include: math-content math-brackets: @@ -393,6 +383,12 @@ contexts: - match: (?=\S) pop: true + # matches a closing brace pops the context + brace-pop: + - match: \} + scope: punctuation.definition.group.brace.end.tex + pop: true + immediately-pop: - match: '' pop: true From d789979a6e1ffb8c30ef4a1d0bd44d62a846a025 Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Fri, 18 Nov 2022 22:53:09 +0200 Subject: [PATCH 06/46] renamed --- LaTeX/LaTeX.sublime-syntax | 42 +++++++++++++++++++------------------- LaTeX/TeX.sublime-syntax | 14 ++++++------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index e670f72657..9a8a943ed8 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -306,7 +306,7 @@ contexts: 3: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.include.latex - - include: brace-pop + - include: brace-group-end sections: - match: |- @@ -335,7 +335,7 @@ contexts: push: - meta_scope: meta.section.latex - meta_content_scope: entity.name.section.latex - - include: brace-pop + - include: brace-group-end - include: main structure: @@ -444,7 +444,7 @@ contexts: scope: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.group.brace.latex - - include: brace-pop + - include: brace-group-end - include: math-content math-content: @@ -466,7 +466,7 @@ contexts: push: - meta_scope: meta.function.ensuremath.latex - meta_content_scope: meta.environment.math.inline.ensuremath.latex - - include: brace-pop + - include: brace-group-end - include: math-content - match: (\\\() @@ -560,7 +560,7 @@ contexts: push: - meta_scope: meta.function.emph.latex - meta_content_scope: markup.italic.emph.latex - - include: brace-pop + - include: brace-group-end - include: main - match: ((\\)textit)(\{) captures: @@ -570,7 +570,7 @@ contexts: push: - meta_scope: meta.function.textit.latex - meta_content_scope: markup.italic.textit.latex - - include: brace-pop + - include: brace-group-end - include: main - match: ((\\)textbf)(\{) captures: @@ -580,7 +580,7 @@ contexts: push: - meta_scope: meta.function.textbf.latex - meta_content_scope: markup.bold.textbf.latex - - include: brace-pop + - include: brace-group-end - include: main - match: ((\\)texttt)(\{) captures: @@ -590,7 +590,7 @@ contexts: push: - meta_scope: meta.function.texttt.latex - meta_content_scope: markup.raw.texttt.latex - - include: brace-pop + - include: brace-group-end - include: main - match: ((\\)textsl)(\{) captures: @@ -600,7 +600,7 @@ contexts: push: - meta_scope: meta.function.textsl.latex - meta_content_scope: markup.italic.textsl.latex - - include: brace-pop + - include: brace-group-end - include: main - match: ((\\)text)(\{) captures: @@ -608,7 +608,7 @@ contexts: 2: punctuation.definition.backslash.latex 3: punctuation.definition.group.brace.begin.latex push: - - include: brace-pop + - include: brace-group-end - include: main - match: ((\\)underline)(\{) captures: @@ -618,7 +618,7 @@ contexts: push: - meta_scope: meta.function.underline.latex - meta_content_scope: markup.underline.underline.latex - - include: brace-pop + - include: brace-group-end - include: main footnote: @@ -634,7 +634,7 @@ contexts: set: - meta_scope: meta.function.footnote.latex meta.group.brace.latex - meta_content_scope: markup.italic.footnote.latex - - include: brace-pop + - include: brace-group-end - include: main - match: (?=\S) pop: true @@ -686,7 +686,7 @@ contexts: - meta_scope: meta.group.brace.latex - match: '[a-zA-Z0-9\.:/*!^_-]+' scope: constant.other.citation.latex - - include: brace-pop + - include: brace-group-end - match: '' pop: true - match: |- @@ -708,7 +708,7 @@ contexts: - meta_scope: meta.function.reference.latex meta.group.brace.latex - match: '[a-zA-Z0-9\.:/*!^_-]+' scope: constant.other.reference.latex - - include: brace-pop + - include: brace-group-end - match: '' pop: true - match: ((\\)label)(\{) @@ -720,7 +720,7 @@ contexts: - meta_scope: meta.function.label.latex - match: '[a-zA-Z0-9\.:/*!^_-]+' scope: entity.name.label.latex - - include: brace-pop + - include: brace-group-end begin-end-commands: - match: ((\\)begin)(\{)\s*(\w*)\*?\s*(\}) @@ -1547,7 +1547,7 @@ contexts: push: - meta_include_prototype: false - meta_scope: meta.function.newcolumntype.latex - - include: brace-pop + - include: brace-group-end - include: array-preamble @@ -1591,7 +1591,7 @@ contexts: - match: \{ scope: punctuation.definition.group.brace.begin.latex push: - - include: brace-pop + - include: brace-group-end - include: general-constants - include: general-commands - include: array-preamble @@ -1611,7 +1611,7 @@ contexts: 2: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.function.before-column-decl.latex - - include: brace-pop + - include: brace-group-end - include: general-constants - include: general-commands - include: macro-braces @@ -1622,7 +1622,7 @@ contexts: 2: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.function.after-column-decl.latex - - include: brace-pop + - include: brace-group-end - include: general-constants - include: general-commands - include: macro-braces @@ -1636,7 +1636,7 @@ contexts: 2: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.function.inter-column-decl.latex - - include: brace-pop + - include: brace-group-end - include: general-constants - include: general-commands - include: macro-braces @@ -1647,7 +1647,7 @@ contexts: 2: punctuation.definition.group.brace.begin.latex push: - meta_scope: meta.function.inter-column-decl.latex - - include: brace-pop + - include: brace-group-end - include: general-constants - include: general-commands - include: macro-braces diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index e1ba93d9fd..255b19cf03 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -156,7 +156,7 @@ contexts: scope: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.group.brace.tex - - include: brace-pop + - include: brace-group-end - include: main # within macros, it is possible that only part of some nested struture @@ -167,7 +167,7 @@ contexts: scope: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.group.brace.tex - - include: brace-pop + - include: brace-group-end - include: general-constants - include: general-commands - include: macro-braces @@ -180,7 +180,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.box.tex - - include: brace-pop + - include: brace-group-end - include: main macros: @@ -238,7 +238,7 @@ contexts: def-definition-body: - meta_scope: meta.function.body.tex meta.group.brace.tex - - include: brace-pop + - include: brace-group-end - include: general-constants - include: general-commands - include: macro-braces @@ -324,7 +324,7 @@ contexts: scope: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.group.brace.tex - - include: brace-pop + - include: brace-group-end - include: math-content math-brackets: @@ -383,8 +383,8 @@ contexts: - match: (?=\S) pop: true - # matches a closing brace pops the context - brace-pop: + # matches a closing brace and pops the context + brace-group-end: - match: \} scope: punctuation.definition.group.brace.end.tex pop: true From 4f2b78fbffc611cab16da8268494b5697b234dcc Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 19 Nov 2022 11:20:29 +0100 Subject: [PATCH 07/46] [LaTeX] Refactor braces contexts Illustrate how `braces` are implemented in both TeX & LaTeX with same content but different sub-scopes. Re-implementing a context without meta_prepend/meta_append overrides it completely. --- LaTeX/LaTeX.sublime-syntax | 17 +++++++++++------ LaTeX/TeX.sublime-syntax | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index 9a8a943ed8..bfc552aae6 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -39,12 +39,17 @@ contexts: braces: - match: \{ scope: punctuation.definition.group.brace.begin.latex - push: - - meta_scope: meta.group.brace.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true - - include: main + push: brace-group-body + + brace-group-body: + - meta_scope: meta.group.brace.latex + - include: brace-group-end + - include: main + + brace-group-end: + - match: \} + scope: punctuation.definition.group.brace.end.latex + pop: true # these are used to identify arguments in commands general-optional-arguments: diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 255b19cf03..a773088707 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -154,10 +154,17 @@ contexts: braces: - match: \{ scope: punctuation.definition.group.brace.begin.tex - push: - - meta_scope: meta.group.brace.tex - - include: brace-group-end - - include: main + push: brace-group-body + + brace-group-body: + - meta_scope: meta.group.brace.tex + - include: brace-group-end + - include: main + + brace-group-end: + - match: \} + scope: punctuation.definition.group.brace.end.tex + pop: true # within macros, it is possible that only part of some nested struture # is present. To prevent this from causing problems, here we only match @@ -383,12 +390,6 @@ contexts: - match: (?=\S) pop: true - # matches a closing brace and pops the context - brace-group-end: - - match: \} - scope: punctuation.definition.group.brace.end.tex - pop: true - immediately-pop: - match: '' pop: true From 2ddd55b85b41aad43df351ec9e289740fcb6fc77 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 19 Nov 2022 11:30:03 +0100 Subject: [PATCH 08/46] [TeX] Add more named groups --- LaTeX/TeX.sublime-syntax | 50 ++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index e165f8b130..e637938e6c 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -224,12 +224,14 @@ contexts: macro-braces: - match: \{ scope: punctuation.definition.group.brace.begin.tex - push: - - meta_scope: meta.group.brace.tex - - include: brace-group-end - - include: general-constants - - include: general-commands - - include: macro-braces + push: macro-brace-group-body + + macro-brace-group-body: + - meta_scope: meta.group.brace.tex + - include: brace-group-end + - include: general-constants + - include: general-commands + - include: macro-braces boxes: - match: ((\\)[hv]box)\s*(\{) @@ -237,10 +239,12 @@ contexts: 1: support.function.box.tex 2: punctuation.definition.backslash.tex 3: punctuation.definition.group.brace.begin.tex - push: - - meta_scope: meta.function.box.tex - - include: brace-group-end - - include: main + push: box-body + + box-body: + - meta_scope: meta.function.box.tex + - include: brace-group-end + - include: main macros: # Note \edef and \xdef have slightly different syntax, in that they do not @@ -252,21 +256,23 @@ contexts: scope: keyword.declaration.function.tex storage.modifier.definition.tex captures: 1: punctuation.definition.backslash.tex - push: def-commandname + push: def-maybe-commandname - def-commandname: + def-maybe-commandname: - meta_scope: meta.function.tex - match: (?=\\) - set: - - clear_scopes: 1 - - meta_scope: meta.function.identifier.tex - - match: (\\){{cmdname}} - scope: entity.name.definition.tex - captures: - 1: punctuation.definition.backslash.tex - set: def-argspec - - include: paragraph-pop - - include: else-pop + set: def-commandname + - include: paragraph-pop + - include: else-pop + + def-commandname: + - clear_scopes: 1 + - meta_scope: meta.function.identifier.tex + - match: (\\){{cmdname}} + scope: entity.name.definition.tex + captures: + 1: punctuation.definition.backslash.tex + set: def-argspec - include: paragraph-pop - include: else-pop From 714cd09c4b7da14fbb1765a9481c4936351c8239 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 19 Nov 2022 11:41:58 +0100 Subject: [PATCH 09/46] [LaTeX] Organize math expressions in named contexts --- LaTeX/LaTeX.sublime-syntax | 115 +++++++++++++++++++++++-------------- LaTeX/TeX.sublime-syntax | 44 ++++++++------ 2 files changed, 99 insertions(+), 60 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index bfc552aae6..1248698cc0 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -447,10 +447,12 @@ contexts: math-braces: - match: \{ scope: punctuation.definition.group.brace.begin.latex - push: - - meta_scope: meta.group.brace.latex - - include: brace-group-end - - include: math-content + push: math-brace-group-body + + math-brace-group-body: + - meta_scope: meta.group.brace.latex + - include: brace-group-end + - include: math-content math-content: - meta_prepend: true @@ -463,63 +465,88 @@ contexts: inline-math: - meta_append: true + - include: inline-math-parens + - include: inline-math-ensuremath + + inline-math-ensuremath: - match: ((\\)ensuremath)(\{) captures: 1: support.function.ensuremath.latex 2: punctuation.definition.backslash.latex 3: punctuation.definition.group.brace.begin.latex - push: - - meta_scope: meta.function.ensuremath.latex - - meta_content_scope: meta.environment.math.inline.ensuremath.latex - - include: brace-group-end - - include: math-content + push: inline-math-ensuremath-body - - match: (\\\() - scope: string.other.math.latex - captures: - 1: punctuation.definition.string.begin.latex - push: - - meta_scope: meta.environment.math.inline.paren.latex - - match: (\\\)) - scope: string.other.math.latex punctuation.definition.string.end.latex - pop: true - - include: math-content + inline-math-ensuremath-body: + - meta_scope: meta.function.ensuremath.latex + - meta_content_scope: meta.environment.math.inline.ensuremath.latex + - include: brace-group-end + - include: math-content + + inline-math-parens: + - match: \\\( + scope: string.other.math.latex punctuation.definition.string.begin.latex + push: inline-math-parens-body + + inline-math-parens-body: + - meta_scope: meta.environment.math.inline.paren.latex + - include: inline-math-parens-end + - include: math-content + + inline-math-parens-end: + - match: \\\) + scope: string.other.math.latex punctuation.definition.string.end.latex + pop: true block-math: - meta_append: true - - match: (\\\[) - scope: string.other.math.latex punctuation.definition.string.begin.latex - push: - - meta_scope: meta.environment.math.block.bracket.latex - - match: (\\\]) - scope: string.other.math.latex punctuation.definition.string.end.latex - pop: true - - include: math-content + - include: block-math-brackets + - include: block-math-begin-end-command + + block-math-begin-end-command: - match: |- (?x) - ((\\)begin)(\{)\s*((?: - align|alignat|aligned|alignedat|displaymath - |eqnarray|equation|flalign|gather|gathered - |math|multline|x?xalignat|split - |dmath|dseries|dgroup|darray|dsuspend - )\*?)\s*(\}) + ((\\)begin) (\{) \s* ( + (?: align | alignat | aligned | alignedat | displaymath | eqnarray + | equation | flalign | gather | gathered | math | multline | x?xalignat + | split | dmath | dseries | dgroup | darray | dsuspend )\*? + ) \s* (\}) captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex 3: punctuation.definition.group.brace.begin.latex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.latex - push: - - meta_content_scope: meta.environment.math.block.be.latex - - match: ((\\)end)(\{)\s*(\4)\s*(\}) - captures: - 1: support.function.end.latex keyword.control.flow.begin.latex - 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex - 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex - pop: true - - include: math-content + push: block-math-begin-end-command-body + + block-math-begin-end-command-body: + - meta_content_scope: meta.environment.math.block.be.latex + - 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 + 2: punctuation.definition.backslash.latex + 3: punctuation.definition.group.brace.begin.latex + 4: variable.parameter.function.latex + 5: punctuation.definition.group.brace.end.latex + pop: true + + block-math-brackets: + - match: \\\[ + scope: string.other.math.latex punctuation.definition.string.begin.latex + push: block-math-brackets-body + + block-math-brackets-body: + - meta_scope: meta.environment.math.block.bracket.latex + - include: block-math-brackets-end + - include: math-content + + block-math-brackets-end: + - match: \\\] + scope: string.other.math.latex punctuation.definition.string.end.latex + pop: true graphics: - match: ((\\)includegraphics)\b diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index e637938e6c..d7a611f677 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -382,10 +382,12 @@ contexts: math-braces: - match: \{ scope: punctuation.definition.group.brace.begin.tex - push: - - meta_scope: meta.group.brace.tex - - include: brace-group-end - - include: math-content + push: math-brace-group-body + + math-brace-group-body: + - meta_scope: meta.group.brace.tex + - include: brace-group-end + - include: math-content math-brackets: - match: '[\(\)]' @@ -419,22 +421,32 @@ contexts: inline-math: - match: \$ scope: string.other.math.tex punctuation.definition.string.begin.tex - push: - - meta_scope: meta.environment.math.inline.dollar.tex - - match: \$ - scope: string.other.math.tex punctuation.definition.string.end.tex - pop: true - - include: math-content + push: inline-math-dollar-body + + inline-math-dollar-body: + - meta_scope: meta.environment.math.inline.dollar.tex + - include: inline-math-dollar-end + - include: math-content + + inline-math-dollar-end: + - match: \$ + scope: string.other.math.tex punctuation.definition.string.end.tex + pop: true block-math: - match: \$\$ scope: string.other.math.tex punctuation.definition.string.begin.tex - push: - - meta_scope: meta.environment.math.block.dollar.tex - - match: \$\$ - scope: string.other.math.tex punctuation.definition.string.end.tex - pop: true - - include: math-content + push: block-math-dollar-body + + block-math-dollar-body: + - meta_scope: meta.environment.math.block.dollar.tex + - include: block-math-dollar-end + - include: math-content + + block-math-dollar-end: + - match: \$\$ + scope: string.other.math.tex punctuation.definition.string.end.tex + pop: true ###[ PROTOTYPES ]############################################################## From 7424049963a6ef640282eba5d9499008751d3111 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 19 Nov 2022 11:51:40 +0100 Subject: [PATCH 10/46] [LaTeX] Re-arrange math contexts Re-arrange contexts to implement the top-down principle. --- LaTeX/LaTeX.sublime-syntax | 30 ++++++-------- LaTeX/TeX.sublime-syntax | 83 +++++++++++++++++++------------------- 2 files changed, 54 insertions(+), 59 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index 1248698cc0..a5f6f0afeb 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -444,24 +444,7 @@ contexts: pop: true - include: main - math-braces: - - match: \{ - scope: punctuation.definition.group.brace.begin.latex - push: math-brace-group-body - - math-brace-group-body: - - meta_scope: meta.group.brace.latex - - include: brace-group-end - - include: math-content - - math-content: - - meta_prepend: true - - match: (?=\}) - pop: true - - include: verb - - include: text-decorators - - include: references - - include: begin-end-commands +###[ MATH ]#################################################################### inline-math: - meta_append: true @@ -548,6 +531,17 @@ contexts: scope: string.other.math.latex punctuation.definition.string.end.latex pop: true + math-content: + - meta_prepend: true + - match: (?=\}) + pop: true + - include: verb + - include: text-decorators + - include: references + - include: begin-end-commands + +###[ OTHER ]################################################################### + graphics: - match: ((\\)includegraphics)\b captures: diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index d7a611f677..96b2a10fa3 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -303,6 +303,48 @@ contexts: - include: general-commands - include: macro-braces +###[ MATH ]#################################################################### + + inline-math: + - match: \$ + scope: string.other.math.tex punctuation.definition.string.begin.tex + push: inline-math-dollar-body + + inline-math-dollar-body: + - meta_scope: meta.environment.math.inline.dollar.tex + - include: inline-math-dollar-end + - include: math-content + + inline-math-dollar-end: + - match: \$ + scope: string.other.math.tex punctuation.definition.string.end.tex + pop: true + + block-math: + - match: \$\$ + scope: string.other.math.tex punctuation.definition.string.begin.tex + push: block-math-dollar-body + + block-math-dollar-body: + - meta_scope: meta.environment.math.block.dollar.tex + - include: block-math-dollar-end + - include: math-content + + block-math-dollar-end: + - match: \$\$ + scope: string.other.math.tex punctuation.definition.string.end.tex + pop: true + + math-content: + - include: math-builtin + - include: math-brackets + - include: math-braces + - include: boxes + - include: math-commands + - include: math-operators + - include: math-characters + - include: math-numerics + - include: general-constants math-builtin: - include: math-greeks @@ -407,47 +449,6 @@ contexts: - match: '[A-Za-z]+' scope: variable.other.math.tex - math-content: - - include: math-builtin - - include: math-brackets - - include: math-braces - - include: boxes - - include: math-commands - - include: math-operators - - include: math-characters - - include: math-numerics - - include: general-constants - - inline-math: - - match: \$ - scope: string.other.math.tex punctuation.definition.string.begin.tex - push: inline-math-dollar-body - - inline-math-dollar-body: - - meta_scope: meta.environment.math.inline.dollar.tex - - include: inline-math-dollar-end - - include: math-content - - inline-math-dollar-end: - - match: \$ - scope: string.other.math.tex punctuation.definition.string.end.tex - pop: true - - block-math: - - match: \$\$ - scope: string.other.math.tex punctuation.definition.string.begin.tex - push: block-math-dollar-body - - block-math-dollar-body: - - meta_scope: meta.environment.math.block.dollar.tex - - include: block-math-dollar-end - - include: math-content - - block-math-dollar-end: - - match: \$\$ - scope: string.other.math.tex punctuation.definition.string.end.tex - pop: true - ###[ PROTOTYPES ]############################################################## # matches any nospace and pops the context From ea7bccdef1c4e5d235b4edb4705fc4d8f70a8ebc Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 19 Nov 2022 11:57:56 +0100 Subject: [PATCH 11/46] [TeX] Reorganize macro braces Group macro related contexts in a MACROS section --- LaTeX/TeX.sublime-syntax | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 96b2a10fa3..e7399f6be2 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -218,21 +218,6 @@ contexts: scope: punctuation.definition.group.brace.end.tex pop: true - # within macros, it is possible that only part of some nested struture - # is present. To prevent this from causing problems, here we only match - # elements that are simple, i.e. that do not push to the stack. - macro-braces: - - match: \{ - scope: punctuation.definition.group.brace.begin.tex - push: macro-brace-group-body - - macro-brace-group-body: - - meta_scope: meta.group.brace.tex - - include: brace-group-end - - include: general-constants - - include: general-commands - - include: macro-braces - boxes: - match: ((\\)[hv]box)\s*(\{) captures: @@ -246,6 +231,8 @@ contexts: - include: brace-group-end - include: main +###[ MACROS ]################################################################## + macros: # Note \edef and \xdef have slightly different syntax, in that they do not # allow for arguments. However, every valid \edef could be a valid \def, @@ -298,6 +285,18 @@ contexts: def-definition-body: - meta_scope: meta.function.body.tex meta.group.brace.tex + - include: macro-brace-group-body + + # within macros, it is possible that only part of some nested struture + # is present. To prevent this from causing problems, here we only match + # elements that are simple, i.e. that do not push to the stack. + macro-braces: + - match: \{ + scope: punctuation.definition.group.brace.begin.tex + push: macro-brace-group-body + + macro-brace-group-body: + - meta_scope: meta.group.brace.tex - include: brace-group-end - include: general-constants - include: general-commands From 2fb06e89a914ec0eede191c2ba65337a63d47f60 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 19 Nov 2022 12:14:02 +0100 Subject: [PATCH 12/46] [Markdown] Adjust syntax tests Some final sub scopes changed from .latex to tex due to inheritance. Hence make Markdown syntax tests a bit more lazy. --- Markdown/tests/syntax_test_markdown.md | 58 +++++++++++++------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Markdown/tests/syntax_test_markdown.md b/Markdown/tests/syntax_test_markdown.md index 11ace0245b..c08bd934c8 100644 --- a/Markdown/tests/syntax_test_markdown.md +++ b/Markdown/tests/syntax_test_markdown.md @@ -8036,24 +8036,24 @@ $$ |^ punctuation.definition.math.begin.latex | ^ - punctuation foo = 1 + 2 * \sqrt{a^2+b^2} -| <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex variable.other.math.tex -|^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -| ^ keyword.operator.math.tex -| ^ constant.numeric.math.tex -| ^ keyword.operator.math.tex -| ^ constant.numeric.math.tex -| ^ keyword.operator.math.tex -| ^^^^^ support.function.math.tex -| ^^^^^^^^^ meta.group.brace.latex -| ^ punctuation.definition.group.brace.begin.latex -| ^ variable.other.math.tex -| ^ keyword.operator.math.tex -| ^ constant.numeric.math.tex -| ^ keyword.operator.math.tex -| ^ variable.other.math.tex -| ^ keyword.operator.math.tex -| ^ constant.numeric.math.tex -| ^ punctuation.definition.group.brace.end.latex +| <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar variable.other.math +|^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +| ^ keyword.operator.math +| ^ constant.numeric.math +| ^ keyword.operator.math +| ^ constant.numeric.math +| ^ keyword.operator.math +| ^^^^^ support.function.math +| ^^^^^^^^^ meta.group.brace +| ^ punctuation.definition.group.brace.begin +| ^ variable.other.math +| ^ keyword.operator.math +| ^ constant.numeric.math +| ^ keyword.operator.math +| ^ variable.other.math +| ^ keyword.operator.math +| ^ constant.numeric.math +| ^ punctuation.definition.group.brace.end $$ | <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex |^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex @@ -8211,11 +8211,11 @@ b$ math. |^^^^^^^^ meta.paragraph.markdown - markup.math Handle incomplete $\sqrt{b$ expressions well. -| ^^^^^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex -| ^ punctuation.definition.math.begin.latex -| ^^^^^ support.function.math.tex -| ^^ meta.group.brace.latex -| ^ punctuation.definition.math.end.latex - meta.group +| ^^^^^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar +| ^ punctuation.definition.math.begin +| ^^^^^ support.function.math +| ^^ meta.group.brace +| ^ punctuation.definition.math.end - meta.group | ^ meta.paragraph.markdown - markup.math 1. ordered list $\sqrt{b}$ equation $1+ @@ -8238,12 +8238,12 @@ Handle incomplete $\sqrt{b$ expressions well. | ^^^^^^ - markup.math - meta.tag + unordered $\sqrt{b}$ equation - | ^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex + | ^^^^^^^^^^ markup.list.numbered.markdown meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar Handle incomplete $\sqrt{b$ expressions well. - | ^^^^^^^^^ meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex - | ^ punctuation.definition.math.begin.latex - | ^^^^^ support.function.math.tex - | ^^ meta.group.brace.latex - | ^ punctuation.definition.math.end.latex - meta.group + | ^^^^^^^^^ meta.paragraph.list.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar + | ^ punctuation.definition.math.begin + | ^^^^^ support.function.math + | ^^ meta.group.brace + | ^ punctuation.definition.math.end - meta.group | ^ meta.paragraph.list.markdown - markup.math From 13d3d352779faa0d140a5d309563c44c8ea93162 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 19 Nov 2022 12:16:14 +0100 Subject: [PATCH 13/46] [LaTeX] Rename remaining `inside-...` context --- LaTeX/TeX.sublime-syntax | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index e7399f6be2..110ff623b5 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -134,7 +134,7 @@ contexts: def-registername: - match: \{ scope: punctuation.definition.group.brace.begin.tex - push: inside-register-name-group + push: register-name-group-body - match: (\\){{cmdname}} scope: entity.name.constant.tex captures: @@ -143,7 +143,7 @@ contexts: - include: paragraph-pop - include: else-pop - inside-register-name-group: + register-name-group-body: - meta_scope: meta.group.brace.latex - match: \} scope: punctuation.definition.group.brace.end.tex From ecef8ebb9d55546e28a2d895dde5aad0eda687ed Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Sat, 19 Nov 2022 17:05:44 +0200 Subject: [PATCH 14/46] [TeX] Improved highlighting in macro definition bodies (#3576) Co-authored-by: deathaxe --- LaTeX/LaTeX.sublime-syntax | 38 +++++-------- LaTeX/TeX.sublime-syntax | 76 +++++++++++++++----------- LaTeX/syntax_test_latex.tex | 103 ++++++++++++++++++++++-------------- LaTeX/syntax_test_tex.tex | 47 ++++++++++++++++ 4 files changed, 168 insertions(+), 96 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index a5f6f0afeb..685497733a 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -122,18 +122,20 @@ contexts: newcommand-optarg: - match: \[ scope: punctuation.definition.group.bracket.begin.latex - push: - - clear_scopes: 1 - - meta_scope: meta.function.parameters.default-value.latex - - match: \] - scope: punctuation.definition.group.bracket.end.latex - pop: 2 - - include: general-constants - - include: general-commands - - include: macro-braces + push: newcommand-optarg-body - include: paragraph-pop - include: else-pop + newcommand-optarg-body: + - clear_scopes: 1 + - meta_scope: meta.function.parameters.default-value.latex + - match: \] + scope: punctuation.definition.group.bracket.end.latex + pop: 2 + - include: general-constants + - include: general-commands + - include: macro-braces + newcommand-commandname: # version one: brace-wrapped command name - match: \{ @@ -168,26 +170,14 @@ contexts: newcommand-definition: - meta_scope: meta.function.latex - match: (?=\{) - set: newcommand-block + set: + - def-function-body-meta + - macro-braces-begin - match: (?=\\) set: newcommand-expression - include: paragraph-pop - include: else-pop - newcommand-block: - # usually, a command definition is a brace-enclosed group of tokens - - match: \{ - scope: punctuation.definition.group.brace.begin.latex - set: newcommand-block-body - - newcommand-block-body: - - meta_scope: meta.function.body.latex meta.group.brace.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: 1 - - include: general-constants - - include: general-commands - - include: macro-braces newcommand-expression: - meta_scope: meta.function.body.latex diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 110ff623b5..abac2ce235 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -234,73 +234,85 @@ contexts: ###[ MACROS ]################################################################## macros: - # Note \edef and \xdef have slightly different syntax, in that they do not - # allow for arguments. However, every valid \edef could be a valid \def, - # so syntax highlighting will work properly with correct code. - # we need to make sure to match only full commands, so we look-ahead for - # any following non-letter - match: (\\)[gex]?def{{endcs}} scope: keyword.declaration.function.tex storage.modifier.definition.tex captures: 1: punctuation.definition.backslash.tex - push: def-maybe-commandname + push: def-function-expect-identifier - def-maybe-commandname: + def-function-expect-identifier: - meta_scope: meta.function.tex - match: (?=\\) - set: def-commandname + set: def-function-identifier - include: paragraph-pop - include: else-pop - def-commandname: - - clear_scopes: 1 + def-function-identifier: - meta_scope: meta.function.identifier.tex - match: (\\){{cmdname}} scope: entity.name.definition.tex captures: 1: punctuation.definition.backslash.tex - set: def-argspec + set: def-function-parameters - include: paragraph-pop - include: else-pop - def-argspec: - - clear_scopes: 1 + def-function-parameters: - meta_content_scope: meta.function.parameters.tex - - include: escaped-character - match: (?=\{) - scope: punctuation.definition.group.bracket.end.tex - set: def-definition + set: + - def-function-body-meta + - macro-braces-begin - match: (\#)[0-9] scope: variable.parameter.tex captures: 1: punctuation.definition.variable.tex + - include: escaped-character - include: paragraph-pop - def-definition: + def-function-body-meta: + - meta_include_prototype: false + - meta_scope: meta.function.body.tex + - include: immediately-pop + + macro-braces: - match: \{ scope: punctuation.definition.group.brace.begin.tex - set: def-definition-body - - include: paragraph-pop - - include: else-pop + push: macro-braces-body - def-definition-body: - - meta_scope: meta.function.body.tex meta.group.brace.tex - - include: macro-brace-group-body - - # within macros, it is possible that only part of some nested struture - # is present. To prevent this from causing problems, here we only match - # elements that are simple, i.e. that do not push to the stack. - macro-braces: + macro-braces-begin: - match: \{ scope: punctuation.definition.group.brace.begin.tex - push: macro-brace-group-body + set: macro-braces-body - macro-brace-group-body: + macro-braces-end: + - match: \} + scope: punctuation.definition.group.brace.end.tex + pop: 1 + + macro-braces-body: - meta_scope: meta.group.brace.tex - - include: brace-group-end + - include: macro-braces-end + - include: macro-braces-content + + # within macros, it is possible that only part of some nested struture + # is present. Don't include any context's here that break if they are + # only partially matched. + macro-braces-content: + - include: macro-braces + - include: macro-placeholders + - include: controls + - include: registers + - include: math-builtin - include: general-constants - include: general-commands - - include: macro-braces + + macro-placeholders: + - match: '(#+)(\d)' + scope: variable.parameter.tex + captures: + 1: punctuation.definition.placeholder.tex + 2: meta.number.integer.decimal.tex constant.numeric.value.tex ###[ MATH ]#################################################################### diff --git a/LaTeX/syntax_test_latex.tex b/LaTeX/syntax_test_latex.tex index 7e051ca234..e4f2e94de7 100644 --- a/LaTeX/syntax_test_latex.tex +++ b/LaTeX/syntax_test_latex.tex @@ -27,98 +27,101 @@ % line comment % <- comment.line.percentage.tex -\newcommand{\foo}{\bar} +\newcommand{\foo}{\baz} %^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function %^^^^^^^^^^ meta.function.latex % ^^^^^^ meta.function.identifier.latex -% ^^^^^^ meta.function.body.latex +% ^^^^^^ meta.function.body %^^^^^^^^^^ keyword.declaration.function.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin % ^^^^ entity.name.newcommand.latex % ^ punctuation.definition.backslash.latex -% ^ punctuation.definition.group.brace.end.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.end +% ^ punctuation.definition.group.brace.begin % ^^^^ support.function.general.latex % ^ punctuation.definition.backslash.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end -\newcommand{\foo}[1]{\bar #1} +\newcommand{\foo}[1]{\baz #1} %^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function %^^^^^^^^^^ meta.function.latex % ^^^^^^ meta.function.identifier.latex % ^^^ meta.function.parameters.latex -% ^^^^^^^^^ meta.function.body.latex +% ^^^^^^^^^ meta.function.body %^^^^^^^^^^ keyword.declaration.function.latex % ^^^^ entity.name.newcommand.latex % ^ constant.numeric.value.latex % ^^^^ support.function.general.latex +% ^ punctuation.definition.placeholder.tex +% ^^ variable.parameter.tex +% ^ meta.number.integer.decimal constant.numeric.value.tex -\newcommand{\foo}[2][default]{\bar #1 #2} +\newcommand{\foo}[2][default]{\baz #1 #2} %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function %^^^^^^^^^^ meta.function.latex % ^^^^^^ meta.function.identifier.latex % ^^^ meta.function.parameters.latex % ^^^^^^^^^ meta.function.parameters.default-value.latex -% ^^^^^^^^^^^^ meta.function.body.latex +% ^^^^^^^^^^^^ meta.function.body %^^^^^^^^^^ keyword.declaration.function.latex % ^^^^ entity.name.newcommand.latex % ^ constant.numeric.value.latex % ^^^^ support.function.general.latex -\renewcommand{\foo}[1]{\bar #1} +\renewcommand{\foo}[1]{\baz #1} %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function %^^^^^^^^^^^^ meta.function.latex % ^^^^^^ meta.function.identifier.latex % ^^^ meta.function.parameters.latex -% ^^^^^^^^^ meta.function.body.latex +% ^^^^^^^^^ meta.function.body %^^^^^^^^^^^^ keyword.declaration.function.latex % ^^^^ entity.name.newcommand.latex % ^^^^ support.function.general.latex - \providecommand{\f@o}[2][default]{\bar #1 #2} + \providecommand{\f@o}[2][default]{\baz #1 #2} % ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function % ^^^^^^^^^^^^^^^ meta.function.latex % ^^^^^^ meta.function.identifier.latex % ^^^ meta.function.parameters.latex % ^^^^^^^^^ meta.function.parameters.default-value.latex -% ^^^^^^^^^^^^ meta.function.body.latex +% ^^^^^^^^^^^^ meta.function.body % ^^^^^^^^^^^^^^^ keyword.declaration.function.latex % ^ punctuation.definition.backslash.latex % ^^^^ entity.name.newcommand.latex % ^ constant.numeric.value.latex % ^^^^ support.function.general.latex -\newcommand\foo{\bar} +\newcommand\foo{\baz} %^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function %^^^^^^^^^^ meta.function.latex % ^^^^ meta.function.identifier.latex -% ^^^^^^ meta.function.body.latex +% ^^^^^^ meta.function.body %^^^^^^^^^^ keyword.declaration.function.latex % ^^^^ entity.name.newcommand.latex % ^^^ support.function.general.latex -\newcommand{ \foo }{\bar} +\newcommand{ \foo }{\baz} %^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function %^^^^^^^^^^ meta.function.latex % ^^^^^^^^ meta.function.identifier.latex -% ^^^^^^ meta.function.body.latex +% ^^^^^^ meta.function.body % ^^^^ entity.name.newcommand.latex % ^^^^ support.function.general.latex -\newcommand* {\foo }{\bar} +\newcommand* {\foo }{\baz} %^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function %^^^^^^^^^^^^ meta.function.latex % ^^^^^^^ meta.function.identifier.latex -% ^^^^^^ meta.function.body.latex +% ^^^^^^ meta.function.body % ^^^^ entity.name.newcommand.latex % ^ support.function.general.latex -\newcommand \foo {\bar} +\newcommand \foo {\baz} %^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function %^^^^^^^^^^^ meta.function.latex % ^^^^ meta.function.identifier.latex % ^ meta.function.latex -% ^^^^^^ meta.function.body.latex +% ^^^^^^ meta.function.body % ^^^^ entity.name.newcommand.latex % ^^^^ support.function.general.latex @@ -128,26 +131,46 @@ % ^^^^ meta.function.identifier.latex % ^^^^^^^^^^^^^^^^^^^^^ meta.function.latex % ^^^^ entity.name.newcommand.latex - {\bar} + {\baz} %^^^^^^ - meta.function meta.function % <- meta.function.latex -%^^^^^^ meta.function.body.latex +%^^^^^^ meta.function.body % ^ - meta.function % ^^^^ support.function.general.latex % note: with an actual empty line in-between, this is a new paragraph \newcommand \foo - {\bar} + {\baz} %^^^^^^ - meta.function \newcommand \baz [1] [def] {\textbf{#1}} -% ^ meta.function.latex -% ^^^^ entity.name.newcommand.latex -% ^ constant.numeric.value.latex -% ^^^ meta.function.parameters.default-value.latex -% ^ support.function.general.latex +%^^^^^^^^^^^ meta.function.latex +%^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^ meta.function.identifier.latex entity.name.newcommand.latex +% ^ punctuation.definition.backslash.latex +% ^ meta.function.latex +% ^^^ meta.function.parameters.latex +% ^ punctuation.definition.group.bracket.begin.latex +% ^ meta.number.integer.decimal.latex constant.numeric.value.latex +% ^ punctuation.definition.group.bracket.end.latex +% ^ meta.function.latex +% ^^^^^ meta.function.parameters.default-value.latex +% ^ punctuation.definition.group.bracket.begin.latex +% ^ punctuation.definition.group.bracket.end.latex +% ^ meta.function.latex +% ^^^^^^^^^^^^^ meta.function.body.tex meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^^^^^^^ support.function.general.latex +% ^ punctuation.definition.backslash.latex +% ^^^^ meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^^ variable.parameter.tex +% ^ punctuation.definition.placeholder.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ punctuation.definition.group.brace.end.tex +% ^ punctuation.definition.group.brace.end.tex % This example checks that we can split over multiple lines, including with comments \newcommand\baz % @@ -161,7 +184,7 @@ % ^^^^^^^^ meta.function.parameters.default-value.latex comment.line.percentage.tex cu{]}t] {\textbf{#1}} % ^^^^^^^ meta.function.parameters.default-value.latex -% ^^^^^^^^^^^^^ meta.function.body.latex +% ^^^^^^^^^^^^^ meta.function.body % The argument count can also be based on another macro. Check that we accept this \def\one{1} @@ -173,13 +196,13 @@ % ^ meta.function.latex % ^^^^^^^^^ meta.function.parameters.default-value.latex % ^ meta.function.latex -% ^^^^^^^^^^^^^^^^ meta.function.body.latex +% ^^^^^^^^^^^^^^^^ meta.function.body % newcommand entirely without braces \newcommand\cmd\src %^^^^^^^^^^^^^^^^^^ - meta.function meta.function % ^^^^ meta.function.identifier.latex entity.name.newcommand.latex -% ^^^^ meta.function.body.latex support.function.general.latex +% ^^^^ meta.function.body support.function.general.latex \DeclareMathOperator{\op } {op} %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function @@ -187,7 +210,7 @@ %^^^^^^^^^^^^^^^^^^^ meta.function.latex % ^^^^^^ meta.function.identifier.latex % ^ meta.function.latex -% ^^^^ meta.function.body.latex +% ^^^^ meta.function.body % ^^^ entity.name.newcommand.latex % ^^ text.tex.latex @@ -380,10 +403,10 @@ \subsubsection{name} % ^ punctuation.definition.group.bracket.begin.latex % ^^^^^ meta.function.footnote.latex meta.group.bracket.latex % ^ punctuation.definition.group.bracket.end.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin % ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.footnote.latex meta.group.brace.latex % ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.italic.footnote.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end \footnotetext{Footnote text without creating a mark} % ^^^^^^^^^^^ meta.function.footnote.latex support.function.footnote.latex @@ -469,9 +492,9 @@ \subsubsection{name} % ^ meta.group.bracket.latex % ^ support.function.general.latex % ^ meta.group.bracket.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin % ^ meta.group.brace.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end % MATH @@ -585,9 +608,9 @@ \subsubsection{name} \lstinline{var x = 15;} % ^^^^^^^^^^^^^^^^^^^^^ meta.environment.verbatim.lstinline.latex % ^^^^^^^^^^^^^ meta.group.brace.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin % ^^^^^^^^^^^ markup.raw.verb.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end % ^ - meta.environment.verbatim.lstinline.latex \lstinline|var x = 15;| diff --git a/LaTeX/syntax_test_tex.tex b/LaTeX/syntax_test_tex.tex index e461f6a431..2a90d45e7f 100644 --- a/LaTeX/syntax_test_tex.tex +++ b/LaTeX/syntax_test_tex.tex @@ -113,6 +113,53 @@ %^^^^^^^ support.function.general.tex +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Macro definition contents +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% testing control keywords, parameter placeholders, and escaping of placeholders +\def\test{\ifmmode #2 \#2} +%^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^ meta.function.tex +% ^^^^^ meta.function.identifier.tex +% ^^^^^^^^^^^^^^^^^ meta.function.body.tex meta.group.brace.tex +%^^^ keyword.declaration.function.tex storage.modifier.definition.tex +% ^^^^^ entity.name.definition.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^^^^^^^^ keyword.control.conditional.if.tex +% ^ punctuation.definition.backslash.tex +% ^^ variable.parameter.tex +% ^ punctuation.definition.placeholder.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.character.escape.tex +% ^ punctuation.definition.backslash.tex +% ^ punctuation.definition.group.brace.end.tex + + +% testing registers and nested braces +\def\test{\dimen5 {#2} \alpha} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^ meta.function.tex +% ^^^^^ meta.function.identifier.tex +% ^^^^^^^^^^^^^^^^^^^^^ meta.function.body.tex meta.group.brace.tex +% ^^^^^^^ meta.register.tex +% ^^^^ meta.group.brace.tex meta.group.brace.tex +%^^^ keyword.declaration.function.tex storage.modifier.definition.tex +% ^^^^^ entity.name.definition.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^^ variable.parameter.tex +% ^^^^^^ keyword.other.math.greek.tex + + +% testing incomplete register specification +\def\test{\dimen} other text +%^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^ meta.function.tex +% ^^^^^ meta.function.identifier.tex +% ^^^^^^^^ meta.function.body.tex meta.group.brace.tex +% ^^^^^^ meta.register.tex +% ^^^^^^^^^^^ - meta.function.body + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Control flow / Conditionals %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 8739aef2f244e8e840ad3eaca857087e79ef0a3c Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Sat, 19 Nov 2022 19:37:05 +0200 Subject: [PATCH 15/46] [TeX] improved handling of (cat)code family of commands (#3577) Co-authored-by: deathaxe <16542113+deathaxe@users.noreply.github.com> Co-authored-by: Michael <2701605+michaelblyons@users.noreply.github.com> --- LaTeX/TeX.sublime-syntax | 66 +++++++++++++++++++++++++++++----- LaTeX/syntax_test_tex.tex | 76 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 9 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index abac2ce235..f5d4ced2ad 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -69,6 +69,12 @@ variables: endcs: '(?!{{letter}})' # a command name: either a sequence of letters, or a single non-letter cmdname: '(?x: {{letter}}+ | {{nonletter}})' + # hexadecimal digits in different casing + lchexdigit: (?:[0-9a-f]) + uchexdigit: (?:[0-9A-F]) + anyhexdigit: (?:[0-9a-fA-F]) + # special notation to refer to (non-printable) characters in TeX + charbycode: (?:\^\^(?:{{lchexdigit}}{{lchexdigit}}|.)) contexts: prototype: @@ -77,7 +83,7 @@ contexts: main: - include: macros - include: controls - - include: catcode + - include: character-codes - include: braces - include: boxes - include: block-math @@ -195,14 +201,6 @@ contexts: captures: 1: punctuation.definition.backslash.tex - catcode: - - match: ((\\)catcode)`(?:\\)?.=(\d+) - scope: meta.function.catcode.tex - captures: - 1: keyword.control.catcode.tex - 2: punctuation.definition.backslash.tex - 3: constant.numeric.category.tex - braces: - match: \{ scope: punctuation.definition.group.brace.begin.tex @@ -231,6 +229,56 @@ contexts: - include: brace-group-end - include: main + +###[ CHARACTER CODES ]########################################################## + + character-codes: + - match: (\\)(?:cat|math|uc|lc|del|sf)code{{endcs}} + scope: keyword.control.character-code.tex + captures: + 1: punctuation.definition.backslash.tex + push: + - character-code-meta + - character-code-value + - character-code-assignment + - character-code-number + + character-code-meta: + - meta_include_prototype: false + - meta_scope: meta.function.character-code.tex + - include: immediately-pop + + character-code-number: + - match: (`)(\\)?({{charbycode}}|.) + scope: meta.number.integer.tex + captures: + 1: keyword.operator.tex + 2: punctuation.definition.backslash.tex + 3: constant.character.tex + pop: 1 + - match: \d+ + scope: meta.number.integer.decimal.tex constant.numeric.value.tex + set: character-code-assignment + - include: else-pop + - include: paragraph-pop + + character-code-assignment: + - match: = + scope: keyword.operator.assignment.tex + pop: 1 + - include: else-pop + - include: paragraph-pop + + character-code-value: + - match: \d+ + scope: meta.number.integer.decimal.tex constant.numeric.value.tex + pop: 1 + - match: '"{{anyhexdigit}}+' + scope: meta.number.integer.hexadecimal.tex constant.numeric.value.tex + pop: 1 + - include: else-pop + - include: paragraph-pop + ###[ MACROS ]################################################################## macros: diff --git a/LaTeX/syntax_test_tex.tex b/LaTeX/syntax_test_tex.tex index 2a90d45e7f..1a7a60f536 100644 --- a/LaTeX/syntax_test_tex.tex +++ b/LaTeX/syntax_test_tex.tex @@ -239,3 +239,79 @@ %^^^^ storage.type.tex % ^^^^^ support.function.general.tex % ^ punctuation.definition.backslash.tex + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Character Codes +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\catcode65=12 +%^^^^^^^^^^^^ meta.function.character-code.tex +%^^^^^^^ keyword.control.character-code.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ keyword.operator.assignment.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex + + +% here are some assignments that happen in `plain.tex` + +\catcode`@=11 +%^^^^^^^^^^^^ meta.function.character-code.tex +%^^^^^^^ keyword.control.character-code.tex +% ^^ meta.number.integer.tex +% ^ keyword.operator.tex +% ^ constant.character.tex +% ^ keyword.operator.assignment.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex + +\catcode`\^^K=7 +%^^^^^^^^^^^^^^ meta.function.character-code.tex +%^^^^^^^ keyword.control.character-code.tex +% ^^^^^ meta.number.integer.tex +% ^ keyword.operator.tex +% ^ punctuation.definition.backslash.tex +% ^^^ constant.character.tex +% ^ keyword.operator.assignment.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex + +\mathcode`\^^D="225E +%^^^^^^^^^^^^^^^^^^^ meta.function.character-code.tex +%^^^^^^^^ keyword.control.character-code.tex +% ^^^^^ meta.number.integer.tex +% ^ keyword.operator.tex +% ^ punctuation.definition.backslash.tex +% ^^^ constant.character.tex +% ^ keyword.operator.assignment.tex +% ^^^^^ meta.number.integer.hexadecimal.tex constant.numeric.value.tex + +\delcode`\\="26E30F +%^^^^^^^^^^^^^^^^^^ meta.function.character-code.tex +%^^^^^^^ keyword.control.character-code.tex +% ^^^ meta.number.integer.tex +% ^ keyword.operator.tex +% ^ punctuation.definition.backslash.tex +% ^ constant.character.tex +% ^ keyword.operator.assignment.tex +% ^^^^^^^ meta.number.integer.hexadecimal.tex constant.numeric.value.tex + +% some other assignments + +% skip the = sign +\catcode`@11 +%^^^^^^^^^^^ meta.function.character-code.tex +%^^^^^^^ keyword.control.character-code.tex +% ^^ meta.number.integer.tex +% ^ keyword.operator.tex +% ^ constant.character.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex + +% hex-specifier +\catcode`\^^ab=11 +%^^^^^^^^^^^^^^^^ meta.function.character-code.tex +%^^^^^^^ keyword.control.character-code.tex +% ^^^^^^ meta.number.integer.tex +% ^ keyword.operator.tex +% ^ punctuation.definition.backslash.tex +% ^^^^ constant.character.tex +% ^ keyword.operator.assignment.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex From 00c38f7f1b237042f62d7e7c6b451cc5f42bca0d Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Sun, 20 Nov 2022 12:27:59 +0200 Subject: [PATCH 16/46] [TeX] Fix scoping error (#3582) --- LaTeX/TeX.sublime-syntax | 2 +- LaTeX/syntax_test_tex.tex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index f5d4ced2ad..e79f0a8912 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -150,7 +150,7 @@ contexts: - include: else-pop register-name-group-body: - - meta_scope: meta.group.brace.latex + - meta_scope: meta.group.brace.tex - match: \} scope: punctuation.definition.group.brace.end.tex pop: 2 diff --git a/LaTeX/syntax_test_tex.tex b/LaTeX/syntax_test_tex.tex index 1a7a60f536..b110c363f6 100644 --- a/LaTeX/syntax_test_tex.tex +++ b/LaTeX/syntax_test_tex.tex @@ -225,7 +225,7 @@ \newcount { \mycounter } %^^^^^^^^ keyword.declaration.register.tex storage.modifier.register.tex -% ^^^^^^^^^^^^^^ meta.group.brace.latex +% ^^^^^^^^^^^^^^ meta.group.brace.tex % ^^^^^^^^^^ entity.name.constant.tex % ^ punctuation.definition.group.brace.begin.tex % ^ punctuation.definition.backslash.tex From 700ed591874f2338a5eab37cbb732f15570ece4b Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Sun, 20 Nov 2022 18:11:36 +0200 Subject: [PATCH 17/46] [TeX] added scoping of "constants" (#3581) This commit adds scoping/highlighting for the built-in constant-like objects in TeX. The decision which control sequences to include here is based more on expected usage, than on how this is defined in the underlying language. I think for a macro-processing system like TeX, this is probably the best approach. Thus I've considered as constants in this sense: - The underlying parameters of the TeX typesetting algorithm. - Registers with pre-defined meaning - simple macros (i.e. without parameters) that insert a fixed element into the typesetting In particular, a parameterless macro that a) assigns to some internal value, or b) changes how subsequent input tokens will be interpreted are not considered constants here. The typesetting parameters and registers can be assigned-to, though for most of these this would typically only happen once in the beginning of the document (usually hidden from the user, as part of the TeX format that is used). However, it is possible to change these values in the middle of the document (though some **really** should not be changed), so in that sense these are not all technically constants. For the assignment, I've opted to not try to distinguish constants that are dimensions from constants that are pure numbers, so both get the same scoping. In extremely weird corner cases, this might lead to erroneous scoping, e.g. if you write ``` \hyphenpenalty=5pt ``` then the current scoping would not know that the penalty is a number, so the `pt` are actually letters to typeset, and not part of the unit. Such cases should be very rare, though. Similarly, since macros can hide part of the syntax, there are situations where we have no chance of knowing which scoping is correct. For example, in ``` \abovedisplayskip\value plus 5pt ``` if `\value` evaluates to some measurement, then the `plus 5pt` would be part of the measurement, otherwise, it is normal text. Co-authored-by: deathaxe --- LaTeX/TeX.sublime-syntax | 118 ++++++++++ LaTeX/syntax_test_tex.tex | 463 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 581 insertions(+) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index e79f0a8912..230a27c713 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -56,6 +56,51 @@ variables: registers: |- (?x: box | count | dimen | muskip | skip | toks) + # here, we define variables for the names of the constants and parameters + # of the TeX algorithm. Some of these are defined in terms of pre-reserved + # registers instead of built-ins, but in terms of syntax highlighting this + # should not make a difference + penalties: |- + (?x: line | hyphen | exhyphen | binop | rel | club | widow + | displaywidow | broken | predisplay | postdisplay | interline + | floating | output | inter(?:display|footnote)line) + + tracings: |- + (?x: online | macros | stats | paragraphs | pages | output | lostchars + | commands | restores) + + skips: |- + (?x: baseline | line | par | (?:above|below)display(?:short)? + | left | right | top | splittop | tab | space | xspace | parfill + | (?:thin|med|thick)mu | normalbaseline | normalline | hide) + + constants: |- + (?x: (?:pre)?tolerance | [hv]badness + | (?:doublehyphen|finalhyphen|adj)demerits + | looseness | pausing | holdinginserts | language | uchyph | lefthyphenmin + | righthyphenmin | globaldefs | maxdeadcycles | hangafter | fam | mag + | (?:escape|defaulthyphen|defaultskew|endline|newline)char + | delimiterfactor | time | day | month | year + | showboxbreadth | showboxdepth | errorcontextlines + | [hv]fuzz | overfullrule | [hv]size | maxdepth | splitmaxdepth + | boxmaxdepth | lineskiplimit | delimitershortfall | nulldelimiterspace + | scriptspace | mathsurround | predisplaysize | displaywidth | displayindent + | parindent | hangindent | [hv]offset | (?:small|med|big)skipamount + | normallineskiplimit | jot | {{skips}}skip | tracing{{tracings}} + | {{penalties}}penalty | maxdimen | centering | p@ | z@ | z@skip | voidb@x + | magstephalf | magstep\d | @ne | tw@ | thr@@ | sixt@@n | @cclv | @cclvi + | @m | @M | @MM | m@ne | count@ | dimen@ | dimen@i | dimen@ii | skip@ + | toks@ | insc@unt | allocationnumber) + + # These constants are implemented as macros, and thus cannot be = assigned + macroconst: |- + (?x: (?:thin|negthin|en)space | enskip | q?quad | (?:small|med|big)skip + | [lr]q | [lr]brack | space | empty | null ) + + dimunits: |- + (?x: pt | pc | bp | in | cm | mm | dd | cc | sp | ex | em + | fil | fill | filll | mu) + # letters in the sense of macro names. Whether @ is a letter or not can vary # from a syntax-highlighting perspective, however, we are much safer to # assume it is a letter. Situations where we have `\macro` followed immediately @@ -90,6 +135,7 @@ contexts: - include: inline-math - include: registers - include: register-allocations + - include: tex-constants - include: general-constants - include: general-commands @@ -108,6 +154,77 @@ contexts: scope: constant.character.space.tex - include: escaped-character + tex-constants: + - match: (\\){{constants}}{{endcs}} + scope: constant.language.tex + captures: + 1: punctuation.definition.backslash.tex + push: + - tex-dimension-value + - tex-constant-assignment + - match: (\\){{macroconst}}{{endcs}} + scope: constant.language.tex + captures: + 1: punctuation.definition.backslash.tex + + tex-constant-assignment: + - match: = + scope: keyword.operator.assignment.tex + pop: 1 + - include: else-pop + - include: paragraph-pop + + tex-dimension-value: + - match: (-?)(?:\d+(\.)\d*|(\.)\d+) + scope: constant.numeric.value.tex + captures: + 1: keyword.operator.arithmetic.tex + 2: punctuation.separator.decimal.tex + 3: punctuation.separator.decimal.tex + set: + - tex-dimension-glue + - decimal-float + - match: (-?)\d+ + scope: constant.numeric.value.tex + captures: + 1: keyword.operator.arithmetic.tex + set: + - tex-dimension-glue + - decimal-integer + - match: (`)(\\)?({{charbycode}}|.) + captures: + 1: keyword.operator.tex + 2: punctuation.definition.backslash.tex + 3: constant.character.tex + set: + - tex-dimension-glue + - decimal-integer + - include: else-pop + - include: paragraph-pop + + tex-dimension-glue: + - match: (?:plus|minus){{endcs}} + scope: keyword.operator.arithmetic.tex + set: tex-dimension-value + - include: else-pop + - include: paragraph-pop + + decimal-float: + - meta_scope: meta.number.float.decimal.tex + - include: tex-dimension-suffix + + decimal-integer: + - meta_scope: meta.number.integer.decimal.tex + - include: tex-dimension-suffix + + tex-dimension-suffix: + - match: '{{dimunits}}' + scope: constant.numeric.suffix.tex + pop: 1 + + - include: else-pop + - include: paragraph-pop + escaped-character: - match: (\\){{nonletter}} scope: constant.character.escape.tex @@ -352,6 +469,7 @@ contexts: - include: controls - include: registers - include: math-builtin + - include: tex-constants - include: general-constants - include: general-commands diff --git a/LaTeX/syntax_test_tex.tex b/LaTeX/syntax_test_tex.tex index b110c363f6..452c4c86a2 100644 --- a/LaTeX/syntax_test_tex.tex +++ b/LaTeX/syntax_test_tex.tex @@ -315,3 +315,466 @@ % ^^^^ constant.character.tex % ^ keyword.operator.assignment.tex % ^^ meta.number.integer.decimal.tex constant.numeric.value.tex + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Constants +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\pretolerance=100 +%^^^^^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^^ meta.number.integer.decimal.tex constant.numeric.value.tex +\tolerance=200 +%^^^^^^^^^ constant.language.tex +\hbadness=1000 +%^^^^^^^^ constant.language.tex +\vbadness=1000 +%^^^^^^^^ constant.language.tex +\linepenalty=10 +%^^^^^^^^^^^ constant.language.tex +\hyphenpenalty=50 +%^^^^^^^^^^^^^ constant.language.tex +\exhyphenpenalty=50 +%^^^^^^^^^^^^^^^ constant.language.tex +\binoppenalty=700 +%^^^^^^^^^^^^ constant.language.tex +\relpenalty=500 +%^^^^^^^^^^ constant.language.tex +\clubpenalty=150 +%^^^^^^^^^^^ constant.language.tex +\widowpenalty=150 +%^^^^^^^^^^^^ constant.language.tex +\displaywidowpenalty=50 +%^^^^^^^^^^^^^^^^^^^ constant.language.tex +\brokenpenalty=100 +%^^^^^^^^^^^^^ constant.language.tex +\predisplaypenalty=10000 +%^^^^^^^^^^^^^^^^^ constant.language.tex +\postdisplaypenalty=0 +%^^^^^^^^^^^^^^^^^^ constant.language.tex +\interlinepenalty=0 +%^^^^^^^^^^^^^^^^ constant.language.tex +\floatingpenalty=0 +%^^^^^^^^^^^^^^^ constant.language.tex +\outputpenalty=0 +%^^^^^^^^^^^^^ constant.language.tex +\doublehyphendemerits=10000 +%^^^^^^^^^^^^^^^^^^^^ constant.language.tex +\finalhyphendemerits=5000 +%^^^^^^^^^^^^^^^^^^^ constant.language.tex +\adjdemerits=10000 +%^^^^^^^^^^^ constant.language.tex +\looseness=0 +%^^^^^^^^^ constant.language.tex +\pausing=0 +%^^^^^^^ constant.language.tex +\holdinginserts=0 +%^^^^^^^^^^^^^^ constant.language.tex +\tracingonline=0 +%^^^^^^^^^^^^^ constant.language.tex +\tracingmacros=0 +%^^^^^^^^^^^^^ constant.language.tex +\tracingstats=0 +%^^^^^^^^^^^^ constant.language.tex +\tracingparagraphs=0 +%^^^^^^^^^^^^^^^^^constant.language.tex +\tracingpages=0 +%^^^^^^^^^^^^ constant.language.tex +\tracingoutput=0 +%^^^^^^^^^^^^^ constant.language.tex +\tracinglostchars=1 +%^^^^^^^^^^^^^^^^ constant.language.tex +\tracingcommands=0 +%^^^^^^^^^^^^^^^ constant.language.tex +\tracingrestores=0 +%^^^^^^^^^^^^^^^ constant.language.tex +\language=0 +%^^^^^^^^ constant.language.tex +\uchyph=1 +%^^^^^^ constant.language.tex +\lefthyphenmin=2 +%^^^^^^^^^^^^^ constant.language.tex +\righthyphenmin=3 +%^^^^^^^^^^^^^^ constant.language.tex +\globaldefs=0 +%^^^^^^^^^^ constant.language.tex +\maxdeadcycles=25 +%^^^^^^^^^^^^^ constant.language.tex +\hangafter=1 +%^^^^^^^^^ constant.language.tex +\fam=0 +%^^^ constant.language.tex +\mag=1000 +%^^^ constant.language.tex + +\escapechar=`\\ +%^^^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^^ meta.number.integer +% ^ keyword.operator.tex +% ^ punctuation.definition.backslash.tex +% ^ constant.character.tex +\defaulthyphenchar=`\- +%^^^^^^^^^^^^^^^^^ constant.language.tex +\defaultskewchar=-1 +%^^^^^^^^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex +\endlinechar=`\^^M +%^^^^^^^^^^^ constant.language.tex +\newlinechar=-1 +%^^^^^^^^^^^ constant.language.tex +\delimiterfactor=901 +%^^^^^^^^^^^^^^^ constant.language.tex +\time +%^^^^ constant.language.tex +\day +%^^^ constant.language.tex +\month +%^^^^^ constant.language.tex +\year +%^^^^ constant.language.tex +\showboxbreadth=5 +%^^^^^^^^^^^^^^ constant.language.tex +\showboxdepth=3 +%^^^^^^^^^^^^ constant.language.tex +\errorcontextlines=5 +%^^^^^^^^^^^^^^^^^ constant.language.tex + +\hfuzz=0.1pt +%^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^^^^ meta.number.float.decimal.tex +% ^^^ constant.numeric.value.tex +% ^ punctuation.separator.decimal.tex +% ^^ constant.numeric.suffix.tex +\vfuzz=0.1 pt +%^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^^^^^ meta.number.float.decimal.tex +% ^^^ constant.numeric.value.tex +% ^ punctuation.separator.decimal.tex +% ^^ constant.numeric.suffix.tex + +% check that we can put comment-based line breaks here +\overfullrule=% +%^^^^^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex + 5pt +% ^^^ meta.number.integer.decimal.tex +% ^ constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex + +\hsize=6.5in +%^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^^^^ meta.number.float.decimal.tex +% ^^^ constant.numeric.value.tex +% ^ punctuation.separator.decimal.tex +% ^^ constant.numeric.suffix.tex +\vsize=8.9in +%^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^^^^ meta.number.float.decimal.tex +% ^^^ constant.numeric.value.tex +% ^ punctuation.separator.decimal.tex +% ^^ constant.numeric.suffix.tex +\maxdepth=.4pt +%^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^^^ meta.number.float.decimal.tex +% ^^ constant.numeric.value.tex +% ^ punctuation.separator.decimal.tex +% ^^ constant.numeric.suffix.tex + + +\splitmaxdepth=\maxdimen +%^^^^^^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^^^^^^^^ constant.language.tex +% ^ punctuation.definition.backslash.tex +\boxmaxdepth=\maxdimen +%^^^^^^^^^^^ constant.language.tex +\lineskiplimit=0pt +%^^^^^^^^^^^^^ constant.language.tex +\delimitershortfall=5pt +%^^^^^^^^^^^^^^^^^^ constant.language.tex +\nulldelimiterspace=1.2pt +%^^^^^^^^^^^^^^^^^^ constant.language.tex +\scriptspace=0.5pt +%^^^^^^^^^^^ constant.language.tex +\mathsurround=0pt +%^^^^^^^^^^^^ constant.language.tex +\predisplaysize=0pt +%^^^^^^^^^^^^^^ constant.language.tex +\displaywidth=0pt +%^^^^^^^^^^^^ constant.language.tex +\displayindent=0pt +%^^^^^^^^^^^^^ constant.language.tex +\parindent=20pt +%^^^^^^^^^ constant.language.tex +\hangindent=0pt +%^^^^^^^^^^ constant.language.tex +\hoffset=0pt +%^^^^^^^ constant.language.tex +\voffset=0pt +%^^^^^^^ constant.language.tex + +\baselineskip=0pt +%^^^^^^^^^^^^ constant.language.tex +\lineskip=0pt +%^^^^^^^^ constant.language.tex +\parskip=0pt plus 1pt +%^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex +% ^^^^ keyword.operator.arithmetic.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex + +\abovedisplayskip=12pt plus 3pt minus 9pt +%^^^^^^^^^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex +% ^^^^ keyword.operator.arithmetic.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex +% ^^^^^ keyword.operator.arithmetic.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex +\abovedisplayshortskip=0pt plus 3pt +%^^^^^^^^^^^^^^^^^^^^^ constant.language.tex +\belowdisplayskip=12pt plus 3pt minus 9pt +%^^^^^^^^^^^^^^^^ constant.language.tex +\belowdisplayshortskip=7pt plus 3pt minus 4pt +%^^^^^^^^^^^^^^^^^^^^^ constant.language.tex +\leftskip=0pt +%^^^^^^^^ constant.language.tex +\rightskip=0pt +%^^^^^^^^^ constant.language.tex +\topskip=10pt +%^^^^^^^ constant.language.tex +\splittopskip=10pt +%^^^^^^^^^^^^ constant.language.tex +\tabskip=0pt +%^^^^^^^ constant.language.tex +\spaceskip=0pt +%^^^^^^^^^ constant.language.tex +\xspaceskip=0pt +%^^^^^^^^^^ constant.language.tex +\parfillskip=0pt plus 1fil +%^^^^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex +% ^^^^ keyword.operator.arithmetic.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^^ constant.numeric.suffix.tex + + +\thinmuskip=3mu +%^^^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex + +\medmuskip=4mu plus 2mu minus 4mu +%^^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex +% ^^^^ keyword.operator.arithmetic.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex +% ^^^^^ keyword.operator.arithmetic.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex +\thickmuskip=5mu plus 5mu +%^^^^^^^^^^^ constant.language.tex + +\smallskipamount=3pt plus 1pt minus 1pt +%^^^^^^^^^^^^^^^ constant.language.tex +\medskipamount=6pt plus 2pt minus 2pt +%^^^^^^^^^^^^^ constant.language.tex +\bigskipamount=12pt plus 4pt minus 4pt +%^^^^^^^^^^^^^ constant.language.tex +\normalbaselineskip=12pt +%^^^^^^^^^^^^^^^^^^ constant.language.tex +\normallineskip=1pt +%^^^^^^^^^^^^^^ constant.language.tex +\normallineskiplimit=0pt +%^^^^^^^^^^^^^^^^^^^ constant.language.tex +\jot=3pt +%^^^ constant.language.tex +\interdisplaylinepenalty=100 +%^^^^^^^^^^^^^^^^^^^^^^^ constant.language.tex +\interfootnotelinepenalty=100 +%^^^^^^^^^^^^^^^^^^^^^^^^ constant.language.tex + +\maxdimen +%^^^^^^^^ constant.language.tex +\centering +%^^^^^^^^^ constant.language.tex +\p@ +%^^ constant.language.tex +\z@ +%^^ constant.language.tex +\z@skip +%^^^^^^ constant.language.tex +\voidb@x +%^^^^^^^ constant.language.tex +\magstephalf +%^^^^^^^^^^^ constant.language.tex +\magstep4 +%^^^^^^^^ constant.language.tex +\@ne +%^^^ constant.language.tex +\tw@ +%^^^ constant.language.tex +\thr@@ +%^^^^^ constant.language.tex +\sixt@@n +%^^^^^^^ constant.language.tex +\@cclv +%^^^^^ constant.language.tex +\@cclvi +%^^^^^^ constant.language.tex +\@m +%^^ constant.language.tex +\@M +%^^ constant.language.tex +\@MM +%^^^ constant.language.tex +\m@ne +%^^^^ constant.language.tex + +\count@=255 +%^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^^ meta.number.integer.decimal.tex constant.numeric.value.tex +\dimen@=0 +%^^^^^^ constant.language.tex +\dimen@i=1 +%^^^^^^^ constant.language.tex +\dimen@ii=2 +%^^^^^^^^ constant.language.tex +\skip@=0 +%^^^^^ constant.language.tex +\toks@=0 +%^^^^^ constant.language.tex + +% Assignments without equals sign +\baselineskip-1000\p@ +%^^^^^^^^^^^^ constant.language.tex +% ^^^^^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ keyword.operator.arithmetic.tex +% ^^^ constant.language.tex +% ^ punctuation.definition.backslash.tex + +% Using weird ways to specify a number +\abovedisplayskip=`\^^Z ex +%^^^^^^^^^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^^^^^^ meta.number.integer.decimal.tex +% ^ keyword.operator.tex +% ^ punctuation.definition.backslash.tex +% ^^^ constant.character.tex +% ^^ constant.numeric.suffix.tex + +\abovedisplayskip=`\a ex +%^^^^^^^^^^^^^^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^^^^^^ meta.number.integer.decimal.tex +% ^ keyword.operator.tex +% ^ punctuation.definition.backslash.tex +% ^ constant.character.tex +% ^^ constant.numeric.suffix.tex + + +% The macro-type constants. They cannot be assigned using = +\thinspace=5pt +%^^^^^^^^^ constant.language.tex +% ^ - keyword.operator.assignment.tex + +\negthinspace +%^^^^^^^^^^^^ constant.language.tex +\enspace +%^^^^^^^ constant.language.tex +\enskip +%^^^^^^ constant.language.tex +\quad +%^^^^ constant.language.tex +\qquad +%^^^^^ constant.language.tex +\smallskip +%^^^^^^^^^ constant.language.tex +\medskip +%^^^^^^^ constant.language.tex +\bigskip +%^^^^^^^ constant.language.tex +\space +%^^^^^ constant.language.tex +\empty +%^^^^^ constant.language.tex +\null +%^^^^ constant.language.tex +\lq +%^^ constant.language.tex +\rq +%^^ constant.language.tex +\lbrack +%^^^^^^ constant.language.tex +\rbrack +%^^^^^^ constant.language.tex + +% check that we don't pick it up if it is just the beginning of a word +\jota +%^^^^ - constant.language.tex + +% Check that a number is required +\jot=pt +% ^^ - constant.numeric.suffix.tex +\jot=5pt pt +% ^^ - constant.numeric.suffix.tex + +\jot=5pt plus plus +% ^^^^ - keyword + +\jot=5pt plusword +% ^^^^ - keyword + +\jot=plus +% ^^^^ - keyword + +% \relax is a no-op that can be used to ensure that the following characters +% will not be parsed as part of the quantity +\jot=5pt \relax plus 10pt +% ^^^^ - keyword.operator +%^^^ constant.language.tex +% ^ keyword.operator.assignment.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex +% ^^^^^^ support.function.general.tex +% ^ punctuation.definition.backslash.tex + +% Finally, test that we can safely use constants inside macro definitions + +% No assignment, the = is outside of the macro +\def\macro{\abovedisplayskip}=5pt +% ^ - keyword.operator.assignment.tex +%^^^ meta.function.tex keyword.declaration.function.tex storage.modifier.definition.tex +% ^^^^^^ meta.function.identifier.tex entity.name.definition.tex +% ^ punctuation.definition.backslash.tex +% ^^^^^^^^^^^^^^^^^^^ meta.function.body.tex meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^^^^^^^^^^^^^^^^^ constant.language.tex +% ^ punctuation.definition.backslash.tex +% ^ punctuation.definition.group.brace.end.tex + +% No value, the 5 is outside of the macro +\def\macro{\abovedisplayskip=}5 +% ^ - meta.number + From d460764def076c4555d5c959ac8e197209acacdc Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Sun, 20 Nov 2022 18:12:39 +0200 Subject: [PATCH 18/46] [Tex] add \relax command (#3586) This commit adds the \relax command to control sequence. As its usage is similar to python's `pass`, if used the same scoping, i.e. as a special `keyword.control.flow` --- LaTeX/TeX.sublime-syntax | 4 ++++ LaTeX/syntax_test_tex.tex | 2 ++ 2 files changed, 6 insertions(+) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 230a27c713..38813ed57a 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -317,6 +317,10 @@ contexts: scope: meta.function.input.tex keyword.control.input.tex captures: 1: punctuation.definition.backslash.tex + - match: (\\)relax{{endcs}} + scope: keyword.control.flow.relax.tex + captures: + 1: punctuation.definition.backslash.tex braces: - match: \{ diff --git a/LaTeX/syntax_test_tex.tex b/LaTeX/syntax_test_tex.tex index 452c4c86a2..8a993c4de4 100644 --- a/LaTeX/syntax_test_tex.tex +++ b/LaTeX/syntax_test_tex.tex @@ -196,6 +196,8 @@ \fi %^^ keyword.control.conditional.end.tex +\relax +%^^^^^ keyword.control.flow.relax.tex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Registers From 87ade170dbffc8fffb0904ad962da655010201ba Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 20 Nov 2022 17:15:46 +0100 Subject: [PATCH 19/46] [Tex] Fix \relax test case --- LaTeX/syntax_test_tex.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LaTeX/syntax_test_tex.tex b/LaTeX/syntax_test_tex.tex index 8a993c4de4..a4d9475b86 100644 --- a/LaTeX/syntax_test_tex.tex +++ b/LaTeX/syntax_test_tex.tex @@ -742,7 +742,7 @@ \jot=5pt pt % ^^ - constant.numeric.suffix.tex -\jot=5pt plus plus +\jot=5pt plus plus % ^^^^ - keyword \jot=5pt plusword @@ -759,7 +759,7 @@ % ^ keyword.operator.assignment.tex % ^ meta.number.integer.decimal.tex constant.numeric.value.tex % ^^ constant.numeric.suffix.tex -% ^^^^^^ support.function.general.tex +% ^^^^^^ keyword.control.flow.relax.tex % ^ punctuation.definition.backslash.tex % Finally, test that we can safely use constants inside macro definitions From 106c95e932a4126ecff4ea6f64e08fa0b58340a9 Mon Sep 17 00:00:00 2001 From: Johannes Rappen Date: Thu, 24 Nov 2022 18:20:27 +0100 Subject: [PATCH 20/46] [TeX] refactor LaTeX Log syntax (#3557) --- LaTeX/LaTeX Log.sublime-syntax | 118 ++++++++++++++++++++++++--------- 1 file changed, 87 insertions(+), 31 deletions(-) diff --git a/LaTeX/LaTeX Log.sublime-syntax b/LaTeX/LaTeX Log.sublime-syntax index 486c7f7690..d862c7f31b 100644 --- a/LaTeX/LaTeX Log.sublime-syntax +++ b/LaTeX/LaTeX Log.sublime-syntax @@ -5,45 +5,101 @@ scope: text.log.latex first_line_match: "This is (pdf|pdfe)?TeXk?, Version " +################################################################################ + contexts: main: - - match: ".*Warning:" - scope: invalid.deprecated - - match: '[^:]*:\d*:.*' - scope: invalid.deprecated - - match: .*Error|^!.* - scope: invalid.illegal + - include: log-entries + - include: file-paths + - include: under-over-full + - include: strings + + under-over-full: + - match: (?:Overfull|Underfull) + scope: keyword.control.hyphenation.latex + push: + - meta_scope: meta.log.latex.hyphenation + + - match: \[\]\n + scope: keyword.control.hyphenation.latex + pop: 1 + + - match: '[0-9]+\-\-[0-9]+' + scope: variable.parameter.hyphenation.latex2 + +###[ File paths ]############################################################### + + file-paths: + - include: function-file-paths + - include: tag-file-paths + - include: type-file-paths + + function-file-paths: - match: .*\.sty scope: entity.name.function - - match: .*\.cls - scope: entity.name.type.class + + tag-file-paths: - match: .*\.cfg scope: entity.name.tag.configuration - match: .*\.def scope: entity.name.tag.definition - - match: .*Info.* + + type-file-paths: + - match: .*\.cls + scope: entity.name.type.class + +###[ Log entries ]############################################################## + + log-entries: + - include: error-log-entries + - include: warning-log-entries + - include: info-log-entries + - include: fixme-log-entries + + error-log-entries: + - match: '.*Error|^!.*' + scope: invalid.illegal + + warning-log-entries: + - match: '.*Warning:' + scope: invalid.deprecated + - match: '[^:]*:\d*:.*' + scope: invalid.deprecated + + info-log-entries: + - match: '.*Info.*' scope: comment.block.documentation - - match: ".*FiXme:" + + fixme-log-entries: + - match: '.*FiXme:' scope: meta.log.latex.fixme - - match: (Overfull|Underfull) - captures: - 1: keyword.control.hyphenation.latex - push: - - meta_scope: meta.log.latex.hyphenation - - match: '(\[\]\n)' - captures: - 1: keyword.control.hyphenation.latex - pop: true - - match: '[0-9]+\-\-[0-9]+' - scope: variable.parameter.hyphenation.latex2 - - match: (<) + +###[ Strings ]################################################################## + + strings: + - include: angle-bracket-strings + + angle-bracket-strings: + - match: '<' scope: punctuation.definition.string.begin.log.latex - push: - - meta_scope: string.unquoted.other.filename.log.latex - - match: (>) - scope: punctuation.definition.string.end.log.latex - pop: true - - match: (.*/.*\.pdf) - scope: support.function.with-arg.latex - captures: - 1: entity.name.function.filename.latex + push: angle-bracket-string-content + + angle-bracket-string-content: + - meta_scope: string.unquoted.other.filename.log.latex + + - match: '>' + scope: punctuation.definition.string.end.log.latex + pop: 1 + + - match: '.*/.*\.pdf' + scope: >- + support.function.with-arg.latex + entity.name.function.filename.latex + + - include: eol-pop + +###[ Helpers ]################################################################## + + eol-pop: + - match: '$\n?' + pop: 1 From 45dc6d9ea62d52856776e9ed66c6f42b35be8add Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 24 Nov 2022 18:24:42 +0100 Subject: [PATCH 21/46] [TeX] Small formal tweaks for LaTeX Log syntax --- LaTeX/LaTeX Log.sublime-syntax | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/LaTeX/LaTeX Log.sublime-syntax b/LaTeX/LaTeX Log.sublime-syntax index d862c7f31b..2d2890e2fa 100644 --- a/LaTeX/LaTeX Log.sublime-syntax +++ b/LaTeX/LaTeX Log.sublime-syntax @@ -3,7 +3,7 @@ name: LaTeX Log scope: text.log.latex -first_line_match: "This is (pdf|pdfe)?TeXk?, Version " +first_line_match: 'This is (pdf|pdfe)?TeXk?, Version ' ################################################################################ @@ -17,15 +17,15 @@ contexts: under-over-full: - match: (?:Overfull|Underfull) scope: keyword.control.hyphenation.latex - push: - - meta_scope: meta.log.latex.hyphenation + push: under-over-full-body - - match: \[\]\n - scope: keyword.control.hyphenation.latex - pop: 1 - - - match: '[0-9]+\-\-[0-9]+' - scope: variable.parameter.hyphenation.latex2 + under-over-full-body: + - meta_scope: meta.log.latex.hyphenation + - match: \[\]\n + scope: keyword.control.hyphenation.latex + pop: 1 + - match: '[0-9]+\-\-[0-9]+' + scope: variable.parameter.hyphenation.latex ###[ File paths ]############################################################### @@ -86,20 +86,17 @@ contexts: angle-bracket-string-content: - meta_scope: string.unquoted.other.filename.log.latex - - match: '>' scope: punctuation.definition.string.end.log.latex pop: 1 - - - match: '.*/.*\.pdf' - scope: >- + - match: .*/.*\.pdf + scope: support.function.with-arg.latex entity.name.function.filename.latex - - include: eol-pop ###[ Helpers ]################################################################## eol-pop: - - match: '$\n?' + - match: $\n? pop: 1 From e4b0425c0980c4b15dd183df89510a74fda2fe74 Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Sat, 26 Nov 2022 18:22:15 +0200 Subject: [PATCH 22/46] [LaTeX] xparse command definition support (#3585) This commit adds support for xparse package. see: https://mirror.informatik.hs-fulda.de/tex-archive/macros/latex/contrib/l3packages/xparse.pdf Co-authored-by: deathaxe --- LaTeX/LaTeX.sublime-syntax | 183 ++++++++++-- LaTeX/TeX.sublime-syntax | 10 + LaTeX/syntax_test_latex.xparse.tex | 428 +++++++++++++++++++++++++++++ 3 files changed, 605 insertions(+), 16 deletions(-) create mode 100644 LaTeX/syntax_test_latex.xparse.tex diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index 685497733a..b8a6145c4e 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -41,6 +41,12 @@ contexts: scope: punctuation.definition.group.brace.begin.latex push: brace-group-body + brace-group-begin: + - meta_include_prototype: false + - match: \{ + scope: punctuation.definition.group.brace.begin.latex + pop: true + brace-group-body: - meta_scope: meta.group.brace.latex - include: brace-group-end @@ -83,26 +89,34 @@ contexts: - include: general-optional-arguments - include: else-pop +###[ MACROS ]################################################################## + macros: - meta_append: true + - include: latex-newcommand-macros + - include: xparse-newcommand-macros + +###[ LATEX NEWCOMMAND MACROS ]################################################# + + latex-newcommand-macros: - match: (\\)(?:new|renew|provide)command(?:\*|(?![A-Za-z@])) scope: keyword.declaration.function.latex storage.modifier.newcommand.latex captures: 1: punctuation.definition.backslash.latex push: - - newcommand-definition - - newcommand-optarg - - newcommand-argspec - - newcommand-commandname + - latex-newcommand-definition + - latex-newcommand-optarg + - latex-newcommand-argspec + - latex-newcommand-commandname - match: (\\)DeclareMathOperator(?:\*|(?![A-Za-z@])) scope: support.function.declare-math-operator.latex storage.modifier.newcommand.latex captures: 1: punctuation.definition.backslash.latex push: - - newcommand-definition - - newcommand-commandname + - latex-newcommand-definition + - latex-newcommand-commandname - newcommand-argspec: + latex-newcommand-argspec: - match: \[ scope: punctuation.definition.group.bracket.begin.latex push: @@ -119,14 +133,14 @@ contexts: - include: paragraph-pop - include: else-pop - newcommand-optarg: + latex-newcommand-optarg: - match: \[ scope: punctuation.definition.group.bracket.begin.latex - push: newcommand-optarg-body + push: latex-newcommand-optarg-body - include: paragraph-pop - include: else-pop - newcommand-optarg-body: + latex-newcommand-optarg-body: - clear_scopes: 1 - meta_scope: meta.function.parameters.default-value.latex - match: \] @@ -136,7 +150,7 @@ contexts: - include: general-commands - include: macro-braces - newcommand-commandname: + latex-newcommand-commandname: # version one: brace-wrapped command name - match: \{ scope: punctuation.definition.group.brace.begin.latex @@ -167,19 +181,18 @@ contexts: # we need a separate context for command definitions, because they can contain # un-balanced elements. - newcommand-definition: + latex-newcommand-definition: - meta_scope: meta.function.latex - match: (?=\{) set: - def-function-body-meta - macro-braces-begin - match: (?=\\) - set: newcommand-expression + set: latex-newcommand-expression - include: paragraph-pop - include: else-pop - - newcommand-expression: + latex-newcommand-expression: - meta_scope: meta.function.body.latex # but in principle, a single token is also valid, # thus either a command sequence ... @@ -198,6 +211,145 @@ contexts: - include: paragraph-pop - include: else-pop +###[ XPARSE NEWCOMMAND MACROS ]################################################ + + xparse-newcommand-macros: + # https://www.ctan.org/pkg/xparse + - match: (\\)(?:(?:New|Renew|Provide|Declare)(:?Expandable)?DocumentCommand){{endcs}} + scope: keyword.declaration.function.latex storage.modifier.newcommand.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - latex-newcommand-definition + - xparse-newcommand-argspec + - latex-newcommand-commandname + + xparse-newcommand-argspec: + - match: (?=\{) + set: + - xparse-newcommand-argspec-body + - brace-group-begin + - include: paragraph-pop + - include: else-pop + + xparse-newcommand-argspec-body: + - clear_scopes: 1 + - meta_scope: meta.function.parameters.latex + - include: brace-group-end + - include: macro-braces + - include: xparse-newcommand-single-argspec + # not actually allowed, but included here to future-proof highlighting + - include: general-constants + - include: general-commands + - include: paragraph-pop + + xparse-newcommand-single-argspec: + # modifiers and simple specs + - match: '[+!]' + scope: storage.modifier.latex + - match: '[movsb]' + scope: storage.type.latex + - match: t + scope: storage.type.latex + push: xparse-newcommand-args-token + # delimited arguments without default + - match: '[rd]' + scope: storage.type.latex + push: + - xparse-newcommand-args-token + - xparse-newcommand-args-token + # delimited arguments with default + - match: '[RD]' + scope: storage.type.latex + push: + - xparse-newcommand-optarg-value + - xparse-newcommand-args-token + - xparse-newcommand-args-token + # optional argument with default + - match: O + scope: storage.type.latex + push: xparse-newcommand-optarg-value + # embellishment argument + - match: e + scope: storage.type.latex + push: xparse-newcommand-args-token + # embellishment argument with default + - match: E + scope: storage.type.latex + push: + - xparse-newcommand-optarg-value + - xparse-newcommand-args-token + # argument processors + - match: '>' + scope: storage.modifier.latex + + xparse-newcommand-args-token: + - meta_include_prototype: false + - include: unmatched-brace-pop + - match: (?={) + set: + - xparse-newcommand-args-wrapped-token + - brace-group-begin + - match: (?=\S) + set: xparse-newcommand-args-bare-token + - include: paragraph-pop + + xparse-newcommand-args-bare-token: + # either a command + - match: (\\){{cmdname}}{{endcs}} + scope: constant.other.token.latex + captures: + 1: punctuation.definition.backslash.latex + pop: 1 + # or a single character + - match: \S + scope: constant.character.latex constant.other.token.latex + pop: 1 + - include: paragraph-pop + + xparse-newcommand-args-wrapped-token: + - meta_scope: meta.group.brace.latex + - include: brace-group-end + # either a command + - match: (\\){{cmdname}}{{endcs}} + scope: constant.other.token.latex + captures: + 1: punctuation.definition.backslash.latex + # or a single character + - match: \S + scope: constant.character.latex constant.other.token.latex + + xparse-newcommand-optarg-value: + - meta_include_prototype: false + - include: unmatched-brace-pop + - match: (?={) + set: + - xparse-newcommand-optarg-wrapped-value + - brace-group-begin + - match: (?=\S) + set: xparse-newcommand-optarg-bare-value + - include: paragraph-pop + + xparse-newcommand-optarg-bare-value: + - clear_scopes: 1 + - meta_scope: meta.function.parameters.default-value.latex + - match: (\\){{cmdname}}{{endcs}} + scope: support.function.latex + captures: + 1: punctuation.definition.backslash.latex + pop: 1 + - match: \S + pop: 1 + - include: paragraph-pop + + xparse-newcommand-optarg-wrapped-value: + - clear_scopes: 1 + - meta_scope: meta.function.parameters.default-value.latex meta.group.brace.latex + - include: brace-group-end + - include: macro-braces-content + +###[ CONSTANTS ]############################################################### + general-constants: - meta_prepend: true - match: (\\\\)(?:(\[)\s*-?((?:[[:digit:]]|\.)*)\s*(\w*)\s*(\]))? @@ -566,7 +718,6 @@ contexts: scope: punctuation.definition.verb.latex pop: true - text-decorators: - match: ((\\)emph)(\{) captures: diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 38813ed57a..c1fdad0114 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -327,6 +327,12 @@ contexts: scope: punctuation.definition.group.brace.begin.tex push: brace-group-body + brace-group-begin: + - meta_include_prototype: false + - match: \{ + scope: punctuation.definition.group.brace.begin.tex + pop: true + brace-group-body: - meta_scope: meta.group.brace.tex - include: brace-group-end @@ -645,3 +651,7 @@ contexts: paragraph-pop: - match: ^(?=\s*$) pop: true + + unmatched-brace-pop: + - match: (?=}) + pop: true diff --git a/LaTeX/syntax_test_latex.xparse.tex b/LaTeX/syntax_test_latex.xparse.tex new file mode 100644 index 0000000000..28e982fea0 --- /dev/null +++ b/LaTeX/syntax_test_latex.xparse.tex @@ -0,0 +1,428 @@ +% SYNTAX TEST "Packages/LaTeX/LaTeX.sublime-syntax" + +% <- text.tex.latex + +\NewDocumentCommand{\noparams}{}{content} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^ meta.function.identifier.latex +% ^^ meta.function.parameters.latex +% ^^^^^^^^^ meta.function.body.tex meta.group.brace.tex +% ^ - meta.function +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^^^^^^^^^ entity.name.newcommand.latex +% ^ punctuation.definition.backslash.latex +% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex + +\NewDocumentCommand{\mandatory}{m}{content #1} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^^ meta.function.identifier.latex +% ^^^ meta.function.parameters.latex +% ^^^^^^^^^^^^ meta.function.body meta.group.brace +% ^ - meta.function +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^^^^^^^^^^ entity.name.newcommand.latex +% ^ punctuation.definition.backslash.latex +% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^ storage.type.latex +% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^^ variable.parameter.tex +% ^ punctuation.definition.group.brace.end.tex + +\NewDocumentCommand\nobrace{o}{content} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^ meta.function.identifier.latex +% ^^^ meta.function.parameters.latex +% ^^^^^^^^^ meta.function.body +% ^ - meta.function +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex + +\NewDocumentCommand{\many@args}{o +m s !v}{content} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^^^^^ meta.function.parameters.latex +% ^^^^^^^^^ meta.function.body +% ^ - meta.function +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex +% ^ storage.modifier.latex +% ^ storage.type.latex +% ^ storage.type.latex +% ^ storage.modifier.latex +% ^ storage.type.latex + +\NewDocumentCommand{\delimone}{d{a}{b}}{arg #1} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^^^^ meta.function.parameters.latex - meta.function.latex +% ^^^^^^^^ meta.function.body - meta.function.parameters.latex +% ^ - meta.function +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex +% ^ constant.character.latex constant.other.token.latex +% ^ constant.character.latex constant.other.token.latex + +\ProvideDocumentCommand{\delimtwo}{d\start \end} {arg #1} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^^^^^^^^^ meta.function.parameters.latex - meta.function.latex +% ^ meta.function.latex +% ^^^^^^^^ meta.function.body - meta.function.parameters.latex +% ^ - meta.function +%^^^^^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex +% ^^^^^^ constant.other.token.latex +% ^^^ constant.other.token.latex + +\DeclareDocumentCommand{\delimthree}% +%^^^^^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^^^^^^ entity.name.newcommand.latex +{d()}{arg #1} +%^^^^ meta.function.parameters.latex - meta.function.latex +%^ storage.type.latex +% ^^ constant.character.latex constant.other.token.latex +% ^^^^^^^^ meta.function.body - meta.function.parameters.latex + + +% TODO should the backslashes be part of constant.other.token.latex here? +\RenewDocumentCommand{\delimfour}% + {r\{\}}{body} +%^^^^^^^ meta.function.parameters.latex - meta.function.latex +% ^ storage.type.latex +% ^^^^ constant.other.token.latex +% ^ punctuation.definition.backslash.latex +% ^ punctuation.definition.backslash.latex + + +% This is wrong, because the default value is missing. +% We are making sure that the scoping is somewhat reasonable nonetheless. +\NewDocumentCommand{\delimfive}{D{a}{b}}{arg #1} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^^^^ meta.function.parameters.latex - meta.function.latex +% ^^^^^^^^ meta.function.body -meta.function.latex +% ^ - meta.function +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex +% ^ constant.character.latex constant.other.token.latex +% ^ constant.character.latex constant.other.token.latex + +\NewDocumentCommand{\delimsix}{R(){a complicated{default} \test{value}}}{arg #1} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^ meta.function.parameters.latex - meta.function.latex +% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.default-value.latex - meta.function.parameters.latex +% ^ meta.function.parameters.latex +% ^^^^^^^^ meta.function.body meta.group.brace +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex +% ^^ constant.character.latex constant.other.token.latex +% ^ punctuation.definition.group.brace.end.latex + + +\NewDocumentCommand{\optional}{O{default}}{function body} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^ meta.function.identifier.latex +% ^^ meta.function.parameters.latex +% ^^^^^^^^^ meta.function.parameters.default-value.latex meta.group.brace.latex +% ^ meta.function.parameters.latex punctuation.definition.group.brace.end.latex +% ^^^^^^^^^^^^^^^ meta.function.body +% ^ - meta.function +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex + +% Check that default values can include paragraph breaks +\NewDocumentCommand{\optionaltwo}{O{default +% ^^ meta.function.parameters.latex +% ^^^^^^^^ meta.function.parameters.default-value.latex + +with paragraph}}{function body} +% ^ meta.function.parameters.latex +%^^^^^^^^^^^^^^ meta.function.parameters.default-value.latex +% ^^^^^^^^^^^^^^^ meta.function.body + +\NewDocumentCommand{\optional}{Ov}{function body} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^ meta.function.identifier.latex +% ^^ meta.function.parameters.latex +% ^ meta.function.parameters.default-value.latex +% ^ meta.function.parameters.latex +% ^^^^^^^^^^^^^^^ meta.function.body +% ^ - meta.function +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex + +\NewDocumentCommand{\optional}{O\{}{function body} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^ meta.function.identifier.latex +% ^ meta.function.parameters.latex +% ^^ meta.function.parameters.default-value.latex +% ^ meta.function.parameters.latex +% ^^^^^^^^^^^^^^^ meta.function.body +% ^ - meta.function +%^^^^^^^^^^^^^^^^^^ storage.modifier.newcommand.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^^^^^^^^^ entity.name.newcommand.latex +% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^ storage.type.latex +% ^ - punctuation.definition.group +% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex + +\NewDocumentCommand{\optional}{O\value m}{function body} +% ^^ meta.function.parameters.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^ storage.type.latex +% ^^^^^^ meta.function.parameters.default-value.latex support.function.latex +% ^ punctuation.definition.backslash.latex +% ^^^ meta.function.parameters.latex +% ^ storage.type.latex +% ^ punctuation.definition.group.brace.end.latex + +\NewDocumentCommand{\optional}{O{#1: \year \parskip1em }}{function body} +% ^ storage.type.latex +% ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.default-value.latex meta.group.brace.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^^ variable.parameter.tex +% ^ punctuation.definition.placeholder.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^^^^ constant.language.tex +% ^^^^^^^^ constant.language.tex +% ^ punctuation.definition.backslash.tex +% ^ punctuation.definition.backslash.tex +% ^^^ meta.number.integer.decimal.tex +% ^ constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex + + +% A "token" argument +\NewExpandableDocumentCommand{\withtoken}{t\test}{function body} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^^^ meta.function.parameters.latex +% ^^^^^^^^^^^^^^^ meta.function.body +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^ storage.modifier.newcommand.latex +% ^^^^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex +% ^^^^^ constant.other.token.latex + + +% embellishments +\NewDocumentCommand{\embellish}{e\test}{body} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^^^ meta.function.parameters.latex +% ^^^^^^ meta.function.body +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex +% ^^^^^ constant.other.token.latex + +\NewDocumentCommand{\embellish}{e{\test}}{body} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^^^^^ meta.function.parameters.latex +% ^^^^^^ meta.function.body +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex +% ^^^^^ constant.other.token.latex + + +\NewDocumentCommand{\embellish}{e{_^}}{body} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^^ meta.function.parameters.latex +% ^^^^^^ meta.function.body +%^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^^^^^^^^^ entity.name.newcommand.latex +% ^ storage.type.latex +% ^^ constant.character.latex constant.other.token.latex + +\NewDocumentCommand{\embellish}{E{_^}{default}}{body} +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^ meta.function.parameters.latex +% ^^^^^^^^^ meta.function.parameters.default-value.latex +% ^ meta.function.parameters.latex +% ^^^^^^ meta.function.body +% ^ - meta.function +% ^^^^^^^^^^ entity.name.newcommand.latex +% ^^ constant.character.latex constant.other.token.latex + +\NewDocumentCommand{\MyMacro}{e{\up \down}}{up: #1 down: #2} +% ^ storage.type.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^^^ constant.other.token.latex +% ^^^^^ constant.other.token.latex +% ^ punctuation.definition.backslash.latex +% ^ punctuation.definition.backslash.latex +% ^^ punctuation.definition.group.brace.end.latex +% ^^^^^^^^^^^^^^^^^ meta.function.body.tex meta.group.brace.tex + + +% Argument processors: example from +% https://www.nic.funet.fi/pub/TeX/CTAN/macros/latex/contrib/l3packages/xparse.pdf +\NewDocumentCommand \foo { O{,} >{\SplitList{#1}} m } { \foobar{#2} } +% ^^^ meta.function.parameters.latex +% ^^^ meta.function.parameters.default-value.latex meta.group.brace.latex +% ^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.latex +% ^ meta.function.latex +% ^^^^^^^^^^^^^^^ meta.function.body.tex meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.latex +% ^ storage.type.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.end.latex +% ^ storage.modifier.latex +% ^^^^^^^^^^^^^^^^ meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^^^^^^^^^^ support.function.general.latex +% ^ punctuation.definition.backslash.latex +% ^^^^ meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^^ variable.parameter.tex +% ^ punctuation.definition.placeholder.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ punctuation.definition.group.brace.end.tex +% ^ punctuation.definition.group.brace.end.tex +% ^ storage.type.latex +% ^ punctuation.definition.group.brace.end.latex + + + +% Now for some broken and incomplete examples +\NewDocumentCommand{\incomplete} + +other stuff +% ^^^^^^^^^^ - meta.fuction + +\NewDocumentCommand{\incompletearg}{m + +other stuff +% ^^^^^^^^^^ - meta.fuction + +\NewDocumentCommand{\incompleteoptional}{O + +other stuff +%<- - meta.fuction + +\NewDocumentCommand{\optional}{O}{sdfsdf} +% ^^^^^^^^ - meta.function.parameters + +% missing token +\NewDocumentCommand {\conjugate} { t } {(#1,#2,#3)} +% ^^^^^ meta.function.parameters +% ^^^^^^^^^^^^^ - meta.function.parameters + + +% This is not a valid command, but we still want to make sure we get reasonable +% highlighting, e.g. scoping of all braces, grouping etc. +\NewDocumentCommand{\broken}{m{default}}{body} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^^^^^^^ meta.function.parameters.latex +% ^^^^^^^^^ meta.group.brace.tex +% ^^^^^^ meta.function.body.tex meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.latex +% ^^^^^^^ entity.name.newcommand.latex +% ^ punctuation.definition.backslash.latex +% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^ storage.type.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex +% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex + +% \other is not allowed here, but we try to get decent highlighting. We should +% not mark this as an error, in case the xparse syntax gets extended at some +% point +\NewDocumentCommand{\embellish}{e\test\other @}{content (#1)} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.function meta.function +%^^^^^^^^^^^^^^^^^^ meta.function.latex +% ^^^^^^^^^^^^ meta.function.identifier.latex +% ^^^^^^^^^^^^^^^^ meta.function.parameters.latex +% ^^^^^^^^^^^^^^ meta.function.body.tex meta.group.brace.tex +% ^ - meta.function +% ^ punctuation.definition.group.brace.begin.latex +% ^^^^^^^^^^ entity.name.newcommand.latex +% ^ punctuation.definition.backslash.latex +% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^ storage.type.latex +% ^^^^^ constant.other.token.latex +% ^ punctuation.definition.backslash.latex +% ^^^^^^ support.function.general.latex +% ^ punctuation.definition.backslash.latex +% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^^ variable.parameter.tex +% ^ punctuation.definition.placeholder.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ punctuation.definition.group.brace.end.tex + + +% Currently unsupported syntax versions: +% These are very rare, so at this point we have opted for reduced complexity +% of the syntax highlighting, with the cost that some syntactially valid patterns +% get suboptimal highlighting. + +\NewDocumentCommand{\braces}{{m}}{content} +% ^^^^^ meta.function.parameters.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^^^ meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex +% ^ punctuation.definition.group.brace.end.latex +% ^^^^^^^^^ meta.function.body.tex meta.group.brace.tex + +\NewDocumentCommand{\braces}{m {O}{value} m}{content} +% ^^^^^^^^^^^^^^^^ meta.function.parameters.latex +% ^ punctuation.definition.group.brace.begin.latex +% ^ storage.type.latex +% ^^^^^^^^^^ meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex +% ^ storage.type.latex +% ^ punctuation.definition.group.brace.end.latex +% ^^^^^^^^^ meta.function.body.tex meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex From 07a4d0491bb38a93bde7a34c14f14da18d09c9fe Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 26 Nov 2022 17:32:53 +0100 Subject: [PATCH 23/46] [LaTeX] Adjust latex-newcommand context structure 1. converts anonymous into named contexts 2. make use of `{{letter}}` variable 3. bring contexts inline with xparese-newcommand --- LaTeX/LaTeX.sublime-syntax | 77 ++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index b8a6145c4e..e131868e03 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -119,20 +119,22 @@ contexts: latex-newcommand-argspec: - match: \[ scope: punctuation.definition.group.bracket.begin.latex - push: - - clear_scopes: 1 - - meta_scope: meta.function.parameters.latex - - match: \] - scope: punctuation.definition.group.bracket.end.latex - pop: 2 - - match: \d+\b - scope: meta.number.integer.decimal.latex constant.numeric.value.latex - - include: general-constants - - include: general-commands - - include: macro-braces + push: latex-newcommand-argspec-body - include: paragraph-pop - include: else-pop + latex-newcommand-argspec-body: + - clear_scopes: 1 + - meta_scope: meta.function.parameters.latex + - match: \] + scope: punctuation.definition.group.bracket.end.latex + pop: 2 + - match: \d+\b + scope: meta.number.integer.decimal.latex constant.numeric.value.latex + - include: general-constants + - include: general-commands + - include: macro-braces + latex-newcommand-optarg: - match: \[ scope: punctuation.definition.group.bracket.begin.latex @@ -152,33 +154,36 @@ contexts: latex-newcommand-commandname: # version one: brace-wrapped command name - - match: \{ - scope: punctuation.definition.group.brace.begin.latex - push: - - clear_scopes: 1 - - meta_scope: meta.function.identifier.latex - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: 2 - - match: (\\)[A-Za-z@]+ - scope: entity.name.newcommand.latex - captures: - 1: punctuation.definition.backslash.latex + - match: (?=\{) + set: + - latex-newcommand-wrapped-commandname + - brace-group-begin # version two: directly written - match: (?=\\) - set: - - clear_scopes: 1 - - meta_scope: meta.function.identifier.latex - - match: (\\)[A-Za-z@]+ - scope: entity.name.newcommand.latex - captures: - 1: punctuation.definition.backslash.latex - pop: 1 - - include: paragraph-pop - - include: else-pop + set: latex-newcommand-bare-commandname - include: paragraph-pop - include: else-pop + latex-newcommand-bare-commandname: + - clear_scopes: 1 + - meta_scope: meta.function.identifier.latex + - match: (\\){{letter}}+ + scope: entity.name.newcommand.latex + captures: + 1: punctuation.definition.backslash.latex + pop: 1 + - include: paragraph-pop + - include: else-pop + + latex-newcommand-wrapped-commandname: + - clear_scopes: 1 + - meta_scope: meta.function.identifier.latex + - include: brace-group-end + - match: (\\){{letter}}+ + scope: entity.name.newcommand.latex + captures: + 1: punctuation.definition.backslash.latex + # we need a separate context for command definitions, because they can contain # un-balanced elements. latex-newcommand-definition: @@ -196,7 +201,7 @@ contexts: - meta_scope: meta.function.body.latex # but in principle, a single token is also valid, # thus either a command sequence ... - - match: (\\)[A-Za-z@]+ + - match: (\\){{letter}}+ scope: support.function.general.latex captures: 1: punctuation.definition.backslash.latex @@ -286,7 +291,7 @@ contexts: xparse-newcommand-args-token: - meta_include_prototype: false - include: unmatched-brace-pop - - match: (?={) + - match: (?=\{) set: - xparse-newcommand-args-wrapped-token - brace-group-begin @@ -322,7 +327,7 @@ contexts: xparse-newcommand-optarg-value: - meta_include_prototype: false - include: unmatched-brace-pop - - match: (?={) + - match: (?=\{) set: - xparse-newcommand-optarg-wrapped-value - brace-group-begin From f45966337630f9a150be857cc8a8c2dbcabceebd Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Sat, 26 Nov 2022 18:52:21 +0200 Subject: [PATCH 24/46] [LaTeX] Fixups for command names (#3594) --- LaTeX/LaTeX.sublime-syntax | 10 +++++----- LaTeX/syntax_test_latex.tex | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index e131868e03..25031cd6bc 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -167,7 +167,7 @@ contexts: latex-newcommand-bare-commandname: - clear_scopes: 1 - meta_scope: meta.function.identifier.latex - - match: (\\){{letter}}+ + - match: (\\){{cmdname}} scope: entity.name.newcommand.latex captures: 1: punctuation.definition.backslash.latex @@ -179,7 +179,7 @@ contexts: - clear_scopes: 1 - meta_scope: meta.function.identifier.latex - include: brace-group-end - - match: (\\){{letter}}+ + - match: (\\){{cmdname}} scope: entity.name.newcommand.latex captures: 1: punctuation.definition.backslash.latex @@ -201,14 +201,14 @@ contexts: - meta_scope: meta.function.body.latex # but in principle, a single token is also valid, # thus either a command sequence ... - - match: (\\){{letter}}+ + - match: (\\){{cmdname}} scope: support.function.general.latex captures: 1: punctuation.definition.backslash.latex pop: 1 - # or a single, potentially escaped character. no further effort at + # or a single character. no further effort at # differentiation here - - match: (\\)?\S\b + - match: \S\b scope: constant.character.escape.latex captures: 1: punctuation.definition.backslash.latex diff --git a/LaTeX/syntax_test_latex.tex b/LaTeX/syntax_test_latex.tex index e4f2e94de7..af543496aa 100644 --- a/LaTeX/syntax_test_latex.tex +++ b/LaTeX/syntax_test_latex.tex @@ -225,6 +225,14 @@ \alpha % ^^^^^^ support.function.general.latex +\newcommand\"{quote} +%^^^^^^^^^^ meta.function.latex keyword.declaration.function.latex storage.modifier.newcommand.latex +% ^^ meta.function.identifier.latex entity.name.newcommand.latex +% ^^^^^^^ meta.function.body.tex meta.group.brace.tex +% ^ punctuation.definition.backslash.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex + \newcommandprefix %^^^^^^^^^^^^^^^^ support.function.general.latex From d7a211d512c7be3d907735383198e94712206c42 Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Sat, 26 Nov 2022 19:25:10 +0200 Subject: [PATCH 25/46] [TeX] Modifiers for \def's (#3593) --- LaTeX/TeX.sublime-syntax | 5 +++++ LaTeX/syntax_test_tex.tex | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index c1fdad0114..863bee0d51 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -415,6 +415,11 @@ contexts: 1: punctuation.definition.backslash.tex push: def-function-expect-identifier + - match: (\\)(?:outer|long|global){{endcs}} + scope: storage.modifier.definition.tex + captures: + 1: punctuation.definition.backslash.tex + def-function-expect-identifier: - meta_scope: meta.function.tex - match: (?=\\) diff --git a/LaTeX/syntax_test_tex.tex b/LaTeX/syntax_test_tex.tex index a4d9475b86..e7c6268165 100644 --- a/LaTeX/syntax_test_tex.tex +++ b/LaTeX/syntax_test_tex.tex @@ -113,6 +113,26 @@ %^^^^^^^ support.function.general.tex +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Modifiers +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + \long\def\test#1{#1} +%^^^^^ storage.modifier.definition.tex +%^ punctuation.definition.backslash.tex +% ^^^^ meta.function.tex keyword.declaration.function.tex storage.modifier.definition.tex + + \outer\def\test#1{#1} +%^^^^^^ storage.modifier.definition.tex +%^ punctuation.definition.backslash.tex +% ^^^^ meta.function.tex keyword.declaration.function.tex storage.modifier.definition.tex + + \global\def\test#1{#1} +%^^^^^^^ storage.modifier.definition.tex +%^ punctuation.definition.backslash.tex +% ^^^^ meta.function.tex keyword.declaration.function.tex storage.modifier.definition.tex + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Macro definition contents %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 7e2f1371d9280f4086c73edd0946e9b8f86e5bdb Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Sun, 27 Nov 2022 12:10:31 +0200 Subject: [PATCH 26/46] [TeX] improve register assignments (#3587) This commit ... 1. uses `tex-dimension-value` to implement register assignments 2. reorganizes some contexts logically and groups them into sections Co-authored-by: deathaxe --- LaTeX/TeX.sublime-syntax | 281 ++++++++++++++++++++------------------ LaTeX/syntax_test_tex.tex | 27 +++- 2 files changed, 174 insertions(+), 134 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 863bee0d51..99fd52cdc3 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -134,7 +134,6 @@ contexts: - include: block-math - include: inline-math - include: registers - - include: register-allocations - include: tex-constants - include: general-constants - include: general-commands @@ -145,137 +144,6 @@ contexts: captures: 1: punctuation.definition.backslash.tex - general-constants: - - match: \\\\ - scope: constant.character.newline.tex - - match: '&' - scope: constant.character.ampersand.tex - - match: '~' - scope: constant.character.space.tex - - include: escaped-character - - tex-constants: - - match: (\\){{constants}}{{endcs}} - scope: constant.language.tex - captures: - 1: punctuation.definition.backslash.tex - push: - - tex-dimension-value - - tex-constant-assignment - - match: (\\){{macroconst}}{{endcs}} - scope: constant.language.tex - captures: - 1: punctuation.definition.backslash.tex - - tex-constant-assignment: - - match: = - scope: keyword.operator.assignment.tex - pop: 1 - - include: else-pop - - include: paragraph-pop - - tex-dimension-value: - - match: (-?)(?:\d+(\.)\d*|(\.)\d+) - scope: constant.numeric.value.tex - captures: - 1: keyword.operator.arithmetic.tex - 2: punctuation.separator.decimal.tex - 3: punctuation.separator.decimal.tex - set: - - tex-dimension-glue - - decimal-float - - match: (-?)\d+ - scope: constant.numeric.value.tex - captures: - 1: keyword.operator.arithmetic.tex - set: - - tex-dimension-glue - - decimal-integer - - match: (`)(\\)?({{charbycode}}|.) - captures: - 1: keyword.operator.tex - 2: punctuation.definition.backslash.tex - 3: constant.character.tex - set: - - tex-dimension-glue - - decimal-integer - - include: else-pop - - include: paragraph-pop - - tex-dimension-glue: - - match: (?:plus|minus){{endcs}} - scope: keyword.operator.arithmetic.tex - set: tex-dimension-value - - include: else-pop - - include: paragraph-pop - - decimal-float: - - meta_scope: meta.number.float.decimal.tex - - include: tex-dimension-suffix - - decimal-integer: - - meta_scope: meta.number.integer.decimal.tex - - include: tex-dimension-suffix - - tex-dimension-suffix: - - match: '{{dimunits}}' - scope: constant.numeric.suffix.tex - pop: 1 - - - include: else-pop - - include: paragraph-pop - - escaped-character: - - match: (\\){{nonletter}} - scope: constant.character.escape.tex - captures: - 1: punctuation.definition.backslash.tex - - registers: - - match: (\\)({{registers}}){{endcs}} - captures: - 1: punctuation.definition.backslash.tex - 2: storage.type.tex - push: register-id - - register-id: - - meta_scope: meta.register.tex - - match: \d+ - scope: meta.number.integer.decimal constant.numeric.value.tex - pop: 1 - - include: general-commands - - include: paragraph-pop - - include: else-pop - - register-allocations: - - match: (\\)new{{registers}}{{endcs}} - scope: keyword.declaration.register.tex storage.modifier.register.tex - captures: - 1: punctuation.definition.backslash.tex - push: def-registername - - def-registername: - - match: \{ - scope: punctuation.definition.group.brace.begin.tex - push: register-name-group-body - - match: (\\){{cmdname}} - scope: entity.name.constant.tex - captures: - 1: punctuation.definition.backslash.tex - pop: 1 - - include: paragraph-pop - - include: else-pop - - register-name-group-body: - - meta_scope: meta.group.brace.tex - - match: \} - scope: punctuation.definition.group.brace.end.tex - pop: 2 - - match: (\\){{cmdname}} - scope: entity.name.constant.tex - captures: - 1: punctuation.definition.backslash.tex - comments: - match: '%.*$\n?' scope: comment.line.percentage.tex @@ -356,7 +224,6 @@ contexts: - include: brace-group-end - include: main - ###[ CHARACTER CODES ]########################################################## character-codes: @@ -406,6 +273,154 @@ contexts: - include: else-pop - include: paragraph-pop +###[ CONSTANTS ]################################################################ + + general-constants: + - match: \\\\ + scope: constant.character.newline.tex + - match: '&' + scope: constant.character.ampersand.tex + - match: '~' + scope: constant.character.space.tex + - include: escaped-character + + escaped-character: + - match: (\\){{nonletter}} + scope: constant.character.escape.tex + captures: + 1: punctuation.definition.backslash.tex + + tex-constants: + - match: (\\){{constants}}{{endcs}} + scope: constant.language.tex + captures: + 1: punctuation.definition.backslash.tex + push: + - tex-dimension-value + - tex-assignment + - match: (\\){{macroconst}}{{endcs}} + scope: constant.language.tex + captures: + 1: punctuation.definition.backslash.tex + +###[ REGISTERS ]################################################################ + + registers: + - include: register-allocations + - include: register-definitions + + register-allocations: + - match: (\\)new{{registers}}{{endcs}} + scope: keyword.declaration.register.tex storage.modifier.register.tex + captures: + 1: punctuation.definition.backslash.tex + push: register-allocation-identifier + + register-allocation-identifier: + - meta_scope: meta.register.tex + - match: (?=\{) + set: + - register-allocation-wrapped-identifier + - brace-group-begin + - match: (\\){{cmdname}} + scope: entity.name.constant.tex + captures: + 1: punctuation.definition.backslash.tex + pop: 1 + - include: paragraph-pop + - include: else-pop + + register-allocation-wrapped-identifier: + - meta_scope: meta.register.tex meta.group.brace.tex + - include: brace-group-end + - match: (\\){{cmdname}} + scope: entity.name.constant.tex + captures: + 1: punctuation.definition.backslash.tex + + register-definitions: + - match: (\\)({{registers}}){{endcs}} + captures: + 1: punctuation.definition.backslash.tex + 2: storage.type.tex + push: register-definition-identifier + + register-definition-identifier: + - meta_scope: meta.register.tex + - match: \d+ + scope: meta.number.integer.decimal constant.numeric.value.tex + set: + - tex-dimension-value + - tex-assignment + - match: (\\){{letter}}+ + scope: support.function.general.tex + captures: + 1: punctuation.definition.backslash.tex + set: + - tex-dimension-value + - tex-assignment + - include: paragraph-pop + - include: else-pop + +###[ DIMENSIONS ]############################################################### + + tex-assignment: + - match: = + scope: keyword.operator.assignment.tex + pop: 1 + - include: else-pop + - include: paragraph-pop + + tex-dimension-value: + - match: (-?)(?:\d+(\.)\d*|(\.)\d+) + scope: constant.numeric.value.tex + captures: + 1: keyword.operator.arithmetic.tex + 2: punctuation.separator.decimal.tex + 3: punctuation.separator.decimal.tex + set: + - tex-dimension-glue + - tex-dimension-decimal-float + - match: (-?)\d+ + scope: constant.numeric.value.tex + captures: + 1: keyword.operator.arithmetic.tex + set: + - tex-dimension-glue + - tex-dimension-decimal-integer + - match: (`)(\\)?({{charbycode}}|.) + captures: + 1: keyword.operator.tex + 2: punctuation.definition.backslash.tex + 3: constant.character.tex + set: + - tex-dimension-glue + - tex-dimension-decimal-integer + - include: else-pop + - include: paragraph-pop + + tex-dimension-glue: + - match: (?:plus|minus){{endcs}} + scope: keyword.operator.arithmetic.tex + set: tex-dimension-value + - include: else-pop + - include: paragraph-pop + + tex-dimension-decimal-float: + - meta_scope: meta.number.float.decimal.tex + - include: tex-dimension-suffix + + tex-dimension-decimal-integer: + - meta_scope: meta.number.integer.decimal.tex + - include: tex-dimension-suffix + + tex-dimension-suffix: + - match: '{{dimunits}}' + scope: constant.numeric.suffix.tex + pop: 1 + - include: else-pop + - include: paragraph-pop + ###[ MACROS ]################################################################## macros: diff --git a/LaTeX/syntax_test_tex.tex b/LaTeX/syntax_test_tex.tex index e7c6268165..de9bfb6262 100644 --- a/LaTeX/syntax_test_tex.tex +++ b/LaTeX/syntax_test_tex.tex @@ -241,11 +241,13 @@ %^^^^^^^^ - meta.register.tex \newdimen\mydimen +%^^^^^^^^^^^^^^^^ meta.register.tex - meta.register meta.register %^^^^^^^^ keyword.declaration.register.tex storage.modifier.register.tex % ^^^^^^^^ entity.name.constant.tex % ^ punctuation.definition.backslash.tex \newcount { \mycounter } +%^^^^^^^^^^^^^^^^^^^^^^^ meta.register.tex - meta.register meta.register %^^^^^^^^ keyword.declaration.register.tex storage.modifier.register.tex % ^^^^^^^^^^^^^^ meta.group.brace.tex % ^^^^^^^^^^ entity.name.constant.tex @@ -257,10 +259,33 @@ % we just scope the macro like we would any other. \def\five{5} \toks \five = 8 -%^^^^^^^^^^^ meta.register.tex +%^^^^^^^^^^ meta.register.tex %^^^^ storage.type.tex % ^^^^^ support.function.general.tex % ^ punctuation.definition.backslash.tex +% ^ keyword.operator.assignment.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex + + +\count255 = 1 +%^^^^^^^^ meta.register.tex +%^^^^^ storage.type.tex +% ^^^ meta.number.integer.decimal constant.numeric.value.tex +% ^ keyword.operator.assignment.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex + +\dimen\dim50em plus 1ex +%^^^^^^^^^ meta.register.tex +%^^^^^ storage.type.tex +% ^^^^ support.function.general.tex +% ^ punctuation.definition.backslash.tex +% ^^^^ meta.number.integer.decimal.tex +% ^^ constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex +% ^^^^ keyword.operator.arithmetic.tex +% ^^^ meta.number.integer.decimal.tex +% ^ constant.numeric.value.tex +% ^^ constant.numeric.suffix.tex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From de22791350f9aed08614f699a10fcb9bb3bbaafd Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 27 Nov 2022 11:11:30 +0100 Subject: [PATCH 27/46] [TeX] Reorganize comments --- LaTeX/TeX.sublime-syntax | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 99fd52cdc3..05d2b97297 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -138,16 +138,18 @@ contexts: - include: general-constants - include: general-commands +###[ COMMENTS ]################################################################# + + comments: + - match: '%.*$\n?' + scope: comment.line.percentage.tex + general-commands: - match: (\\){{letter}}+ scope: support.function.general.tex captures: 1: punctuation.definition.backslash.tex - comments: - - match: '%.*$\n?' - scope: comment.line.percentage.tex - controls: - match: (\\)ifcase{{endcs}} scope: keyword.control.conditional.switch.tex From 450ec3fe960473536594e5e6865906386ef44645 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 27 Nov 2022 11:16:19 +0100 Subject: [PATCH 28/46] [TeX] Reorganize braces This commit groups all code block like contexts, which are used to nest `main` context in a `BLOCKS` sections. --- LaTeX/TeX.sublime-syntax | 72 +++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 05d2b97297..44f1ea8127 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -144,6 +144,44 @@ contexts: - match: '%.*$\n?' scope: comment.line.percentage.tex +###[ BLOCKS ]################################################################### + + braces: + - match: \{ + scope: punctuation.definition.group.brace.begin.tex + push: brace-group-body + + brace-group-begin: + - meta_include_prototype: false + - match: \{ + scope: punctuation.definition.group.brace.begin.tex + pop: true + + brace-group-body: + - meta_scope: meta.group.brace.tex + - include: brace-group-end + - include: main + + brace-group-end: + - match: \} + scope: punctuation.definition.group.brace.end.tex + pop: true + + boxes: + - match: ((\\)[hv]box)\s*(\{) + captures: + 1: support.function.box.tex + 2: punctuation.definition.backslash.tex + 3: punctuation.definition.group.brace.begin.tex + push: box-body + + box-body: + - meta_scope: meta.function.box.tex + - include: brace-group-end + - include: main + +###[ COMMANDS ]################################################################# + general-commands: - match: (\\){{letter}}+ scope: support.function.general.tex @@ -192,40 +230,6 @@ contexts: captures: 1: punctuation.definition.backslash.tex - braces: - - match: \{ - scope: punctuation.definition.group.brace.begin.tex - push: brace-group-body - - brace-group-begin: - - meta_include_prototype: false - - match: \{ - scope: punctuation.definition.group.brace.begin.tex - pop: true - - brace-group-body: - - meta_scope: meta.group.brace.tex - - include: brace-group-end - - include: main - - brace-group-end: - - match: \} - scope: punctuation.definition.group.brace.end.tex - pop: true - - boxes: - - match: ((\\)[hv]box)\s*(\{) - captures: - 1: support.function.box.tex - 2: punctuation.definition.backslash.tex - 3: punctuation.definition.group.brace.begin.tex - push: box-body - - box-body: - - meta_scope: meta.function.box.tex - - include: brace-group-end - - include: main - ###[ CHARACTER CODES ]########################################################## character-codes: From 3f1bd420f8c5bc7a467c2b642e72f7f5a4e18b07 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 27 Nov 2022 11:19:48 +0100 Subject: [PATCH 29/46] [TeX] Reorganize command and control contexts --- LaTeX/TeX.sublime-syntax | 100 ++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 44f1ea8127..78285d7c69 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -180,13 +180,56 @@ contexts: - include: brace-group-end - include: main -###[ COMMANDS ]################################################################# +###[ CHARACTER CODES ]########################################################## - general-commands: - - match: (\\){{letter}}+ - scope: support.function.general.tex + character-codes: + - match: (\\)(?:cat|math|uc|lc|del|sf)code{{endcs}} + scope: keyword.control.character-code.tex captures: 1: punctuation.definition.backslash.tex + push: + - character-code-meta + - character-code-value + - character-code-assignment + - character-code-number + + character-code-meta: + - meta_include_prototype: false + - meta_scope: meta.function.character-code.tex + - include: immediately-pop + + character-code-number: + - match: (`)(\\)?({{charbycode}}|.) + scope: meta.number.integer.tex + captures: + 1: keyword.operator.tex + 2: punctuation.definition.backslash.tex + 3: constant.character.tex + pop: 1 + - match: \d+ + scope: meta.number.integer.decimal.tex constant.numeric.value.tex + set: character-code-assignment + - include: else-pop + - include: paragraph-pop + + character-code-assignment: + - match: = + scope: keyword.operator.assignment.tex + pop: 1 + - include: else-pop + - include: paragraph-pop + + character-code-value: + - match: \d+ + scope: meta.number.integer.decimal.tex constant.numeric.value.tex + pop: 1 + - match: '"{{anyhexdigit}}+' + scope: meta.number.integer.hexadecimal.tex constant.numeric.value.tex + pop: 1 + - include: else-pop + - include: paragraph-pop + +###[ CONTROLS ]################################################################# controls: - match: (\\)ifcase{{endcs}} @@ -230,54 +273,13 @@ contexts: captures: 1: punctuation.definition.backslash.tex -###[ CHARACTER CODES ]########################################################## +###[ COMMANDS ]################################################################# - character-codes: - - match: (\\)(?:cat|math|uc|lc|del|sf)code{{endcs}} - scope: keyword.control.character-code.tex + general-commands: + - match: (\\){{letter}}+ + scope: support.function.general.tex captures: 1: punctuation.definition.backslash.tex - push: - - character-code-meta - - character-code-value - - character-code-assignment - - character-code-number - - character-code-meta: - - meta_include_prototype: false - - meta_scope: meta.function.character-code.tex - - include: immediately-pop - - character-code-number: - - match: (`)(\\)?({{charbycode}}|.) - scope: meta.number.integer.tex - captures: - 1: keyword.operator.tex - 2: punctuation.definition.backslash.tex - 3: constant.character.tex - pop: 1 - - match: \d+ - scope: meta.number.integer.decimal.tex constant.numeric.value.tex - set: character-code-assignment - - include: else-pop - - include: paragraph-pop - - character-code-assignment: - - match: = - scope: keyword.operator.assignment.tex - pop: 1 - - include: else-pop - - include: paragraph-pop - - character-code-value: - - match: \d+ - scope: meta.number.integer.decimal.tex constant.numeric.value.tex - pop: 1 - - match: '"{{anyhexdigit}}+' - scope: meta.number.integer.hexadecimal.tex constant.numeric.value.tex - pop: 1 - - include: else-pop - - include: paragraph-pop ###[ CONSTANTS ]################################################################ From de0a918bfcecdebb28fed5a9986f0a62ea7c2534 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 27 Nov 2022 11:21:48 +0100 Subject: [PATCH 30/46] [TeX] Reorganize main keys --- LaTeX/Bibtex.sublime-syntax | 8 ++++---- LaTeX/LaTeX.sublime-syntax | 2 +- LaTeX/TeX.sublime-syntax | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/LaTeX/Bibtex.sublime-syntax b/LaTeX/Bibtex.sublime-syntax index 53e8041c0d..06238862ba 100644 --- a/LaTeX/Bibtex.sublime-syntax +++ b/LaTeX/Bibtex.sublime-syntax @@ -1,11 +1,11 @@ %YAML 1.2 --- +# Grammar based on description from +# http://artis.imag.fr/~Xavier.Decoret/resources/xdkbibtex/bibtex_summary.html#comment +# +# TODO: Does not support @preamble name: BibTeX scope: text.bibtex -comment: | - Grammar based on description from http://artis.imag.fr/~Xavier.Decoret/resources/xdkbibtex/bibtex_summary.html#comment - - TODO: Does not support @preamble file_extensions: - bib diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index 25031cd6bc..14c9269c83 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -1,6 +1,6 @@ %YAML 1.2 --- -# http://www.sublimetext.com/docs/3/syntax.html +# http://www.sublimetext.com/docs/syntax.html name: LaTeX scope: text.tex.latex diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 78285d7c69..5987b8997e 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -1,11 +1,12 @@ %YAML 1.2 --- -# http://www.sublimetext.com/docs/3/syntax.html +# http://www.sublimetext.com/docs/syntax.html name: TeX +scope: text.tex + file_extensions: - sty - cls -scope: text.tex variables: greeks: |- From ca683f764f9ae7707e5708efac33fe5fe73d4075 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 27 Nov 2022 11:23:05 +0100 Subject: [PATCH 31/46] [TeX] Move test files into test/ sub directory --- LaTeX/{ => tests}/syntax_test_bibtex.bib | 0 LaTeX/{ => tests}/syntax_test_latex.tex | 0 LaTeX/{ => tests}/syntax_test_latex.xparse.tex | 0 LaTeX/{ => tests}/syntax_test_tex.tex | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename LaTeX/{ => tests}/syntax_test_bibtex.bib (100%) rename LaTeX/{ => tests}/syntax_test_latex.tex (100%) rename LaTeX/{ => tests}/syntax_test_latex.xparse.tex (100%) rename LaTeX/{ => tests}/syntax_test_tex.tex (100%) diff --git a/LaTeX/syntax_test_bibtex.bib b/LaTeX/tests/syntax_test_bibtex.bib similarity index 100% rename from LaTeX/syntax_test_bibtex.bib rename to LaTeX/tests/syntax_test_bibtex.bib diff --git a/LaTeX/syntax_test_latex.tex b/LaTeX/tests/syntax_test_latex.tex similarity index 100% rename from LaTeX/syntax_test_latex.tex rename to LaTeX/tests/syntax_test_latex.tex diff --git a/LaTeX/syntax_test_latex.xparse.tex b/LaTeX/tests/syntax_test_latex.xparse.tex similarity index 100% rename from LaTeX/syntax_test_latex.xparse.tex rename to LaTeX/tests/syntax_test_latex.xparse.tex diff --git a/LaTeX/syntax_test_tex.tex b/LaTeX/tests/syntax_test_tex.tex similarity index 100% rename from LaTeX/syntax_test_tex.tex rename to LaTeX/tests/syntax_test_tex.tex From d5ac30eaaaeb74936d83f7a3192ad17411e7038d Mon Sep 17 00:00:00 2001 From: deathaxe Date: Tue, 29 Nov 2022 18:22:49 +0100 Subject: [PATCH 32/46] [LaTeX] Scope all braced groups .tex (#3595) --- Haskell/Literate Haskell.sublime-syntax | 18 +- Haskell/tests/syntax_test_literate.lhs | 8 +- LaTeX/LaTeX.sublime-syntax | 499 +++++++++++------------ LaTeX/tests/syntax_test_latex.tex | 10 +- LaTeX/tests/syntax_test_latex.xparse.tex | 80 ++-- 5 files changed, 298 insertions(+), 317 deletions(-) diff --git a/Haskell/Literate Haskell.sublime-syntax b/Haskell/Literate Haskell.sublime-syntax index a947b402ba..ef7e77ada3 100644 --- a/Haskell/Literate Haskell.sublime-syntax +++ b/Haskell/Literate Haskell.sublime-syntax @@ -15,19 +15,21 @@ contexts: - include: haskell-code haskell-code: - - match: ((\\)begin)(\{)(code)(\}) + - match: ((\\)begin)((\{)\s*(code)\s*(\})) captures: 1: support.function.begin.latex keyword.control.block.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex - 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 3: meta.group.brace.tex + 4: punctuation.definition.group.brace.begin.tex + 5: variable.parameter.function.latex + 6: punctuation.definition.group.brace.end.tex embed: scope:source.haskell embed_scope: source.haskell.embedded.latex - escape: ((\\)end)(\{)(code)(\}) + escape: ((\\)end)((\{)\s*(code)\s*(\})) escape_captures: 1: support.function.end.latex keyword.control.block.end.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex - 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 3: meta.group.brace.tex + 4: punctuation.definition.group.brace.begin.tex + 5: variable.parameter.function.latex + 6: punctuation.definition.group.brace.end.tex diff --git a/Haskell/tests/syntax_test_literate.lhs b/Haskell/tests/syntax_test_literate.lhs index 84580da048..edca6a4e7e 100644 --- a/Haskell/tests/syntax_test_literate.lhs +++ b/Haskell/tests/syntax_test_literate.lhs @@ -5,9 +5,9 @@ % ^ source.haskell.embedded.latex % ^ punctuation.definition.backslash.latex % ^^^^^^ support.function.begin.latex keyword.control.block.begin.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^^^^ variable.parameter.function.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex {- comment -} % ^^^^^^^^^^^^^ source.haskell.embedded.latex comment.block.haskell @@ -23,6 +23,6 @@ % ^^^^^^^^^^^ - source.haskell % ^ punctuation.definition.backslash.latex % ^^^^ support.function.end.latex keyword.control.block.end.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^^^^ variable.parameter.function.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index 14c9269c83..e9a6ad0670 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -36,27 +36,6 @@ contexts: - include: graphics - include: lists - braces: - - match: \{ - scope: punctuation.definition.group.brace.begin.latex - push: brace-group-body - - brace-group-begin: - - meta_include_prototype: false - - match: \{ - scope: punctuation.definition.group.brace.begin.latex - pop: true - - brace-group-body: - - meta_scope: meta.group.brace.latex - - include: brace-group-end - - include: main - - brace-group-end: - - match: \} - scope: punctuation.definition.group.brace.end.latex - pop: true - # these are used to identify arguments in commands general-optional-arguments: - match: \[ @@ -73,15 +52,15 @@ contexts: scope: variable.parameter.bracket.latex argument-brace: - - meta_scope: meta.group.brace.latex + - meta_scope: meta.group.brace.tex - match: \} - scope: punctuation.definition.group.brace.end.latex + scope: punctuation.definition.group.brace.end.tex pop: true - include: main argument: - match: \{ - scope: punctuation.definition.group.brace.begin.latex + scope: punctuation.definition.group.brace.begin.tex set: argument-brace - include: else-pop @@ -313,7 +292,7 @@ contexts: - include: paragraph-pop xparse-newcommand-args-wrapped-token: - - meta_scope: meta.group.brace.latex + - meta_scope: meta.group.brace.tex - include: brace-group-end # either a command - match: (\\){{cmdname}}{{endcs}} @@ -349,7 +328,7 @@ contexts: xparse-newcommand-optarg-wrapped-value: - clear_scopes: 1 - - meta_scope: meta.function.parameters.default-value.latex meta.group.brace.latex + - meta_scope: meta.function.parameters.default-value.latex meta.group.brace.tex - include: brace-group-end - include: macro-braces-content @@ -377,11 +356,11 @@ contexts: captures: 1: support.function.box.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.box.latex - match: \} - scope: punctuation.definition.group.brace.end.latex + scope: punctuation.definition.group.brace.end.tex pop: true - include: main - match: ((\\)(?:framebox|makebox))\b @@ -419,13 +398,13 @@ contexts: - meta_scope: meta.preamble.documentclass.latex - include: general-optional-arguments - match: \{ - scope: punctuation.definition.group.brace.begin.latex + scope: punctuation.definition.group.brace.begin.tex set: - - meta_scope: meta.preamble.documentclass.latex meta.group.brace.latex + - meta_scope: meta.preamble.documentclass.latex meta.group.brace.tex - match: '[A-Za-z[:digit:]-]' scope: support.class.latex - match: \} - scope: punctuation.definition.group.brace.end.latex + scope: punctuation.definition.group.brace.end.tex pop: true - match: '' pop: true @@ -438,11 +417,11 @@ contexts: - meta_scope: meta.preamble.usepackage.latex - include: general-optional-arguments - match: \{ - scope: punctuation.definition.group.brace.begin.latex + scope: punctuation.definition.group.brace.begin.tex set: - - meta_scope: meta.preamble.usepackage.latex meta.group.brace.latex + - meta_scope: meta.preamble.usepackage.latex meta.group.brace.tex - match: \} - scope: punctuation.definition.group.brace.end.latex + scope: punctuation.definition.group.brace.end.tex pop: true - match: '[A-Za-z[:digit:]-]*' scope: support.class.latex @@ -455,7 +434,7 @@ contexts: captures: 1: keyword.control.include.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.include.latex - include: brace-group-end @@ -480,10 +459,10 @@ contexts: captures: 1: support.function.section.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: entity.name.section.latex - 5: punctuation.definition.group.brace.end.latex - 6: punctuation.definition.group.brace.begin.latex + 5: punctuation.definition.group.brace.end.tex + 6: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.section.latex - meta_content_scope: entity.name.section.latex @@ -501,9 +480,9 @@ contexts: captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex push: - meta_include_prototype: false - meta_scope: meta.environment.verbatim.verbatim.latex @@ -512,9 +491,9 @@ contexts: captures: 1: support.function.end.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex pop: true lists: @@ -522,72 +501,72 @@ contexts: captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex push: - meta_scope: meta.environment.list.itemize.latex - match: ((\\)end)(\{)\s*(\4)\s*(\}) captures: 1: support.function.end.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex pop: true - include: main - match: ((\\)begin)(\{)\s*(enumerate\*?)\s*(\}) captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex push: - meta_scope: meta.environment.list.enumerate.latex - match: ((\\)end)(\{)\s*(\4)\s*(\}) captures: 1: support.function.end.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex pop: true - include: main - match: ((\\)begin)(\{)\s*(list\*?)\s*(\}) captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex push: - meta_scope: meta.environment.list.list.latex - match: ((\\)end)(\{)\s*(\4)\s*(\}) captures: 1: support.function.end.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex pop: true - include: main - match: ((\\)begin)(\{)\s*(description\*?)\s*(\}) captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex push: - meta_scope: meta.environment.list.description.latex - match: ((\\)end)(\{)\s*(\4)\s*(\}) captures: 1: support.function.end.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex pop: true - include: main @@ -603,7 +582,7 @@ contexts: captures: 1: support.function.ensuremath.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex push: inline-math-ensuremath-body inline-math-ensuremath-body: @@ -643,9 +622,9 @@ contexts: captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex push: block-math-begin-end-command-body block-math-begin-end-command-body: @@ -658,9 +637,9 @@ contexts: captures: 1: support.function.end.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex pop: true block-math-brackets: @@ -705,9 +684,9 @@ contexts: captures: 1: support.function.url.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: markup.underline.link.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex verb: - match: ((\\)verb)(\W) @@ -728,7 +707,7 @@ contexts: captures: 1: support.function.emph.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.emph.latex - meta_content_scope: markup.italic.emph.latex @@ -738,7 +717,7 @@ contexts: captures: 1: support.function.textit.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.textit.latex - meta_content_scope: markup.italic.textit.latex @@ -748,7 +727,7 @@ contexts: captures: 1: support.function.textbf.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.textbf.latex - meta_content_scope: markup.bold.textbf.latex @@ -758,7 +737,7 @@ contexts: captures: 1: support.function.texttt.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.texttt.latex - meta_content_scope: markup.raw.texttt.latex @@ -768,7 +747,7 @@ contexts: captures: 1: support.function.textsl.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.textsl.latex - meta_content_scope: markup.italic.textsl.latex @@ -778,7 +757,7 @@ contexts: captures: 1: support.function.text.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex push: - include: brace-group-end - include: main @@ -786,7 +765,7 @@ contexts: captures: 1: support.function.text.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.underline.latex - meta_content_scope: markup.underline.underline.latex @@ -802,9 +781,9 @@ contexts: - meta_scope: meta.function.footnote.latex - include: general-optional-arguments - match: \{ - scope: punctuation.definition.group.brace.begin.latex + scope: punctuation.definition.group.brace.begin.tex set: - - meta_scope: meta.function.footnote.latex meta.group.brace.latex + - meta_scope: meta.function.footnote.latex meta.group.brace.tex - meta_content_scope: markup.italic.footnote.latex - include: brace-group-end - include: main @@ -851,11 +830,11 @@ contexts: - meta_scope: meta.function.citation.latex - include: general-optional-arguments - match: \{ - scope: punctuation.definition.group.brace.begin.latex + scope: punctuation.definition.group.brace.begin.tex # Some commands, e.g. \parencites, allow multiple [][]{} argument sequences, # so we `push` instead of `set`. push: - - meta_scope: meta.group.brace.latex + - meta_scope: meta.group.brace.tex - match: '[a-zA-Z0-9\.:/*!^_-]+' scope: constant.other.citation.latex - include: brace-group-end @@ -875,9 +854,9 @@ contexts: - meta_scope: meta.function.reference.latex - include: general-optional-arguments - match: \{ - scope: punctuation.definition.group.brace.begin.latex + scope: punctuation.definition.group.brace.begin.tex set: - - meta_scope: meta.function.reference.latex meta.group.brace.latex + - meta_scope: meta.function.reference.latex meta.group.brace.tex - match: '[a-zA-Z0-9\.:/*!^_-]+' scope: constant.other.reference.latex - include: brace-group-end @@ -887,7 +866,7 @@ contexts: captures: 1: support.function.label.latex storage.type.label.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.label.latex - match: '[a-zA-Z0-9\.:/*!^_-]+' @@ -899,9 +878,9 @@ contexts: captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex push: - include: general-optional-arguments - match: '' @@ -910,9 +889,9 @@ contexts: captures: 1: support.function.end.latex keyword.control.flow.end.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex # external packages packages: @@ -933,13 +912,13 @@ contexts: - meta_scope: meta.environment.verbatim.lstinline.latex - include: general-optional-arguments - match: \{ - scope: punctuation.definition.group.brace.begin.latex + scope: punctuation.definition.group.brace.begin.tex set: - meta_include_prototype: false - - meta_scope: meta.group.brace.latex + - meta_scope: meta.group.brace.tex - meta_content_scope: meta.environment.verbatim.lstinline.latex markup.raw.verb.latex - match: '\}' - scope: meta.environment.verbatim.lstinline.latex punctuation.definition.group.brace.end.latex + scope: meta.environment.verbatim.lstinline.latex punctuation.definition.group.brace.end.tex pop: true - match: (\W) scope: punctuation.definition.verb.latex @@ -954,9 +933,9 @@ contexts: captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex push: - meta_include_prototype: false - meta_scope: meta.environment.verbatim.lstlisting.latex @@ -964,9 +943,9 @@ contexts: captures: 1: support.function.end.latex keyword.control.flow.end.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex pop: true - include: general-optional-arguments - match: .*(%\s*(?i:c))$ @@ -1086,9 +1065,9 @@ contexts: captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex push: - meta_include_prototype: false - meta_scope: meta.environment.verbatim.minted.latex @@ -1096,192 +1075,192 @@ contexts: captures: 1: support.function.end.latex keyword.control.flow.end.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex pop: true - include: general-optional-arguments - match: (\{)(c)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.c embed_scope: meta.environment.embedded.c.latex source.c.embedded escape: (?=\\end\{minted\}) - match: (\{)(cpp|c\+\+)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.c++ embed_scope: meta.environment.embedded.c++.latex source.c++.embedded escape: (?=\\end\{minted\}) - match: (\{)(diff)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.diff embed_scope: meta.environment.embedded.diff.latex source.diff.embedded escape: (?=\\end\{minted\}) - match: (\{)(go|golang)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.go embed_scope: meta.environment.embedded.go.latex source.go.embedded escape: (?=\\end\{minted\}) - match: (\{)(haskell|hs)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.haskell embed_scope: meta.environment.embedded.haskell.latex source.haskell.embedded escape: (?=\\end\{minted\}) - match: (\{)(html)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:text.html.basic embed_scope: meta.environment.embedded.html.latex text.html.embedded escape: (?=\\end\{minted\}) - match: (\{)(java)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.java embed_scope: meta.environment.embedded.java.latex source.java.embedded escape: (?=\\end\{minted\}) - match: (\{)(javascript|js)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.js embed_scope: meta.environment.embedded.js.latex source.js.embedded escape: (?=\\end\{minted\}) - match: (\{)(json)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.json embed_scope: meta.environment.embedded.json.latex source.json.embedded escape: (?=\\end\{minted\}) - match: (\{)(tex|latex)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:text.tex.latex embed_scope: meta.environment.embedded.latex.latex text.tex.latex.embedded escape: (?=\\end\{minted\}) - match: (\{)(lisp)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.lisp embed_scope: meta.environment.embedded.lisp.latex source.lisp.embedded escape: (?=\\end\{minted\}) - match: (\{)(lua)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.lua embed_scope: meta.environment.embedded.lua.latex source.lua.embedded escape: (?=\\end\{minted\}) - match: (\{)(obj(?:ective\-|)c)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.objc embed_scope: meta.environment.embedded.objc.latex source.objc.embedded escape: (?=\\end\{minted\}) - match: (\{)(obj(?:ective\-|)c\+\+)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.objc++ embed_scope: meta.environment.embedded.objc++.latex source.objc++.embedded escape: (?=\\end\{minted\}) - match: (\{)(perl)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.perl embed_scope: meta.environment.embedded.perl.latex source.perl.embedded escape: (?=\\end\{minted\}) - match: (\{)(php)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.php embed_scope: meta.environment.embedded.php.latex source.php.embedded escape: (?=\\end\{minted\}) - match: (\{)(python|py)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.python embed_scope: meta.environment.embedded.python.latex source.python.embedded escape: (?=\\end\{minted\}) - match: (\{)(r)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.r embed_scope: meta.environment.embedded.r.latex source.r.embedded escape: (?=\\end\{minted\}) - match: (\{)(ruby)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.ruby embed_scope: meta.environment.embedded.ruby.latex source.ruby.embedded escape: (?=\\end\{minted\}) - match: (\{)(sh|shell|bash )(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.shell embed_scope: meta.environment.embedded.shell.latex source.shell.embedded escape: (?=\\end\{minted\}) - match: (\{)(sql|mysql|ddl|dml)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.sql embed_scope: meta.environment.embedded.sql.latex source.sql.embedded escape: (?=\\end\{minted\}) - match: (\{)(xml)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:text.xml embed_scope: meta.environment.embedded.xml.latex text.xml.embedded escape: (?=\\end\{minted\}) - match: (\{)(yaml)(\}) captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex + 3: punctuation.definition.group.brace.end.tex embed: scope:source.yaml embed_scope: meta.environment.embedded.yaml.latex source.yaml.embedded escape: (?=\\end\{minted\}) @@ -1304,324 +1283,324 @@ contexts: - match: (\{)(c)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.c embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.c.latex source.c.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(cpp|c\+\+)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.c++ embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.c++.latex source.c++.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(diff)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.diff embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.diff.latex source.diff.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(go|golang)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.go embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.go.latex source.go.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(haskell|hs)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.haskell embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.haskell.latex source.haskell.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(html)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:text.html.basic embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.html.latex text.html.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(java)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.java embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.java.latex source.java.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(javascript|js)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.js embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.js.latex source.js.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(json)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.json embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.json.latex source.json.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(tex|latex)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:text.tex.latex embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.latex.latex text.tex.latex.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(lisp)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.lisp embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.lisp.latex source.lisp.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(lua)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.lua embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.lua.latex source.lua.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(obj(?:ective\-|)c)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.objc embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.objc.latex source.objc.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(obj(?:ective\-|)c\+\+)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.objc++ embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.objc++.latex source.objc++.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(perl)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.perl embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.perl.latex source.perl.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(php)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.php embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.php.latex source.php.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(python|py)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.python embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.python.latex source.python.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(r)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.r embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.r.latex source.r.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(ruby)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.ruby embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.ruby.latex source.ruby.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(sh|shell|bash )(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.shell embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.shell.latex source.shell.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(sql|mysql|ddl|dml)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.sql embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.sql.latex source.sql.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(xml)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:text.xml embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.xml.latex text.xml.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: (\{)(yaml)(\})((\{)|(\W)) scope: meta.environment.verbatim.minted.latex captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: variable.parameter.function.latex - 3: punctuation.definition.group.brace.end.latex - 5: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.end.tex + 5: punctuation.definition.group.brace.begin.tex 6: punctuation.definition.verb.latex embed: scope:source.yaml embed_scope: meta.environment.verbatim.minted.latex meta.environment.embedded.yaml.latex source.yaml.embedded escape: (\})|(\4) escape_captures: - 1: punctuation.definition.group.brace.begin.latex + 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: '' pop: true @@ -1643,9 +1622,9 @@ contexts: captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex push: - meta_scope: meta.environment.comment.latex - meta_content_scope: comment.block.environment.comment.latex @@ -1653,9 +1632,9 @@ contexts: captures: 1: support.function.end.latex keyword.control.flow.end.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex pop: true # beamer support @@ -1664,18 +1643,18 @@ contexts: captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex push: - meta_scope: meta.environment.frame.latex - match: ((\\)end)(\{)(frame)(\}) captures: 1: support.function.end.latex keyword.control.flow.end.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex pop: true - include: frametitles - include: main @@ -1686,9 +1665,9 @@ contexts: captures: 1: support.function.frametitle.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: entity.name.function.frame.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex # support for array package pkgarray: @@ -1710,12 +1689,12 @@ contexts: captures: 1: support.function.newcolumntype.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: support.function.latex entity.name.newcolumntype.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex 6: punctuation.definition.group.bracket.begin.latex 7: punctuation.definition.group.bracket.end.latex - 8: punctuation.definition.group.brace.begin.latex + 8: punctuation.definition.group.brace.begin.tex push: - meta_include_prototype: false - meta_scope: meta.function.newcolumntype.latex @@ -1731,20 +1710,20 @@ contexts: captures: 1: support.function.begin.latex keyword.control.flow.begin.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex 6: punctuation.definition.group.bracket.begin.latex 7: punctuation.definition.group.bracket.end.latex push: - meta_scope: meta.environment.tabular.latex - match: \{ - scope: meta.function.column-spec.latex punctuation.definition.group.brace.begin.latex + scope: meta.function.column-spec.latex punctuation.definition.group.brace.begin.tex set: - meta_content_scope: meta.environment.tabular.latex meta.function.column-spec.latex - include: array-preamble - match: \} - scope: punctuation.definition.group.brace.end.latex + scope: punctuation.definition.group.brace.end.tex set: - meta_content_scope: meta.environment.tabular.latex - match: ((\\)end)(\{)(tabular)(\}) @@ -1752,16 +1731,16 @@ contexts: captures: 1: support.function.end.latex keyword.control.flow.end.latex 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.latex + 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex - 5: punctuation.definition.group.brace.end.latex + 5: punctuation.definition.group.brace.end.tex pop: true - include: main array-preamble: - match: \{ - scope: punctuation.definition.group.brace.begin.latex + scope: punctuation.definition.group.brace.begin.tex push: - include: brace-group-end - include: general-constants @@ -1780,7 +1759,7 @@ contexts: - match: (>)\s*(\{) captures: 1: support.function.insert-before-column.latex - 2: punctuation.definition.group.brace.begin.latex + 2: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.before-column-decl.latex - include: brace-group-end @@ -1791,7 +1770,7 @@ contexts: - match: (<)\s*(\{) captures: 1: support.function.insert-after-column.latex - 2: punctuation.definition.group.brace.begin.latex + 2: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.after-column-decl.latex - include: brace-group-end @@ -1805,7 +1784,7 @@ contexts: - match: (@)\s*(\{) captures: 1: support.function.inter-column-nospace.latex - 2: punctuation.definition.group.brace.begin.latex + 2: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.inter-column-decl.latex - include: brace-group-end @@ -1816,7 +1795,7 @@ contexts: - match: (!)\s*(\{) captures: 1: support.function.inter-column.latex - 2: punctuation.definition.group.brace.begin.latex + 2: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.inter-column-decl.latex - include: brace-group-end @@ -1827,22 +1806,22 @@ contexts: - match: (\*)\s*(\{) captures: 1: support.function.insert-repeated.latex - 2: meta.function.insert-repeated-count.latex punctuation.definition.group.brace.begin.latex + 2: meta.function.insert-repeated-count.latex punctuation.definition.group.brace.begin.tex push: - meta_content_scope: meta.function.insert-repeated-count.latex - match: \d+ scope: constant.numeric.array-count.latex - include: general-commands - match: \} - scope: punctuation.definition.group.brace.end.latex + scope: punctuation.definition.group.brace.end.tex set: - match: \{ - scope: meta.function.insert-repeated-content.latex punctuation.definition.group.brace.begin.latex + scope: meta.function.insert-repeated-content.latex punctuation.definition.group.brace.begin.tex set: - meta_content_scope: meta.function.insert-repeated-content.latex - include: array-preamble - match: \} - scope: meta.function.insert-repeated-content.latex punctuation.definition.group.brace.end.latex + scope: meta.function.insert-repeated-content.latex punctuation.definition.group.brace.end.tex pop: true - match: '' pop: true diff --git a/LaTeX/tests/syntax_test_latex.tex b/LaTeX/tests/syntax_test_latex.tex index af543496aa..4a11f5ace2 100644 --- a/LaTeX/tests/syntax_test_latex.tex +++ b/LaTeX/tests/syntax_test_latex.tex @@ -403,7 +403,7 @@ \subsubsection{name} \footnote{This is a basic footnote} % ^^^^^^^ meta.function.footnote.latex support.function.footnote.latex -% ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.footnote.latex meta.group.brace.latex +% ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.footnote.latex meta.group.brace.tex % ^^^^^^^^^^^^^^^^^^^^^^^^ markup.italic.footnote.latex \footnote [ 5 ] {This is a footnote with a specific reference mark} @@ -412,13 +412,13 @@ \subsubsection{name} % ^^^^^ meta.function.footnote.latex meta.group.bracket.latex % ^ punctuation.definition.group.bracket.end.latex % ^ punctuation.definition.group.brace.begin -% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.footnote.latex meta.group.brace.latex +% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.footnote.latex meta.group.brace.tex % ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.italic.footnote.latex % ^ punctuation.definition.group.brace.end \footnotetext{Footnote text without creating a mark} % ^^^^^^^^^^^ meta.function.footnote.latex support.function.footnote.latex -% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.footnote.latex meta.group.brace.latex +% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.footnote.latex meta.group.brace.tex % ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.italic.footnote.latex \footnotemark @@ -501,7 +501,7 @@ \subsubsection{name} % ^ support.function.general.latex % ^ meta.group.bracket.latex % ^ punctuation.definition.group.brace.begin -% ^ meta.group.brace.latex +% ^ meta.group.brace.tex % ^ punctuation.definition.group.brace.end @@ -615,7 +615,7 @@ \subsubsection{name} \lstinline{var x = 15;} % ^^^^^^^^^^^^^^^^^^^^^ meta.environment.verbatim.lstinline.latex -% ^^^^^^^^^^^^^ meta.group.brace.latex +% ^^^^^^^^^^^^^ meta.group.brace.tex % ^ punctuation.definition.group.brace.begin % ^^^^^^^^^^^ markup.raw.verb.latex % ^ punctuation.definition.group.brace.end diff --git a/LaTeX/tests/syntax_test_latex.xparse.tex b/LaTeX/tests/syntax_test_latex.xparse.tex index 28e982fea0..3d9ea4edec 100644 --- a/LaTeX/tests/syntax_test_latex.xparse.tex +++ b/LaTeX/tests/syntax_test_latex.xparse.tex @@ -10,12 +10,12 @@ % ^^^^^^^^^ meta.function.body.tex meta.group.brace.tex % ^ - meta.function %^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^^^^^^^^^ entity.name.newcommand.latex % ^ punctuation.definition.backslash.latex -% ^ punctuation.definition.group.brace.end.latex -% ^ punctuation.definition.group.brace.begin.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex % ^ punctuation.definition.group.brace.begin.tex % ^ punctuation.definition.group.brace.end.tex @@ -27,13 +27,13 @@ % ^^^^^^^^^^^^ meta.function.body meta.group.brace % ^ - meta.function %^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^^^^^^^^^^ entity.name.newcommand.latex % ^ punctuation.definition.backslash.latex -% ^ punctuation.definition.group.brace.end.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.end.tex +% ^ punctuation.definition.group.brace.begin.tex % ^ storage.type.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex % ^ punctuation.definition.group.brace.begin.tex % ^^ variable.parameter.tex % ^ punctuation.definition.group.brace.end.tex @@ -140,7 +140,7 @@ % ^^^^^^^^^ entity.name.newcommand.latex % ^ storage.type.latex % ^^ constant.character.latex constant.other.token.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex \NewDocumentCommand{\optional}{O{default}}{function body} @@ -148,8 +148,8 @@ %^^^^^^^^^^^^^^^^^^ meta.function.latex % ^^^^^^^^^^^ meta.function.identifier.latex % ^^ meta.function.parameters.latex -% ^^^^^^^^^ meta.function.parameters.default-value.latex meta.group.brace.latex -% ^ meta.function.parameters.latex punctuation.definition.group.brace.end.latex +% ^^^^^^^^^ meta.function.parameters.default-value.latex meta.group.brace.tex +% ^ meta.function.parameters.latex punctuation.definition.group.brace.end.tex % ^^^^^^^^^^^^^^^ meta.function.body % ^ - meta.function %^^^^^^^^^^^^^^^^^^ keyword.declaration.function.latex storage.modifier.newcommand.latex @@ -189,30 +189,30 @@ % ^^^^^^^^^^^^^^^ meta.function.body % ^ - meta.function %^^^^^^^^^^^^^^^^^^ storage.modifier.newcommand.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^^^^^^^^^ entity.name.newcommand.latex -% ^ punctuation.definition.group.brace.end.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.end.tex +% ^ punctuation.definition.group.brace.begin.tex % ^ storage.type.latex % ^ - punctuation.definition.group -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex % ^ punctuation.definition.group.brace.begin.tex % ^ punctuation.definition.group.brace.end.tex \NewDocumentCommand{\optional}{O\value m}{function body} % ^^ meta.function.parameters.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^ storage.type.latex % ^^^^^^ meta.function.parameters.default-value.latex support.function.latex % ^ punctuation.definition.backslash.latex % ^^^ meta.function.parameters.latex % ^ storage.type.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex \NewDocumentCommand{\optional}{O{#1: \year \parskip1em }}{function body} % ^ storage.type.latex -% ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.default-value.latex meta.group.brace.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.default-value.latex meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.tex % ^^ variable.parameter.tex % ^ punctuation.definition.placeholder.tex % ^ meta.number.integer.decimal.tex constant.numeric.value.tex @@ -286,27 +286,27 @@ \NewDocumentCommand{\MyMacro}{e{\up \down}}{up: #1 down: #2} % ^ storage.type.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^^^ constant.other.token.latex % ^^^^^ constant.other.token.latex % ^ punctuation.definition.backslash.latex % ^ punctuation.definition.backslash.latex -% ^^ punctuation.definition.group.brace.end.latex +% ^^ punctuation.definition.group.brace.end.tex % ^^^^^^^^^^^^^^^^^ meta.function.body.tex meta.group.brace.tex -% Argument processors: example from +% Argument processors: example from % https://www.nic.funet.fi/pub/TeX/CTAN/macros/latex/contrib/l3packages/xparse.pdf \NewDocumentCommand \foo { O{,} >{\SplitList{#1}} m } { \foobar{#2} } % ^^^ meta.function.parameters.latex -% ^^^ meta.function.parameters.default-value.latex meta.group.brace.latex +% ^^^ meta.function.parameters.default-value.latex meta.group.brace.tex % ^^^^^^^^^^^^^^^^^^^^^^ meta.function.parameters.latex % ^ meta.function.latex % ^^^^^^^^^^^^^^^ meta.function.body.tex meta.group.brace.tex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^ storage.type.latex -% ^ punctuation.definition.group.brace.begin.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex % ^ storage.modifier.latex % ^^^^^^^^^^^^^^^^ meta.group.brace.tex % ^ punctuation.definition.group.brace.begin.tex @@ -320,7 +320,7 @@ % ^ punctuation.definition.group.brace.end.tex % ^ punctuation.definition.group.brace.end.tex % ^ storage.type.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex @@ -358,15 +358,15 @@ % ^^^^^^^^^^^^ meta.function.parameters.latex % ^^^^^^^^^ meta.group.brace.tex % ^^^^^^ meta.function.body.tex meta.group.brace.tex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^^^^^^^ entity.name.newcommand.latex % ^ punctuation.definition.backslash.latex -% ^ punctuation.definition.group.brace.end.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.end.tex +% ^ punctuation.definition.group.brace.begin.tex % ^ storage.type.latex % ^ punctuation.definition.group.brace.begin.tex % ^ punctuation.definition.group.brace.end.tex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex % ^ punctuation.definition.group.brace.begin.tex % ^ punctuation.definition.group.brace.end.tex @@ -380,17 +380,17 @@ % ^^^^^^^^^^^^^^^^ meta.function.parameters.latex % ^^^^^^^^^^^^^^ meta.function.body.tex meta.group.brace.tex % ^ - meta.function -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^^^^^^^^^^ entity.name.newcommand.latex % ^ punctuation.definition.backslash.latex -% ^ punctuation.definition.group.brace.end.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.end.tex +% ^ punctuation.definition.group.brace.begin.tex % ^ storage.type.latex % ^^^^^ constant.other.token.latex % ^ punctuation.definition.backslash.latex % ^^^^^^ support.function.general.latex % ^ punctuation.definition.backslash.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex % ^ punctuation.definition.group.brace.begin.tex % ^^ variable.parameter.tex % ^ punctuation.definition.placeholder.tex @@ -401,20 +401,20 @@ % Currently unsupported syntax versions: % These are very rare, so at this point we have opted for reduced complexity % of the syntax highlighting, with the cost that some syntactially valid patterns -% get suboptimal highlighting. +% get suboptimal highlighting. \NewDocumentCommand{\braces}{{m}}{content} % ^^^^^ meta.function.parameters.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^^^ meta.group.brace.tex % ^ punctuation.definition.group.brace.begin.tex % ^ punctuation.definition.group.brace.end.tex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex % ^^^^^^^^^ meta.function.body.tex meta.group.brace.tex \NewDocumentCommand{\braces}{m {O}{value} m}{content} % ^^^^^^^^^^^^^^^^ meta.function.parameters.latex -% ^ punctuation.definition.group.brace.begin.latex +% ^ punctuation.definition.group.brace.begin.tex % ^ storage.type.latex % ^^^^^^^^^^ meta.group.brace.tex % ^ punctuation.definition.group.brace.begin.tex @@ -422,7 +422,7 @@ % ^ punctuation.definition.group.brace.begin.tex % ^ punctuation.definition.group.brace.end.tex % ^ storage.type.latex -% ^ punctuation.definition.group.brace.end.latex +% ^ punctuation.definition.group.brace.end.tex % ^^^^^^^^^ meta.function.body.tex meta.group.brace.tex % ^ punctuation.definition.group.brace.begin.tex % ^ punctuation.definition.group.brace.end.tex From 2f6dfd84dd354c32652be5456ec29943d9d30066 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Dec 2022 19:25:09 +0100 Subject: [PATCH 33/46] [TeX] Apply scope naming guidelines to math operators --- LaTeX/TeX.sublime-syntax | 10 ++++-- LaTeX/tests/syntax_test_latex.tex | 4 +-- LaTeX/tests/syntax_test_tex.tex | 45 ++++++++++++++++++++++++++ Markdown/tests/syntax_test_markdown.md | 14 ++++---- 4 files changed, 62 insertions(+), 11 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 5987b8997e..4d114e7fd3 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -634,8 +634,14 @@ contexts: 1: punctuation.definition.backslash.tex math-operators: - - match: \+|\-|=|-|\*|/|\^|_|<|> - scope: keyword.operator.math.tex + - match: '[<>]=?' + scope: keyword.operator.comparison.tex + - match: '[-+*/^!]' + scope: keyword.operator.arithmetic.tex + - match: = + scope: keyword.operator.assignment.tex + - match: _ + scope: punctuation.separator.indice.tex math-braces: - match: \{ diff --git a/LaTeX/tests/syntax_test_latex.tex b/LaTeX/tests/syntax_test_latex.tex index 4a11f5ace2..4a3fd3a047 100644 --- a/LaTeX/tests/syntax_test_latex.tex +++ b/LaTeX/tests/syntax_test_latex.tex @@ -534,11 +534,11 @@ \subsubsection{name} $\alpha _$ % ^ keyword.other.math.greek.tex -% ^ keyword.operator.math.tex +% ^ punctuation.separator.indice.tex $\alpha_$ % ^ keyword.other.math.greek.tex -% ^ keyword.operator.math.tex +% ^ punctuation.separator.indice.tex % Boxes \mbox{text}{text} diff --git a/LaTeX/tests/syntax_test_tex.tex b/LaTeX/tests/syntax_test_tex.tex index de9bfb6262..e8aaa31f65 100644 --- a/LaTeX/tests/syntax_test_tex.tex +++ b/LaTeX/tests/syntax_test_tex.tex @@ -825,3 +825,48 @@ \def\macro{\abovedisplayskip=}5 % ^ - meta.number + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Math +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +$$ +% <- meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex +%^^ meta.environment.math.block.dollar.tex +%^ string.other.math.tex punctuation.definition.string.begin.tex + + c = a + b - d * f / g! +% ^ variable.other.math.tex +% ^ keyword.operator.assignment.tex +% ^ variable.other.math.tex +% ^ keyword.operator.arithmetic.tex +% ^ variable.other.math.tex +% ^ keyword.operator.arithmetic.tex +% ^ variable.other.math.tex +% ^ keyword.operator.arithmetic.tex +% ^ variable.other.math.tex +% ^ keyword.operator.arithmetic.tex +% ^ variable.other.math.tex +% ^ keyword.operator.arithmetic.tex + + a < b <= c +% ^ variable.other.math.tex +% ^ keyword.operator.comparison.tex +% ^ variable.other.math.tex +% ^^ keyword.operator.comparison.tex +% ^ variable.other.math.tex + + a > b >= c +% ^ variable.other.math.tex +% ^ keyword.operator.comparison.tex +% ^ variable.other.math.tex +% ^^ keyword.operator.comparison.tex +% ^ variable.other.math.tex + + a_n^2 +% ^ variable.other.math.tex +% ^ punctuation.separator.indice.tex +% ^ variable.other.math.tex +% ^ keyword.operator.arithmetic.tex + +$$ \ No newline at end of file diff --git a/Markdown/tests/syntax_test_markdown.md b/Markdown/tests/syntax_test_markdown.md index c08bd934c8..eb5e381df6 100644 --- a/Markdown/tests/syntax_test_markdown.md +++ b/Markdown/tests/syntax_test_markdown.md @@ -8038,20 +8038,20 @@ $$ foo = 1 + 2 * \sqrt{a^2+b^2} | <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar variable.other.math |^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar -| ^ keyword.operator.math +| ^ keyword.operator.assignment | ^ constant.numeric.math -| ^ keyword.operator.math +| ^ keyword.operator.arithmetic | ^ constant.numeric.math -| ^ keyword.operator.math +| ^ keyword.operator.arithmetic | ^^^^^ support.function.math | ^^^^^^^^^ meta.group.brace | ^ punctuation.definition.group.brace.begin | ^ variable.other.math -| ^ keyword.operator.math +| ^ keyword.operator.arithmetic | ^ constant.numeric.math -| ^ keyword.operator.math +| ^ keyword.operator.arithmetic | ^ variable.other.math -| ^ keyword.operator.math +| ^ keyword.operator.arithmetic | ^ constant.numeric.math | ^ punctuation.definition.group.brace.end $$ @@ -8171,7 +8171,7 @@ This is math $1+1$ expression, but $ 1+1 $ ,$ 1+1$, $1+1 $ and 1+1$ or $1+1 are | ^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex | ^ punctuation.definition.math.begin.latex | ^ constant.numeric.math.tex -| ^ keyword.operator.math.tex +| ^ keyword.operator.arithmetic.tex | ^ constant.numeric.math.tex | ^ punctuation.definition.math.end.latex | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math From 42c7b91931e56a6c4a1b2f8874fc79cedc527281 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Dec 2022 19:31:52 +0100 Subject: [PATCH 34/46] [TeX] Apply scope naming guidelines to math numbers --- LaTeX/TeX.sublime-syntax | 12 ++++++---- LaTeX/tests/syntax_test_tex.tex | 33 ++++++++++++++++++++++++++ Markdown/tests/syntax_test_markdown.md | 12 +++++----- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 4d114e7fd3..be9311c94e 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -559,7 +559,7 @@ contexts: - include: math-commands - include: math-operators - include: math-characters - - include: math-numerics + - include: math-numbers - include: general-constants math-builtin: @@ -663,9 +663,13 @@ contexts: captures: 1: punctuation.definition.backslash.brace.escape.tex - math-numerics: - - match: (([[:digit:]]*\.[[:digit:]]+)|[[:digit:]]+) - scope: constant.numeric.math.tex + math-numbers: + - match: \d*(\.)\d+ + scope: meta.number.float.decimal.tex constant.numeric.value.tex + captures: + 1: punctuation.separator.decimal.tex + - match: \d+ + scope: meta.number.integer.decimal.tex constant.numeric.value.tex math-characters: - match: '[A-Za-z]+' diff --git a/LaTeX/tests/syntax_test_tex.tex b/LaTeX/tests/syntax_test_tex.tex index e8aaa31f65..2cf6587c2a 100644 --- a/LaTeX/tests/syntax_test_tex.tex +++ b/LaTeX/tests/syntax_test_tex.tex @@ -835,6 +835,38 @@ %^^ meta.environment.math.block.dollar.tex %^ string.other.math.tex punctuation.definition.string.begin.tex + 0 1 2 3 4 5 6 7 8 9 10 11 +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex + + 1.0 +%^ - meta.number - constant +% ^^^ meta.number.float.decimal.tex constant.numeric.value.tex +% ^ punctuation.separator.decimal.tex +% ^ - meta.number - constant + + 0.2 +%^ - meta.number - constant +% ^^^ meta.number.float.decimal.tex constant.numeric.value.tex +% ^ punctuation.separator.decimal.tex +% ^ - meta.number - constant + + .4 +%^ - meta.number - constant +% ^^ meta.number.float.decimal.tex constant.numeric.value.tex +% ^ punctuation.separator.decimal.tex +% ^ - meta.number - constant + c = a + b - d * f / g! % ^ variable.other.math.tex % ^ keyword.operator.assignment.tex @@ -868,5 +900,6 @@ % ^ punctuation.separator.indice.tex % ^ variable.other.math.tex % ^ keyword.operator.arithmetic.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex $$ \ No newline at end of file diff --git a/Markdown/tests/syntax_test_markdown.md b/Markdown/tests/syntax_test_markdown.md index eb5e381df6..6a45725083 100644 --- a/Markdown/tests/syntax_test_markdown.md +++ b/Markdown/tests/syntax_test_markdown.md @@ -8039,20 +8039,20 @@ foo = 1 + 2 * \sqrt{a^2+b^2} | <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar variable.other.math |^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar | ^ keyword.operator.assignment -| ^ constant.numeric.math +| ^ constant.numeric.value | ^ keyword.operator.arithmetic -| ^ constant.numeric.math +| ^ constant.numeric.value | ^ keyword.operator.arithmetic | ^^^^^ support.function.math | ^^^^^^^^^ meta.group.brace | ^ punctuation.definition.group.brace.begin | ^ variable.other.math | ^ keyword.operator.arithmetic -| ^ constant.numeric.math +| ^ constant.numeric.value | ^ keyword.operator.arithmetic | ^ variable.other.math | ^ keyword.operator.arithmetic -| ^ constant.numeric.math +| ^ constant.numeric.value | ^ punctuation.definition.group.brace.end $$ | <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex punctuation.definition.math.end.latex @@ -8170,9 +8170,9 @@ Math $1+1$ setext heading This is math $1+1$ expression, but $ 1+1 $ ,$ 1+1$, $1+1 $ and 1+1$ or $1+1 are not. | ^^^^^ meta.paragraph.markdown markup.math.inline.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar.latex | ^ punctuation.definition.math.begin.latex -| ^ constant.numeric.math.tex +| ^ constant.numeric.value.tex | ^ keyword.operator.arithmetic.tex -| ^ constant.numeric.math.tex +| ^ constant.numeric.value.tex | ^ punctuation.definition.math.end.latex | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup.math From cf2abb21e21cda0c484f5ea951b0938ffc8c59d0 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Dec 2022 19:34:06 +0100 Subject: [PATCH 35/46] [TeX] rename math variables context --- LaTeX/TeX.sublime-syntax | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index be9311c94e..938d34a99d 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -558,7 +558,7 @@ contexts: - include: boxes - include: math-commands - include: math-operators - - include: math-characters + - include: math-variables - include: math-numbers - include: general-constants @@ -671,7 +671,7 @@ contexts: - match: \d+ scope: meta.number.integer.decimal.tex constant.numeric.value.tex - math-characters: + math-variables: - match: '[A-Za-z]+' scope: variable.other.math.tex From 88b797935a822b3895577dfaa33ea65d760a7d86 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Dec 2022 19:41:13 +0100 Subject: [PATCH 36/46] [TeX] Apply scope naming guidelines to math brackets --- LaTeX/TeX.sublime-syntax | 20 ++++++++++++-------- LaTeX/tests/syntax_test_tex.tex | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 938d34a99d..6e1e4edee8 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -654,14 +654,18 @@ contexts: - include: math-content math-brackets: - - match: '[\(\)]' - scope: constant.character.parenthesis.tex - - match: '[\[\]]' - scope: constant.character.bracket.tex - - match: (\\)[\{\}] - scope: constant.character.brace.escape.tex - captures: - 1: punctuation.definition.backslash.brace.escape.tex + - match: \( + scope: punctuation.section.parens.begin.tex + - match: \) + scope: punctuation.section.parens.end.tex + - match: \[ + scope: punctuation.section.brackets.begin.tex + - match: \] + scope: punctuation.section.brackets.end.tex + - match: (\\)[{}] + scope: constant.character.escape.tex + captures: + 1: punctuation.definition.escape.tex math-numbers: - match: \d*(\.)\d+ diff --git a/LaTeX/tests/syntax_test_tex.tex b/LaTeX/tests/syntax_test_tex.tex index 2cf6587c2a..75be68f364 100644 --- a/LaTeX/tests/syntax_test_tex.tex +++ b/LaTeX/tests/syntax_test_tex.tex @@ -867,6 +867,21 @@ % ^ punctuation.separator.decimal.tex % ^ - meta.number - constant + () +% ^ punctuation.section.parens.begin.tex +% ^ punctuation.section.parens.end.tex + + [] +% ^ punctuation.section.brackets.begin.tex +% ^ punctuation.section.brackets.end.tex + + \{ \} +%^ - constant +% ^^ constant.character.escape.tex +% ^ - constant +% ^^ constant.character.escape.tex +% ^ - constant + c = a + b - d * f / g! % ^ variable.other.math.tex % ^ keyword.operator.assignment.tex From 561fb528daa6302335fbab316a02e9cfe8c704e7 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Dec 2022 19:52:01 +0100 Subject: [PATCH 37/46] [LaTeX] Enhance math syntax tests --- LaTeX/tests/syntax_test_latex.tex | 72 ++++++++++++++++++++++--------- LaTeX/tests/syntax_test_tex.tex | 29 +++++++++++++ 2 files changed, 81 insertions(+), 20 deletions(-) diff --git a/LaTeX/tests/syntax_test_latex.tex b/LaTeX/tests/syntax_test_latex.tex index 4a3fd3a047..7acf72da1a 100644 --- a/LaTeX/tests/syntax_test_latex.tex +++ b/LaTeX/tests/syntax_test_latex.tex @@ -505,42 +505,74 @@ \subsubsection{name} % ^ punctuation.definition.group.brace.end -% MATH +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Math +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Check we have always a shared environment $f(x) = x^2$ -% ^ meta.environment.math.inline +% <- meta.environment.math.inline.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex +%^^^^^^^^^^ meta.environment.math.inline.dollar.tex - string +% ^ meta.environment.math.inline.dollar.tex string.other.math.tex punctuation.definition.string.end.tex +% ^ - meta.environment.math + $$f(x) = x^2$$ -% ^ meta.environment.math.block +% <- meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex +%^ meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex +% ^^^^^^^^^^ meta.environment.math.block.dollar.tex - string +% ^^ meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.end.tex +% ^ - meta.environment.math + \(f(x) = x^2\) -% ^ meta.environment.math.inline +% <- meta.environment.math.inline.paren.latex string.other.math.latex punctuation.definition.string.begin.latex +%^ meta.environment.math.inline.paren.latex string.other.math.latex punctuation.definition.string.begin.latex +% ^^^^^^^^^^ meta.environment.math.inline.paren.latex - string +% ^^ meta.environment.math.inline.paren.latex string.other.math.latex punctuation.definition.string.end.latex +% ^ - meta.environment.math + \[ +% <- meta.environment.math.block.bracket.latex string.other.math.latex punctuation.definition.string.begin.latex +%^ meta.environment.math.block.bracket.latex string.other.math.latex punctuation.definition.string.begin.latex +% ^ meta.environment.math.block.bracket.latex - string f(x) = x^2 \text{ $f$ is a function} -% ^ meta.environment.math.block +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.environment.math.block.bracket.latex \] +% <- meta.environment.math.block.bracket.latex string.other.math.latex punctuation.definition.string.end.latex +%^ meta.environment.math.block.bracket.latex string.other.math.latex punctuation.definition.string.end.latex +% ^ - meta.environment.math + \ensuremath{f(x) = x^2} -% ^ meta.environment.math.inline +% <- meta.function.ensuremath.latex support.function.ensuremath.latex punctuation.definition.backslash.latex +%^^^^^^^^^^ meta.function.ensuremath.latex +% ^ meta.function.ensuremath.latex - meta.environment.math +% ^^^^^^^^^^ meta.function.ensuremath.latex meta.environment.math.inline.ensuremath.latex +% ^ meta.function.ensuremath.latex - meta.environment.math +%^^^^^^^^^^ support.function.ensuremath.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ 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 +% <- meta.environment.math.block.be.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 +% ^ punctuation.definition.group.brace.begin.tex +% ^^^^^^^^ variable.parameter.function.latex +% ^ punctuation.definition.group.brace.end.tex -$\iota$ -% ^ keyword.other.math.greek.tex - -$\Iota$ -% ^ support.function.math.tex - -$\alpha _$ -% ^ keyword.other.math.greek.tex -% ^ punctuation.separator.indice.tex -$\alpha_$ -% ^ keyword.other.math.greek.tex -% ^ punctuation.separator.indice.tex +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Boxes +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Boxes \mbox{text}{text} % ^ meta.function.box.latex % ^ -meta.function.box.latex diff --git a/LaTeX/tests/syntax_test_tex.tex b/LaTeX/tests/syntax_test_tex.tex index 75be68f364..7de8340053 100644 --- a/LaTeX/tests/syntax_test_tex.tex +++ b/LaTeX/tests/syntax_test_tex.tex @@ -830,6 +830,35 @@ % Math %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +$f(x) = x^2$ +% <- meta.environment.math.inline.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex +%^^^^^^^^^^ meta.environment.math.inline.dollar.tex - string +% ^ meta.environment.math.inline.dollar.tex string.other.math.tex punctuation.definition.string.end.tex + +$$f(x) = x^2$$ +% <- meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex +%^ meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex +% ^^^^^^^^^^ meta.environment.math.block.dollar.tex - string +% ^^ meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.end.tex + +$\iota$ +%^^^^^ keyword.other.math.greek.tex +%^ punctuation.definition.backslash.tex + +$\Iota$ +%^^^^^ support.function.math.tex - keyword.other +%^ punctuation.definition.backslash.tex + +$\alpha _$ +%^^^^^^ keyword.other.math.greek.tex +%^ punctuation.definition.backslash.tex +% ^ punctuation.separator.indice.tex + +$\alpha_$ +%^^^^^^ keyword.other.math.greek.tex +%^ punctuation.definition.backslash.tex +% ^ punctuation.separator.indice.tex + $$ % <- meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex %^^ meta.environment.math.block.dollar.tex From e6cb8a79ea1ad2331e91c6de88b38675ea352ac4 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 1 Dec 2022 20:36:49 +0100 Subject: [PATCH 38/46] [LaTeX] Fix register id scope --- LaTeX/TeX.sublime-syntax | 2 +- LaTeX/tests/syntax_test_tex.tex | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 6e1e4edee8..8f8a2cb72e 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -357,7 +357,7 @@ contexts: register-definition-identifier: - meta_scope: meta.register.tex - match: \d+ - scope: meta.number.integer.decimal constant.numeric.value.tex + scope: meta.number.integer.decimal.tex constant.numeric.value.tex set: - tex-dimension-value - tex-assignment diff --git a/LaTeX/tests/syntax_test_tex.tex b/LaTeX/tests/syntax_test_tex.tex index 7de8340053..6f88de1b07 100644 --- a/LaTeX/tests/syntax_test_tex.tex +++ b/LaTeX/tests/syntax_test_tex.tex @@ -167,6 +167,7 @@ %^^^ keyword.declaration.function.tex storage.modifier.definition.tex % ^^^^^ entity.name.definition.tex % ^ punctuation.definition.group.brace.begin.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex % ^^ variable.parameter.tex % ^^^^^^ keyword.other.math.greek.tex @@ -226,12 +227,12 @@ \muskip5 %^^^^^^ storage.type.tex %^^^^^^^ meta.register.tex -% ^ meta.number.integer.decimal constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex \box 60 %^^^ storage.type.tex %^^^^^^ meta.register.tex -% ^^ meta.number.integer.decimal constant.numeric.value.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex \skip5 10 %^^^^^ meta.register.tex From 3fa906676af976b501ad0d4dd012b8594e10626f Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Wed, 7 Dec 2022 12:05:53 -0600 Subject: [PATCH 39/46] fixed a scoping bug (#3609) --- LaTeX/TeX.sublime-syntax | 2 +- LaTeX/tests/syntax_test_tex.tex | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 8f8a2cb72e..c2a4169d83 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -595,7 +595,7 @@ contexts: - match: (\\){{largeops}}{{endcs}} scope: keyword.other.math.large-operator.tex captures: - 1: punctuation.definition.backslash.texpunctuation.definition.backslash.tex + 1: punctuation.definition.backslash.tex math-binops: - match: (\\){{binops}}{{endcs}} diff --git a/LaTeX/tests/syntax_test_tex.tex b/LaTeX/tests/syntax_test_tex.tex index 6f88de1b07..fbb42b42f5 100644 --- a/LaTeX/tests/syntax_test_tex.tex +++ b/LaTeX/tests/syntax_test_tex.tex @@ -947,4 +947,9 @@ % ^ keyword.operator.arithmetic.tex % ^ meta.number.integer.decimal.tex constant.numeric.value.tex -$$ \ No newline at end of file +$$ + + $\sum_{i=1}^{1} i^2$ +%^^^^^^^^^^^^^^^^^^^^ meta.environment.math.inline.dollar. +% ^ punctuation.definition.backslash.tex +% ^^^^ keyword.other.math.large-operator.tex From c7385293acdcccc02ddbf456ab935bd43c74dcf6 Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Thu, 8 Dec 2022 02:27:46 -0600 Subject: [PATCH 40/46] [TeX] Improved integer handling (#3604) This commit does a first step at generalizing and unifying the handling of integers. It provides a general context that matches decimal, octal, hexadecimal, and "based on character" integers. I've not yet used this for the definition of dimensions, because here we currently enter different scopes based on whether we've matched an integer or a float. The syntax specified here assumes that everything will be written on one line. It also does not handle the case of multiple leading signs. --- LaTeX/TeX.sublime-syntax | 69 ++++++++++++++++++++------------- LaTeX/tests/syntax_test_tex.tex | 40 +++++++++++++++++++ 2 files changed, 82 insertions(+), 27 deletions(-) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index c2a4169d83..bd6c2facba 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -191,7 +191,7 @@ contexts: push: - character-code-meta - character-code-value - - character-code-assignment + - tex-assignment - character-code-number character-code-meta: @@ -200,16 +200,7 @@ contexts: - include: immediately-pop character-code-number: - - match: (`)(\\)?({{charbycode}}|.) - scope: meta.number.integer.tex - captures: - 1: keyword.operator.tex - 2: punctuation.definition.backslash.tex - 3: constant.character.tex - pop: 1 - - match: \d+ - scope: meta.number.integer.decimal.tex constant.numeric.value.tex - set: character-code-assignment + - include: tex-simple-integer - include: else-pop - include: paragraph-pop @@ -221,12 +212,7 @@ contexts: - include: paragraph-pop character-code-value: - - match: \d+ - scope: meta.number.integer.decimal.tex constant.numeric.value.tex - pop: 1 - - match: '"{{anyhexdigit}}+' - scope: meta.number.integer.hexadecimal.tex constant.numeric.value.tex - pop: 1 + - include: tex-simple-integer - include: else-pop - include: paragraph-pop @@ -352,25 +338,54 @@ contexts: captures: 1: punctuation.definition.backslash.tex 2: storage.type.tex - push: register-definition-identifier + push: + - tex-dimension-value + - tex-assignment + - register-definition-identifier register-definition-identifier: - meta_scope: meta.register.tex - - match: \d+ - scope: meta.number.integer.decimal.tex constant.numeric.value.tex - set: - - tex-dimension-value - - tex-assignment - - match: (\\){{letter}}+ + - match: (\\){{cmdname}} scope: support.function.general.tex captures: 1: punctuation.definition.backslash.tex - set: - - tex-dimension-value - - tex-assignment + pop: 1 + - include: tex-simple-integer - include: paragraph-pop - include: else-pop +###[ NUMBERS ]################################################################## + + # These match integers/floats that are written in a simple form, i.e. not extending + # across lines + # we are also not handling the case where there are multiple signs + + tex-simple-integer: + - match: ([+-]?)\s*\d+ + scope: meta.number.integer.decimal.tex constant.numeric.value.tex + captures: + 1: keyword.operator.arithmetic.tex + pop: 1 + - match: ([+-]?)\s*"{{uchexdigit}}+ + scope: meta.number.integer.hexadecimal.tex constant.numeric.value.tex + captures: + 1: keyword.operator.arithmetic.tex + pop: 1 + - match: ([+-]?)\s*'[0-7]+ + scope: meta.number.integer.octal.tex constant.numeric.value.tex + captures: + 1: keyword.operator.arithmetic.tex + pop: 1 + - match: ([+-]?)\s*(`)(\\)?({{charbycode}}|.) + scope: meta.number.integer.tex constant.numeric.value.tex + captures: + 1: keyword.operator.arithmetic.tex + 2: keyword.operator.tex + 3: punctuation.definition.backslash.tex + 4: constant.character.tex + pop: 1 + + ###[ DIMENSIONS ]############################################################### tex-assignment: diff --git a/LaTeX/tests/syntax_test_tex.tex b/LaTeX/tests/syntax_test_tex.tex index fbb42b42f5..f5a23bc1e1 100644 --- a/LaTeX/tests/syntax_test_tex.tex +++ b/LaTeX/tests/syntax_test_tex.tex @@ -237,6 +237,32 @@ \skip5 10 %^^^^^ meta.register.tex % ^^ - meta.register.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex + +\count"AB 10 +%^^^^^^^^ meta.register.tex +% ^^ - meta.register.tex +% ^^^ meta.number.integer.hexadecimal.tex constant.numeric.value.tex + + +% tricky case: 9 is not an octal digit +\dimen'569 +%^^^^^^^^ meta.register.tex +% ^ - meta.register.tex +% ^^^ meta.number.integer.octal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex + +% tricky case: 9 is not an octal digit +\dimen`\a +%^^^^^^^^ meta.register.tex +% ^ - meta.register.tex +% ^^^ meta.number.integer.tex constant.numeric.value.tex + +% tricky case: 9 is not an octal digit +\dimen`16 +%^^^^^^^ meta.register.tex +% ^ - meta.register.tex +% ^^ meta.number.integer.tex constant.numeric.value.tex \counting %^^^^^^^^ - meta.register.tex @@ -342,6 +368,20 @@ % ^ keyword.operator.assignment.tex % ^^^^^^^ meta.number.integer.hexadecimal.tex constant.numeric.value.tex +\lccode65='123 +%^^^^^^^^^^^^^ meta.function.character-code.tex +%^^^^^^ keyword.control.character-code.tex +% ^^ meta.number.integer.decimal.tex +% ^ keyword.operator.assignment.tex +% ^^^ meta.number.integer.octal.tex constant.numeric.value.tex + +\lccode"AB=`\a +%^^^^^^^^^^^^^ meta.function.character-code.tex +%^^^^^^ keyword.control.character-code.tex +% ^^^ meta.number.integer.hexadecimal.tex +% ^ keyword.operator.assignment.tex +% ^^^ meta.number.integer.tex constant.numeric.value.tex + % some other assignments % skip the = sign From 43b7f26b816d871d532cdb6caf60c35a417e1660 Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Wed, 1 Feb 2023 19:33:13 +0100 Subject: [PATCH 41/46] [LaTeX] Text formatting (#3618) This commit reworks the handling of text formatting commands in LaTeX. In particular, in cases where there are commands within formatted text, e.g. `\textbf{\TeX in bold}`, we no longer format the command names. One challenge is that there are several font properties that can be changed independently: - Font family (roman, sans serif, typewriter), - font weight (bold, medium, (possibly) light), - and font shape (upright, italic, slanted, small-caps). Most of these do not have any corresponding `markup` scopes and highlighting rules (at least with default color schemes). At this point, only a subset of nesting of these properties is actually handled: Bold/italic combination, and nested \emph emphasize, as well as ensuring that all the commands that do not change one of these properties still typeset their arguments according to the outer command. No provision has been made for any form of triple-nesting, i.e. `\textbf{\textit{\textup{a}}}` would not result in bold `a` right now. Not sure if supporting this would be worth it. Finally, there is also an \underline command that could be combined with bold/italic. So far, I've not included this, because in LaTeX underline comes with some caveats, so that package commands like `\uline` or `\ul` are often recommended. --- LaTeX/LaTeX.sublime-syntax | 417 ++++++++++++++++++++++++++---- LaTeX/tests/syntax_test_latex.tex | 277 +++++++++++++++++++- 2 files changed, 630 insertions(+), 64 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index e9a6ad0670..b89483384b 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -15,6 +15,9 @@ first_line_match: |- ^ \s* \%+ .*? -\*- .*? \blatex\b .*? -\*- # editorconfig ) +variables: + simpletext: '[^\\{}%$~&#_^]*' + contexts: main: @@ -702,75 +705,387 @@ contexts: scope: punctuation.definition.verb.latex pop: true +###[ FONTS ]#################################################################### + + # https://en.wikibooks.org/wiki/LaTeX/Fonts#Font_styles text-decorators: - - match: ((\\)emph)(\{) + - include: text-normal-select-font-family + - include: text-normal-select-font-shape + - include: text-normal-select-font-weight + + - match: (\\)textnormal{{endcs}} + scope: support.function.textnormal.latex captures: - 1: support.function.emph.latex - 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.tex + 1: punctuation.definition.backslash.latex push: - - meta_scope: meta.function.emph.latex - - meta_content_scope: markup.italic.emph.latex - - include: brace-group-end - - include: main - - match: ((\\)textit)(\{) + - textnormal-meta + - text-normal-body + - expect-text-markup-open-brace + + - match: ((\\)text)(\{) captures: - 1: support.function.textit.latex + 1: support.function.text.latex 2: punctuation.definition.backslash.latex 3: punctuation.definition.group.brace.begin.tex - push: - - meta_scope: meta.function.textit.latex - - meta_content_scope: markup.italic.textit.latex - - include: brace-group-end - - include: main - - match: ((\\)textbf)(\{) + push: text-body + + - match: ((\\)underline)(\{) captures: - 1: support.function.textbf.latex + 1: support.function.text.latex 2: punctuation.definition.backslash.latex 3: punctuation.definition.group.brace.begin.tex + push: text-underline-body + + text-body: + - meta_scope: meta.function.text.latex + - include: brace-group-end + - include: main + + text-underline-body: + - meta_scope: meta.function.underline.latex + - meta_content_scope: markup.underline.other.latex + - include: brace-group-end + - include: main + + text-normal-select-font-family: + - match: (\\)textrm{{endcs}} + scope: support.function.textrm.latex + captures: + 1: punctuation.definition.backslash.latex push: - - meta_scope: meta.function.textbf.latex - - meta_content_scope: markup.bold.textbf.latex - - include: brace-group-end - - include: main - - match: ((\\)texttt)(\{) + - textrm-meta + - text-normal-body + - expect-text-markup-open-brace + - match: (\\)textsf{{endcs}} + scope: support.function.textsf.latex captures: - 1: support.function.texttt.latex - 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.tex + 1: punctuation.definition.backslash.latex push: - - meta_scope: meta.function.texttt.latex - - meta_content_scope: markup.raw.texttt.latex - - include: brace-group-end - - include: main - - match: ((\\)textsl)(\{) + - textsf-meta + - text-normal-body + - expect-text-markup-open-brace + - match: (\\)texttt{{endcs}} + scope: support.function.texttt.latex captures: - 1: support.function.textsl.latex - 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.tex + 1: punctuation.definition.backslash.latex push: - - meta_scope: meta.function.textsl.latex - - meta_content_scope: markup.italic.textsl.latex - - include: brace-group-end - - include: main - - match: ((\\)text)(\{) + - texttt-meta + - texttt-body + - expect-text-markup-open-brace + + text-normal-select-font-shape: + - match: (\\)textup{{endcs}} + scope: support.function.textup.latex captures: - 1: support.function.text.latex - 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.tex + 1: punctuation.definition.backslash.latex push: - - include: brace-group-end - - include: main - - match: ((\\)underline)(\{) + - textup-meta + - text-normal-body + - expect-text-markup-open-brace + - match: (\\)textit{{endcs}} + scope: support.function.textit.latex captures: - 1: support.function.text.latex - 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.tex + 1: punctuation.definition.backslash.latex push: - - meta_scope: meta.function.underline.latex - - meta_content_scope: markup.underline.underline.latex - - include: brace-group-end - - include: main + - textit-meta + - text-italic-body + - expect-text-markup-open-brace + - match: (\\)textsl{{endcs}} + scope: support.function.textsl.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textsl-meta + - text-italic-body + - expect-text-markup-open-brace + - match: (\\)textsc{{endcs}} + scope: support.function.textsc.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textsc-meta + - texttt-body + - expect-text-markup-open-brace + - match: (\\)emph{{endcs}} + scope: support.function.emph.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - emph-meta + - text-italic-body + - expect-text-markup-open-brace + + text-normal-select-font-weight: + - match: (\\)textbf{{endcs}} + scope: support.function.textbf.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textbf-meta + - text-bold-body + - expect-text-markup-open-brace + - match: (\\)textmd{{endcs}} + scope: support.function.textmd.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textmd-meta + - text-normal-body + - expect-text-markup-open-brace + - match: (\\)textlf{{endcs}} + scope: support.function.textlf.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textlf-meta + - text-normal-body + - expect-text-markup-open-brace + + text-normal-body: + - include: brace-group-end + - include: main + + text-bold-body: + - include: brace-group-end + - include: text-bold-select-font-family + - include: text-bold-select-font-shape + - match: \{ + scope: punctuation.definition.group.brace.begin.tex + push: text-bold-brace-group-body + - include: main + - match: .{{simpletext}} + scope: markup.bold.latex + + text-bold-select-font-family: + - match: (\\)textrm{{endcs}} + scope: support.function.textrm.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textrm-meta + - text-bold-body + - expect-text-markup-open-brace + - match: (\\)textsf{{endcs}} + scope: support.function.textsf.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textsf-meta + - text-bold-body + - expect-text-markup-open-brace + - match: (\\)texttt{{endcs}} + scope: support.function.texttt.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - texttt-meta + - texttt-body + - expect-text-markup-open-brace + + text-bold-select-font-shape: + - match: (\\)textup{{endcs}} + scope: support.function.textup.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textup-meta + - text-bold-body + - expect-text-markup-open-brace + - match: (\\)textit{{endcs}} + scope: support.function.textit.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textit-meta + - text-it-and-bf-body + - expect-text-markup-open-brace + - match: (\\)textsl{{endcs}} + scope: support.function.textsl.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textsl-meta + - text-it-and-bf-body + - expect-text-markup-open-brace + - match: (\\)textsc{{endcs}} + scope: support.function.textsc.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textsc-meta + - texttt-body + - expect-text-markup-open-brace + - match: (\\)emph{{endcs}} + scope: support.function.emph.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - emph-meta + - text-it-and-bf-body + - expect-text-markup-open-brace + + text-bold-brace-group-body: + - meta_scope: meta.group.brace.tex + - include: brace-group-end + - include: text-bold-body + + text-italic-body: + - include: brace-group-end + - include: text-italic-select-font-family + - include: text-italic-select-font-weight + - match: \{ + scope: punctuation.definition.group.brace.begin.tex + push: text-italic-brace-group-body + # special support for nested \emph-asis + - match: (\\)emph{{endcs}} + scope: support.function.emph.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - emph-meta + - text-normal-body + - brace-group-begin + - include: main + - match: .{{simpletext}} + scope: markup.italic.latex + + text-italic-select-font-family: + - match: (\\)textrm{{endcs}} + scope: support.function.textrm.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textrm-meta + - text-italic-body + - expect-text-markup-open-brace + - match: (\\)textsf{{endcs}} + scope: support.function.textsf.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textsf-meta + - text-italic-body + - expect-text-markup-open-brace + - match: (\\)texttt{{endcs}} + scope: support.function.texttt.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - texttt-meta + - texttt-body + - expect-text-markup-open-brace + + text-italic-select-font-weight: + - match: (\\)textbf{{endcs}} + scope: support.function.textbf.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textbf-meta + - text-it-and-bf-body + - expect-text-markup-open-brace + - match: (\\)textmd{{endcs}} + scope: support.function.textmd.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textmd-meta + - text-italic-body + - expect-text-markup-open-brace + - match: (\\)textlf{{endcs}} + scope: support.function.textlf.latex + captures: + 1: punctuation.definition.backslash.latex + push: + - textlf-meta + - text-italic-body + - expect-text-markup-open-brace + + text-italic-brace-group-body: + - meta_scope: meta.group.brace.tex + - include: brace-group-end + - include: text-italic-body + + text-it-and-bf-body: + - include: brace-group-end + - include: main + - match: .{{simpletext}} + scope: markup.bold.latex markup.italic.latex + + texttt-body: + - include: brace-group-end + - include: main + - match: .{{simpletext}} + scope: markup.raw.inline.latex + + # utility that waits for the brace, and pops the three contexts + # we push for each \text... command otherwise + expect-text-markup-open-brace: + - match: \{ + scope: punctuation.definition.group.brace.begin.tex + pop: true + - match: (?=\S) + pop: 3 + + textnormal-meta: + - meta_include_prototype: false + - meta_scope: meta.function.textnormal.latex + - include: immediately-pop + + textbf-meta: + - meta_include_prototype: false + - meta_scope: meta.function.textbf.latex + - include: immediately-pop + + textmd-meta: + - meta_include_prototype: false + - meta_scope: meta.function.textmd.latex + - include: immediately-pop + + textlf-meta: + - meta_include_prototype: false + - meta_scope: meta.function.textlf.latex + - include: immediately-pop + + textsf-meta: + - meta_include_prototype: false + - meta_scope: meta.function.textsf.latex + - include: immediately-pop + + textup-meta: + - meta_include_prototype: false + - meta_scope: meta.function.textup.latex + - include: immediately-pop + + textsc-meta: + - meta_include_prototype: false + - meta_scope: meta.function.textsc.latex + - include: immediately-pop + + textrm-meta: + - meta_include_prototype: false + - meta_scope: meta.function.textrm.latex + - include: immediately-pop + + textit-meta: + - meta_include_prototype: false + - meta_scope: meta.function.textit.latex + - include: immediately-pop + + texttt-meta: + - meta_include_prototype: false + - meta_scope: meta.function.texttt.latex + - include: immediately-pop + + textsl-meta: + - meta_include_prototype: false + - meta_scope: meta.function.textsl.latex + - include: immediately-pop + + emph-meta: + - meta_include_prototype: false + - meta_scope: meta.function.emph.latex + - include: immediately-pop footnote: - match: ((\\)footnote(?:text)?)\b diff --git a/LaTeX/tests/syntax_test_latex.tex b/LaTeX/tests/syntax_test_latex.tex index 7acf72da1a..f166234c57 100644 --- a/LaTeX/tests/syntax_test_latex.tex +++ b/LaTeX/tests/syntax_test_latex.tex @@ -381,23 +381,274 @@ \subsubsection{name} % MARKUP COMMANDS +\textnormal{text} +%^^^^^^^^^^^^^^^^ meta.function.textnormal.latex +%^^^^^^^^^^ support.function.textnormal.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex + +\textrm{text} +%^^^^^^^^^^^^ meta.function.textrm.latex +%^^^^^^ support.function.textrm.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex + +\textsf{text} +%^^^^^^^^^^^^ meta.function.textsf.latex +%^^^^^^ support.function.textsf.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex + \emph{text} -% ^ markup.italic.emph.latex +%^^^^^^^^^^ meta.function.emph.latex +%^^^^ support.function.emph.latex +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^^^^ markup.italic.latex +% ^ punctuation.definition.group.brace.end.tex - markup + +\emph{text \emph{nested} emph} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.emph.latex +%^^^^ support.function.emph.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^^^^^ markup.italic.latex +% ^^^^^^^^^^^^^ meta.function.emph.latex - markup +% ^^^^^ support.function.emph.latex +% ^ punctuation.definition.backslash.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ punctuation.definition.group.brace.end.tex +% ^^^^^ markup.italic.latex +% ^ punctuation.definition.group.brace.end.tex + +\textbf{a} +%^^^^^^^^^ meta.function.textbf.latex +%^^^^^^ support.function.textbf.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^ markup.bold.latex +% ^ punctuation.definition.group.brace.end.tex + \textbf{text} -% ^ markup.bold.textbf.latex -\textit{text} -% ^ markup.italic.textit.latex -\texttt{text} -% ^ markup.raw.texttt.latex -\textsl{text} -% ^ markup.italic.textsl.latex -\textbf{\textit{text}} -% ^ markup.bold.textbf.latex markup.italic.textit.latex -\textit{\textbf{text}} -% ^ markup.italic.textit.latex markup.bold.textbf.latex +%^^^^^^^^^^^^ meta.function.textbf.latex +%^^^^^^ support.function.textbf.latex +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^^^^ markup.bold.latex +% ^ punctuation.definition.group.brace.end.tex - markup + +\textbf{text \command and text} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.textbf.latex +% ^^^^ markup.bold.latex +% ^^^^^^^^ support.function.general.latex - markup +% ^^^^^^^^ markup.bold.latex + + +\textit{text@"special"} +%^^^^^^^^^^^^^^^^^^^^^^ meta.function.textit.latex +%^^^^^^ support.function.textit.latex +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^^^^^^^^^^^^^^ markup.italic.latex +% ^ punctuation.definition.group.brace.end.tex - markup + +\texttt{text 123} +%^^^^^^^^^^^^^^^^ meta.function.texttt.latex +%^^^^^^ support.function.texttt.latex +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^^^^^^^^ markup.raw.inline.latex +% ^ punctuation.definition.group.brace.end.tex - markup + +\textsc{smallcaps} +%^^^^^^^^^^^^^^^^^ meta.function.textsc.latex +%^^^^^^ support.function.textsc.latex +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^^^^^^^^^ markup.raw.inline.latex +% ^ punctuation.definition.group.brace.end.tex - markup + +\textup{upright} +%^^^^^^^^^^^^^^^ meta.function.textup.latex +%^^^^^^ support.function.textup.latex +% ^^^^^^^ - markup + +\textlf{upright} +%^^^^^^^^^^^^^^^ meta.function.textlf.latex +%^^^^^^ support.function.textlf.latex +% ^^^^^^^ - markup + +\textmd{upright} +%^^^^^^^^^^^^^^^ meta.function.textmd.latex +%^^^^^^ support.function.textmd.latex +% ^^^^^^^ - markup + +%% combinations + +\textbf{text \textrm{roman font}} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.textbf.latex +%^^^^^^ support.function.textbf.latex +% ^^^^^ markup.bold.latex +% ^^^^^^^^^^^^^^^^^^^ meta.function.textrm.latex +% ^^^^^^^ support.function.textrm.latex +% ^^^^^^^^^^ markup.bold.latex + +\textbf{\textit{text} just bold \textsl{slanted}} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.textbf.latex +% ^^^^^^^^^^^^^ meta.function.textit.latex +% ^^^^^^^^^^^^^^^^ meta.function.textsl.latex +%^^^^^^ support.function.textbf.latex - markup +% ^^^^^^^ support.function.textit.latex - markup +% ^^^^^^^ support.function.textsl.latex - markup +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^ punctuation.definition.backslash.latex - markup +% ^^^^ markup.bold.latex markup.italic.latex +% ^^^^^^^^^^^ markup.bold.latex +% ^^^^^^^ markup.bold.latex markup.italic.latex +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^ punctuation.definition.group.brace.end.tex - markup +% ^ punctuation.definition.backslash.latex - markup +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^ punctuation.definition.group.brace.end.tex - markup +% ^ punctuation.definition.group.brace.end.tex - markup + + +\textbf{bold \textnormal{not bold}} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.textbf.latex +%^^^^^^ support.function.textbf.latex +% ^^^^^^^^^^^ support.function.textnormal.latex +% ^^^^^ markup.bold.latex +% ^^^^^^^^^^^^^^^^^^^^^ meta.function.textnormal.latex - markup + + +\textbf{bold \textsf{still bold}} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.textbf.latex +%^^^^^^ support.function.textbf.latex +% ^^^^^^^ support.function.textsf.latex +% ^^^^^ markup.bold.latex +% ^^^^^^^^^^^^^^^^^^^ meta.function.textsf.latex +% ^^^^^^^^^^ markup.bold.latex + +\textbf{bold \textup{still bold}} +% ^^^^^^^^^^ markup.bold.latex + +\textbf{bold \textmd{not bold}} +% ^^^^^^^^ - markup.bold.latex + +\textbf{bold \textlf{not bold}} +% ^^^^^^^^ - markup.bold.latex + +\textbf{bold \textbf{still bold}} +% ^^^^^^^^^^ markup.bold.latex + +\textbf{bold \texttt{not bold}} +% ^^^^^^^^ markup.raw.inline.latex + +\textbf{bold \textsc{not bold}} +% ^^^^^^^^ markup.raw.inline.latex + +\textbf{bold \emph{and italic}} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.textbf.latex +%^^^^^^ support.function.textbf.latex - markup +% ^^^^^ markup.bold.latex +% ^^^^^ support.function.emph.latex - markup +% ^^^^^^^^^^^^^^^^^ meta.function.emph.latex +% ^^^^^^^^^^ markup.bold.latex markup.italic.latex + +\textbf{text {in braces} still bold} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.textbf.latex +% ^^^^^^^^^ markup.bold.latex +% ^^^^^^^^^^ markup.bold.latex + +\textit{italic \textbf{bold} italic} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.textit.latex +%^^^^^^ support.function.textit.latex - markup +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^^^^^^^ markup.italic.latex +% ^^^^^^^^^^^^^ meta.function.textbf.latex +% ^^^^^^^ support.function.textbf.latex - markup +% ^ punctuation.definition.backslash.latex - markup +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^^^^ markup.bold.latex markup.italic.latex +% ^ punctuation.definition.group.brace.end.tex - markup +% ^^^^^^^ markup.italic.latex +% ^ punctuation.definition.group.brace.end.tex - markup + +\textit{italic \textup{upright}} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.textit.latex +%^^^^^^ support.function.textit.latex +% ^^^^^^^ markup.italic.latex +% ^^^^^^^^^^^^^^^^ meta.function.textup.latex +% ^^^^^^^ support.function.textup.latex +% ^^^^^^^ - markup + +\textsl{text \textbf{bold} slanted} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.textsl.latex +%^^^^^^ support.function.textsl.latex +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^^^^^ markup.italic.latex +% ^^^^ markup.bold.latex markup.italic.latex +% ^ punctuation.definition.group.brace.end.tex - markup +% ^^^^^^^^ markup.italic.latex - markup.bold +% ^ punctuation.definition.group.brace.end.tex - markup + +\textit{italic \textmd{upright}} +% ^^^^^^^ markup.italic.latex + +\textit{italic \emph{upright}} +% ^^^^^^^ - markup.italic.latex + +\textit{italic \textsf{italic}} +% ^^^^^^ markup.italic.latex + +\textit{italic \textlf{italic}} +% ^^^^^^ markup.italic.latex + +\textit{italic \textrm{italic}} +% ^^^^^^ markup.italic.latex + +\textit{italic \textsl{italic}} +% ^^^^^^ markup.italic.latex + +\textsl{italic \textit{italic}} +% ^^^^^^ markup.italic.latex + +\textit{italic \textsc{upright}} +% ^^^^^^^ markup.raw.inline.latex + +\textsl{italic \texttt{upright}} +% ^^^^^^^ markup.raw.inline.latex + +\textit{italic \textnormal{upright}} +% ^^^^^^^^^^^^^^^^^^^^ meta.function.textnormal.latex +% ^^^^^^^^^^^ support.function.textnormal.latex +% ^^^^^^^ - markup + +\textit{text {in braces} still italic} +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.textit.latex +% ^^^^^^^^^ markup.italic.latex +% ^^^^^^^^^^^^ markup.italic.latex + \underline{text} -% ^ markup.underline.underline.latex +%^^^^^^^^^^^^^^^ meta.function.underline.latex +%^^^^^^^^^ support.function.text.latex +% ^ punctuation.definition.group.brace.begin.tex - markup +% ^^^^ markup.underline.other.latex +% ^ punctuation.definition.group.brace.end.tex - markup + + +% Check math in markup +\textbf{bold $normal math$} +% ^^^^^^^^^^^^^ meta.environment.math.inline.dollar.tex - markup.bold.latex +% ^ string.other.math.tex punctuation.definition.string.begin.tex +% ^ string.other.math.tex punctuation.definition.string.end.tex + +\textbf{bold %with comment} +% ^^^^^^^^^^^^^^ comment.line.percentage.tex -markup.bold.latex +} + +\textit{italics~with~nbsp} +% ^ constant.character.space.tex -markup.italic.latex +% ^ constant.character.space.tex -markup.italic.latex +% check that incomplete code does not break too much +\textbf no braces here +%^^^^^^^ meta.function.textbf.latex +%^^^^^^ support.function.textbf.latex +% ^^^^^^^^^^^^^^^ - meta.function % FOOTNOTE COMMANDS From a9932f8d46e6106fa60ab7591e310827cb9ffcb5 Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Sat, 13 May 2023 12:16:22 +0300 Subject: [PATCH 42/46] [TeX.DocStrip] Basic DocStrip support (#3555) This PR adds support for the `DocStrip` format of TeX, used by many LaTeX packages to specify their installation. https://www.texlive.info/CTAN/macros/latex/base/docstrip.pdf I've inherited from the base `TeX` syntax, and just prepended the new commands to the `main` context. This is not quite accurate, in the sense that many `plainTeX` constructs would simply be invalid in a docstrip file -- as there is no typesetting to be done, typesetting and math commands don't really make sense. But I think it is OK to highlight these commands, and probably better to handle things like this, because if we manually select the subset that is supported, and later on add something new in `TeX` that also works in `DocStrip`, we might forget to change `DocStrips` `main` context. In general, `DocStrip` files are usually rather short and simple, and typically look like the examples given in https://texdoc.org/serve/dtxtut.pdf/0 (appendix A). Finally, since the goal is not to produce typeset output, but instead to describe how files are generated, I've used a `source` main scope. --- LaTeX/DocStrip.sublime-syntax | 96 ++++++++++++++++++++++++++++++++++ LaTeX/syntax_test_docstrip.ins | 89 +++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 LaTeX/DocStrip.sublime-syntax create mode 100644 LaTeX/syntax_test_docstrip.ins diff --git a/LaTeX/DocStrip.sublime-syntax b/LaTeX/DocStrip.sublime-syntax new file mode 100644 index 0000000000..f4777a8eb4 --- /dev/null +++ b/LaTeX/DocStrip.sublime-syntax @@ -0,0 +1,96 @@ +%YAML 1.2 +--- +# https://www.sublimetext.com/docs/syntax.html +# https://www.texlive.info/CTAN/macros/latex/base/docstrip.pdf +name: TeX (DocStrip) +scope: source.tex.docstrip +version: 1 +extends: Packages/LaTeX/TeX.sublime-syntax + +file_extensions: + - ins + +contexts: + main: + - meta_prepend: true + - include: docstrip-preamble + - include: docstrip-config + - include: docstrip-user-io + - include: docstrip-keywords + - include: docstrip-constants + + controls: + - meta_append: true + - match: (\\)endbatchfile{{endcs}} + scope: keyword.control.tex.docstrip + captures: + 1: punctuation.definition.backslash.tex + - match: (\\)(?:batch)?input{{endcs}} + scope: meta.function.input.tex keyword.control.input.tex + captures: + 1: punctuation.definition.backslash.tex + - match: (\\)ifToplevel{{endcs}} + scope: keyword.control.conditional.tex.docstrip + captures: + 1: punctuation.definition.backslash.tex + + docstrip-preamble: + - match: (\\)(?:declare)?(?:pre|post)amble{{endcs}} + scope: keyword.context.block.tex.docstrip + captures: + 1: punctuation.definition.backslash.tex + push: docstrip-preamble-content + + docstrip-preamble-content: + - meta_include_prototype: false + - meta_content_scope: markup.raw.verbatim.tex + - match: (\\)end(?:pre|post)amble{{endcs}} + scope: keyword.context.block.tex.docstrip + captures: + 1: punctuation.definition.backslash.tex + pop: 1 + + docstrip-keywords: + - match: (\\)(?:file|from|generateFile){{endcs}} + scope: keyword.tex.docstrip + captures: + 1: punctuation.definition.backslash.tex + push: docstrip-file-argument + - match: (\\)(?:generate|needed){{endcs}} + scope: keyword.tex.docstrip + captures: + 1: punctuation.definition.backslash.tex + + docstrip-file-argument: + - match: \{ + scope: punctuation.definition.group.brace.begin.tex + set: docstrip-file-argument-path + - include: else-pop + - include: paragraph-pop + + docstrip-file-argument-path: + - meta_content_scope: meta.path.tex.docstrip + - include: macro-braces-body + + docstrip-config: + - match: (\\)(?:usedir|showdirectory|BaseDirectory|DeclareDir|UseTDS|maxfiles|maxoutfiles){{endcs}} + scope: support.function.tex.docstrip + captures: + 1: punctuation.definition.backslash.tex + + docstrip-user-io: + - match: (\\)(?:Msg|Ask){{endcs}} + scope: support.function.tex.docstrip + captures: + 1: punctuation.definition.backslash.tex + + docstrip-constants: + - match: (\\)(?:askforoverwrite(?:true|false)|askonceonly|(?:use|no)(?:pre|post)amble|showprogress|keepsilent){{endcs}} + scope: constant.language.tex.docstrip + captures: + 1: punctuation.definition.backslash.tex + + - match: (\\)(?:(?:Double)?perCent|MetaPrefix|empty){{endcs}} + scope: constant.language.tex.docstrip + captures: + 1: punctuation.definition.backslash.tex diff --git a/LaTeX/syntax_test_docstrip.ins b/LaTeX/syntax_test_docstrip.ins new file mode 100644 index 0000000000..dd2d9bccd0 --- /dev/null +++ b/LaTeX/syntax_test_docstrip.ins @@ -0,0 +1,89 @@ +% SYNTAX TEST "Packages/LaTeX/DocStrip.sublime-syntax" + +\input docstrip.tex +%^^^^^ meta.function.input.tex keyword.control.input.tex + + +\keepsilent +%^^^^^^^^^^ constant.language.tex.docstrip + + +\usedir{tex/latex/somewhere} +%^^^^^^ support.function.tex.docstrip + + + +\preamble +%^^^^^^^^ keyword.context.block.tex.docstrip +This is a generated file. + +This file may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either +version 1.3 of this license or (at your option) any later +version. The latest version of this license is in: +http://www.latex-project.org/lppl.txt +and version 1.3 or later is part of all distributions of +LaTeX version 2005/12/01 or later. +% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.raw.verbatim.tex +\endpreamble +%^^^^^^^^^^^ keyword.context.block.tex.docstrip + +\declarepostamble +%^^^^^^^^^^^^^^^^ keyword.context.block.tex.docstrip +some text to copy +%^^^^^^^^^^^^^^^^^ markup.raw.verbatim.tex +\endpostamble +%^^^^^^^^^^^^ keyword.context.block.tex.docstrip + +\askforoverwritefalse +%^^^^^^^^^^^^^^^^^^^^ constant.language.tex.docstrip + +\askforoverwritetrue +%^^^^^^^^^^^^^^^^^^^ constant.language.tex.docstrip + +\nopreamble +%^^^^^^^^^^ constant.language.tex.docstrip + +\usepostamble +%^^^^^^^^^^^^ constant.language.tex.docstrip + +\askonceonly +%^^^^^^^^^^^ constant.language.tex.docstrip + +\showprogress +%^^^^^^^^^^^^ constant.language.tex.docstrip + + +\batchinput{other.docstrip} +%^^^^^^^^^^ meta.function.input.tex keyword.control.input.tex + +\let\MetaPrefix \DoubleperCent \perCent +% ^^^^^^^^^^^ constant.language.tex.docstrip +% ^^^^^^^^^^^^^^ constant.language.tex.docstrip +% ^^^^^^^^ constant.language.tex.docstrip +% ^ punctuation.definition.backslash.tex +% ^ punctuation.definition.backslash.tex + + +\ifToplevel{Conditional code executed} +%^^^^^^^^^^ keyword.control.conditional.tex.docstrip + +\generate{\file{target.sty}{\from{source.dtx}{pattern}}} +%^^^^^^^^ keyword.tex.docstrip +% ^^^^^ keyword.tex.docstrip +% ^^^^^^^^^^ meta.path.tex.docstrip +% ^^^^^ keyword.tex.docstrip +% ^^^^^^^^^^ meta.path.tex.docstrip + + +% Old but still supported syntax: +\generateFile{README.txt}{t}{\from{test.dtx}{README}} +%^^^^^^^^^^^^ keyword.tex.docstrip +% ^^^^^^^^^^ meta.path.tex.docstrip +% ^^^^^ keyword.tex.docstrip +% ^^^^^^^^ meta.path.tex.docstrip + +\Msg{* "example" package is now generated} +%^^^ support.function.tex.docstrip +\endbatchfile +%^^^^^^^^^^^^ keyword.control.tex From 504a1a709ad5609cac9d1f7303c162d7f0cca002 Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Sun, 11 Jun 2023 20:50:15 +0200 Subject: [PATCH 43/46] Revert to support.function scope (#3787) --- LaTeX/TeX.sublime-syntax | 4 +- LaTeX/{ => tests}/syntax_test_docstrip.ins | 0 LaTeX/tests/syntax_test_latex.xparse.tex | 4 +- LaTeX/tests/syntax_test_tex.tex | 300 ++++++++++----------- 4 files changed, 154 insertions(+), 154 deletions(-) rename LaTeX/{ => tests}/syntax_test_docstrip.ins (100%) diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index bd6c2facba..0c110098e0 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -287,14 +287,14 @@ contexts: tex-constants: - match: (\\){{constants}}{{endcs}} - scope: constant.language.tex + scope: support.function.tex captures: 1: punctuation.definition.backslash.tex push: - tex-dimension-value - tex-assignment - match: (\\){{macroconst}}{{endcs}} - scope: constant.language.tex + scope: support.function.tex captures: 1: punctuation.definition.backslash.tex diff --git a/LaTeX/syntax_test_docstrip.ins b/LaTeX/tests/syntax_test_docstrip.ins similarity index 100% rename from LaTeX/syntax_test_docstrip.ins rename to LaTeX/tests/syntax_test_docstrip.ins diff --git a/LaTeX/tests/syntax_test_latex.xparse.tex b/LaTeX/tests/syntax_test_latex.xparse.tex index 3d9ea4edec..03a275c954 100644 --- a/LaTeX/tests/syntax_test_latex.xparse.tex +++ b/LaTeX/tests/syntax_test_latex.xparse.tex @@ -216,8 +216,8 @@ % ^^ variable.parameter.tex % ^ punctuation.definition.placeholder.tex % ^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^^^^^ constant.language.tex -% ^^^^^^^^ constant.language.tex +% ^^^^^ support.function.tex +% ^^^^^^^^ support.function.tex % ^ punctuation.definition.backslash.tex % ^ punctuation.definition.backslash.tex % ^^^ meta.number.integer.decimal.tex diff --git a/LaTeX/tests/syntax_test_tex.tex b/LaTeX/tests/syntax_test_tex.tex index f5a23bc1e1..834649bf25 100644 --- a/LaTeX/tests/syntax_test_tex.tex +++ b/LaTeX/tests/syntax_test_tex.tex @@ -410,135 +410,135 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \pretolerance=100 -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^^ meta.number.integer.decimal.tex constant.numeric.value.tex \tolerance=200 -%^^^^^^^^^ constant.language.tex +%^^^^^^^^^ support.function.tex \hbadness=1000 -%^^^^^^^^ constant.language.tex +%^^^^^^^^ support.function.tex \vbadness=1000 -%^^^^^^^^ constant.language.tex +%^^^^^^^^ support.function.tex \linepenalty=10 -%^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^ support.function.tex \hyphenpenalty=50 -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \exhyphenpenalty=50 -%^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^ support.function.tex \binoppenalty=700 -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex \relpenalty=500 -%^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^ support.function.tex \clubpenalty=150 -%^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^ support.function.tex \widowpenalty=150 -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex \displaywidowpenalty=50 -%^^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^^ support.function.tex \brokenpenalty=100 -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \predisplaypenalty=10000 -%^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^ support.function.tex \postdisplaypenalty=0 -%^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^ support.function.tex \interlinepenalty=0 -%^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^ support.function.tex \floatingpenalty=0 -%^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^ support.function.tex \outputpenalty=0 -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \doublehyphendemerits=10000 -%^^^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^^^ support.function.tex \finalhyphendemerits=5000 -%^^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^^ support.function.tex \adjdemerits=10000 -%^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^ support.function.tex \looseness=0 -%^^^^^^^^^ constant.language.tex +%^^^^^^^^^ support.function.tex \pausing=0 -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex \holdinginserts=0 -%^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^ support.function.tex \tracingonline=0 -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \tracingmacros=0 -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \tracingstats=0 -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex \tracingparagraphs=0 -%^^^^^^^^^^^^^^^^^constant.language.tex +%^^^^^^^^^^^^^^^^^support.function.tex \tracingpages=0 -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex \tracingoutput=0 -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \tracinglostchars=1 -%^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^ support.function.tex \tracingcommands=0 -%^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^ support.function.tex \tracingrestores=0 -%^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^ support.function.tex \language=0 -%^^^^^^^^ constant.language.tex +%^^^^^^^^ support.function.tex \uchyph=1 -%^^^^^^ constant.language.tex +%^^^^^^ support.function.tex \lefthyphenmin=2 -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \righthyphenmin=3 -%^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^ support.function.tex \globaldefs=0 -%^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^ support.function.tex \maxdeadcycles=25 -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \hangafter=1 -%^^^^^^^^^ constant.language.tex +%^^^^^^^^^ support.function.tex \fam=0 -%^^^ constant.language.tex +%^^^ support.function.tex \mag=1000 -%^^^ constant.language.tex +%^^^ support.function.tex \escapechar=`\\ -%^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^^ meta.number.integer % ^ keyword.operator.tex % ^ punctuation.definition.backslash.tex % ^ constant.character.tex \defaulthyphenchar=`\- -%^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^ support.function.tex \defaultskewchar=-1 -%^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^ meta.number.integer.decimal.tex constant.numeric.value.tex \endlinechar=`\^^M -%^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^ support.function.tex \newlinechar=-1 -%^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^ support.function.tex \delimiterfactor=901 -%^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^ support.function.tex \time -%^^^^ constant.language.tex +%^^^^ support.function.tex \day -%^^^ constant.language.tex +%^^^ support.function.tex \month -%^^^^^ constant.language.tex +%^^^^^ support.function.tex \year -%^^^^ constant.language.tex +%^^^^ support.function.tex \showboxbreadth=5 -%^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^ support.function.tex \showboxdepth=3 -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex \errorcontextlines=5 -%^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^ support.function.tex \hfuzz=0.1pt -%^^^^^ constant.language.tex +%^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^^^^ meta.number.float.decimal.tex % ^^^ constant.numeric.value.tex % ^ punctuation.separator.decimal.tex % ^^ constant.numeric.suffix.tex \vfuzz=0.1 pt -%^^^^^ constant.language.tex +%^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^^^^^ meta.number.float.decimal.tex % ^^^ constant.numeric.value.tex @@ -547,7 +547,7 @@ % check that we can put comment-based line breaks here \overfullrule=% -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex 5pt % ^^^ meta.number.integer.decimal.tex @@ -555,21 +555,21 @@ % ^^ constant.numeric.suffix.tex \hsize=6.5in -%^^^^^ constant.language.tex +%^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^^^^ meta.number.float.decimal.tex % ^^^ constant.numeric.value.tex % ^ punctuation.separator.decimal.tex % ^^ constant.numeric.suffix.tex \vsize=8.9in -%^^^^^ constant.language.tex +%^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^^^^ meta.number.float.decimal.tex % ^^^ constant.numeric.value.tex % ^ punctuation.separator.decimal.tex % ^^ constant.numeric.suffix.tex \maxdepth=.4pt -%^^^^^^^^ constant.language.tex +%^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^^^ meta.number.float.decimal.tex % ^^ constant.numeric.value.tex @@ -578,43 +578,43 @@ \splitmaxdepth=\maxdimen -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex -% ^^^^^^^^^ constant.language.tex +% ^^^^^^^^^ support.function.tex % ^ punctuation.definition.backslash.tex \boxmaxdepth=\maxdimen -%^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^ support.function.tex \lineskiplimit=0pt -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \delimitershortfall=5pt -%^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^ support.function.tex \nulldelimiterspace=1.2pt -%^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^ support.function.tex \scriptspace=0.5pt -%^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^ support.function.tex \mathsurround=0pt -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex \predisplaysize=0pt -%^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^ support.function.tex \displaywidth=0pt -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex \displayindent=0pt -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \parindent=20pt -%^^^^^^^^^ constant.language.tex +%^^^^^^^^^ support.function.tex \hangindent=0pt -%^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^ support.function.tex \hoffset=0pt -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex \voffset=0pt -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex \baselineskip=0pt -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex \lineskip=0pt -%^^^^^^^^ constant.language.tex +%^^^^^^^^ support.function.tex \parskip=0pt plus 1pt -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^ meta.number.integer.decimal.tex constant.numeric.value.tex % ^^ constant.numeric.suffix.tex @@ -623,7 +623,7 @@ % ^^ constant.numeric.suffix.tex \abovedisplayskip=12pt plus 3pt minus 9pt -%^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^ meta.number.integer.decimal.tex constant.numeric.value.tex % ^^ constant.numeric.suffix.tex @@ -634,27 +634,27 @@ % ^ meta.number.integer.decimal.tex constant.numeric.value.tex % ^^ constant.numeric.suffix.tex \abovedisplayshortskip=0pt plus 3pt -%^^^^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^^^^ support.function.tex \belowdisplayskip=12pt plus 3pt minus 9pt -%^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^ support.function.tex \belowdisplayshortskip=7pt plus 3pt minus 4pt -%^^^^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^^^^ support.function.tex \leftskip=0pt -%^^^^^^^^ constant.language.tex +%^^^^^^^^ support.function.tex \rightskip=0pt -%^^^^^^^^^ constant.language.tex +%^^^^^^^^^ support.function.tex \topskip=10pt -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex \splittopskip=10pt -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex \tabskip=0pt -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex \spaceskip=0pt -%^^^^^^^^^ constant.language.tex +%^^^^^^^^^ support.function.tex \xspaceskip=0pt -%^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^ support.function.tex \parfillskip=0pt plus 1fil -%^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^ meta.number.integer.decimal.tex constant.numeric.value.tex % ^^ constant.numeric.suffix.tex @@ -664,13 +664,13 @@ \thinmuskip=3mu -%^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^ meta.number.integer.decimal.tex constant.numeric.value.tex % ^^ constant.numeric.suffix.tex \medmuskip=4mu plus 2mu minus 4mu -%^^^^^^^^^ constant.language.tex +%^^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^ meta.number.integer.decimal.tex constant.numeric.value.tex % ^^ constant.numeric.suffix.tex @@ -681,90 +681,90 @@ % ^ meta.number.integer.decimal.tex constant.numeric.value.tex % ^^ constant.numeric.suffix.tex \thickmuskip=5mu plus 5mu -%^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^ support.function.tex \smallskipamount=3pt plus 1pt minus 1pt -%^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^ support.function.tex \medskipamount=6pt plus 2pt minus 2pt -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \bigskipamount=12pt plus 4pt minus 4pt -%^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^ support.function.tex \normalbaselineskip=12pt -%^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^ support.function.tex \normallineskip=1pt -%^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^ support.function.tex \normallineskiplimit=0pt -%^^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^^ support.function.tex \jot=3pt -%^^^ constant.language.tex +%^^^ support.function.tex \interdisplaylinepenalty=100 -%^^^^^^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^^^^^^ support.function.tex \interfootnotelinepenalty=100 -%^^^^^^^^^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^^^^^^^^^ support.function.tex \maxdimen -%^^^^^^^^ constant.language.tex +%^^^^^^^^ support.function.tex \centering -%^^^^^^^^^ constant.language.tex +%^^^^^^^^^ support.function.tex \p@ -%^^ constant.language.tex +%^^ support.function.tex \z@ -%^^ constant.language.tex +%^^ support.function.tex \z@skip -%^^^^^^ constant.language.tex +%^^^^^^ support.function.tex \voidb@x -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex \magstephalf -%^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^ support.function.tex \magstep4 -%^^^^^^^^ constant.language.tex +%^^^^^^^^ support.function.tex \@ne -%^^^ constant.language.tex +%^^^ support.function.tex \tw@ -%^^^ constant.language.tex +%^^^ support.function.tex \thr@@ -%^^^^^ constant.language.tex +%^^^^^ support.function.tex \sixt@@n -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex \@cclv -%^^^^^ constant.language.tex +%^^^^^ support.function.tex \@cclvi -%^^^^^^ constant.language.tex +%^^^^^^ support.function.tex \@m -%^^ constant.language.tex +%^^ support.function.tex \@M -%^^ constant.language.tex +%^^ support.function.tex \@MM -%^^^ constant.language.tex +%^^^ support.function.tex \m@ne -%^^^^ constant.language.tex +%^^^^ support.function.tex \count@=255 -%^^^^^^ constant.language.tex +%^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^^ meta.number.integer.decimal.tex constant.numeric.value.tex \dimen@=0 -%^^^^^^ constant.language.tex +%^^^^^^ support.function.tex \dimen@i=1 -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex \dimen@ii=2 -%^^^^^^^^ constant.language.tex +%^^^^^^^^ support.function.tex \skip@=0 -%^^^^^ constant.language.tex +%^^^^^ support.function.tex \toks@=0 -%^^^^^ constant.language.tex +%^^^^^ support.function.tex % Assignments without equals sign \baselineskip-1000\p@ -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex % ^^^^^ meta.number.integer.decimal.tex constant.numeric.value.tex % ^ keyword.operator.arithmetic.tex -% ^^^ constant.language.tex +% ^^^ support.function.tex % ^ punctuation.definition.backslash.tex % Using weird ways to specify a number \abovedisplayskip=`\^^Z ex -%^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^^^^^^ meta.number.integer.decimal.tex % ^ keyword.operator.tex @@ -773,7 +773,7 @@ % ^^ constant.numeric.suffix.tex \abovedisplayskip=`\a ex -%^^^^^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^^^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^^^^^^ meta.number.integer.decimal.tex % ^ keyword.operator.tex @@ -784,43 +784,43 @@ % The macro-type constants. They cannot be assigned using = \thinspace=5pt -%^^^^^^^^^ constant.language.tex +%^^^^^^^^^ support.function.tex % ^ - keyword.operator.assignment.tex \negthinspace -%^^^^^^^^^^^^ constant.language.tex +%^^^^^^^^^^^^ support.function.tex \enspace -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex \enskip -%^^^^^^ constant.language.tex +%^^^^^^ support.function.tex \quad -%^^^^ constant.language.tex +%^^^^ support.function.tex \qquad -%^^^^^ constant.language.tex +%^^^^^ support.function.tex \smallskip -%^^^^^^^^^ constant.language.tex +%^^^^^^^^^ support.function.tex \medskip -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex \bigskip -%^^^^^^^ constant.language.tex +%^^^^^^^ support.function.tex \space -%^^^^^ constant.language.tex +%^^^^^ support.function.tex \empty -%^^^^^ constant.language.tex +%^^^^^ support.function.tex \null -%^^^^ constant.language.tex +%^^^^ support.function.tex \lq -%^^ constant.language.tex +%^^ support.function.tex \rq -%^^ constant.language.tex +%^^ support.function.tex \lbrack -%^^^^^^ constant.language.tex +%^^^^^^ support.function.tex \rbrack -%^^^^^^ constant.language.tex +%^^^^^^ support.function.tex % check that we don't pick it up if it is just the beginning of a word \jota -%^^^^ - constant.language.tex +%^^^^ - support.function.tex % Check that a number is required \jot=pt @@ -841,7 +841,7 @@ % will not be parsed as part of the quantity \jot=5pt \relax plus 10pt % ^^^^ - keyword.operator -%^^^ constant.language.tex +%^^^ support.function.tex % ^ keyword.operator.assignment.tex % ^ meta.number.integer.decimal.tex constant.numeric.value.tex % ^^ constant.numeric.suffix.tex @@ -858,7 +858,7 @@ % ^ punctuation.definition.backslash.tex % ^^^^^^^^^^^^^^^^^^^ meta.function.body.tex meta.group.brace.tex % ^ punctuation.definition.group.brace.begin.tex -% ^^^^^^^^^^^^^^^^^ constant.language.tex +% ^^^^^^^^^^^^^^^^^ support.function.tex % ^ punctuation.definition.backslash.tex % ^ punctuation.definition.group.brace.end.tex From 66dccdfe4abf29dcef3fa892b82c54990120f5b6 Mon Sep 17 00:00:00 2001 From: ngc92 <7938269+ngc92@users.noreply.github.com> Date: Wed, 1 Nov 2023 21:23:07 +0200 Subject: [PATCH 44/46] [LaTeX] Math scopes (#3608) --- LaTeX/LaTeX.sublime-syntax | 22 ++- LaTeX/TeX.sublime-syntax | 26 ++-- LaTeX/tests/syntax_test_latex.tex | 83 +++++++----- LaTeX/tests/syntax_test_tex.math.tex | 178 +++++++++++++++++++++++++ LaTeX/tests/syntax_test_tex.tex | 128 ------------------ Markdown/tests/syntax_test_markdown.md | 6 +- 6 files changed, 263 insertions(+), 180 deletions(-) create mode 100644 LaTeX/tests/syntax_test_tex.math.tex diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index b89483384b..0504e4963b 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -581,16 +581,22 @@ contexts: - include: inline-math-ensuremath inline-math-ensuremath: - - match: ((\\)ensuremath)(\{) + - match: (\\)ensuremath{{endcs}} + scope: support.function.ensuremath.latex captures: - 1: support.function.ensuremath.latex - 2: punctuation.definition.backslash.latex - 3: punctuation.definition.group.brace.begin.tex - push: inline-math-ensuremath-body + 1: punctuation.definition.backslash.latex + push: inline-math-ensuremath-begin + + inline-math-ensuremath-begin: + - meta_scope: meta.function.ensuremath.latex + - match: \{ + scope: punctuation.definition.group.brace.begin.tex + set: inline-math-ensuremath-body + - include: paragraph-pop inline-math-ensuremath-body: - meta_scope: meta.function.ensuremath.latex - - meta_content_scope: meta.environment.math.inline.ensuremath.latex + - meta_content_scope: meta.environment.math.inline.ensuremath.latex markup.math.inline - include: brace-group-end - include: math-content @@ -601,6 +607,7 @@ contexts: inline-math-parens-body: - meta_scope: meta.environment.math.inline.paren.latex + - meta_content_scope: markup.math.inline - include: inline-math-parens-end - include: math-content @@ -631,7 +638,7 @@ contexts: push: block-math-begin-end-command-body block-math-begin-end-command-body: - - meta_content_scope: meta.environment.math.block.be.latex + - meta_content_scope: meta.environment.math.block.be.latex markup.math.block - include: block-math-begin-end-command-end - include: math-content @@ -652,6 +659,7 @@ contexts: block-math-brackets-body: - meta_scope: meta.environment.math.block.bracket.latex + - meta_content_scope: markup.math.block - include: block-math-brackets-end - include: math-content diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 0c110098e0..1f76a6fc1c 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -543,6 +543,7 @@ contexts: inline-math-dollar-body: - meta_scope: meta.environment.math.inline.dollar.tex + - meta_content_scope: markup.math.inline - include: inline-math-dollar-end - include: math-content @@ -558,6 +559,7 @@ contexts: block-math-dollar-body: - meta_scope: meta.environment.math.block.dollar.tex + - meta_content_scope: markup.math.block - include: block-math-dollar-end - include: math-content @@ -649,14 +651,16 @@ contexts: 1: punctuation.definition.backslash.tex math-operators: - - match: '[<>]=?' + # note: in math notation, = usually denotes that two terms are equal, instead + # of an assignment. + - match: '[<>]=?|=' scope: keyword.operator.comparison.tex - - match: '[-+*/^!]' + - match: '[-+*/!]' scope: keyword.operator.arithmetic.tex - - match: = - scope: keyword.operator.assignment.tex - match: _ - scope: punctuation.separator.indice.tex + scope: punctuation.separator.subscript.tex + - match: \^ + scope: punctuation.separator.superscript.tex math-braces: - match: \{ @@ -677,10 +681,14 @@ contexts: scope: punctuation.section.brackets.begin.tex - match: \] scope: punctuation.section.brackets.end.tex - - match: (\\)[{}] - scope: constant.character.escape.tex + - match: (\\){ + scope: punctuation.section.braces.begin.tex constant.character.escape.tex captures: - 1: punctuation.definition.escape.tex + 1: punctuation.definition.backslash.tex + - match: (\\)} + scope: punctuation.section.braces.end.tex constant.character.escape.tex + captures: + 1: punctuation.definition.backslash.tex math-numbers: - match: \d*(\.)\d+ @@ -692,7 +700,7 @@ contexts: math-variables: - match: '[A-Za-z]+' - scope: variable.other.math.tex + scope: variable.other.math.tex markup.italic.math.tex ###[ PROTOTYPES ]############################################################## diff --git a/LaTeX/tests/syntax_test_latex.tex b/LaTeX/tests/syntax_test_latex.tex index f166234c57..0d943f0eb8 100644 --- a/LaTeX/tests/syntax_test_latex.tex +++ b/LaTeX/tests/syntax_test_latex.tex @@ -762,47 +762,58 @@ \subsubsection{name} % Check we have always a shared environment -$f(x) = x^2$ -% <- meta.environment.math.inline.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex -%^^^^^^^^^^ meta.environment.math.inline.dollar.tex - string -% ^ meta.environment.math.inline.dollar.tex string.other.math.tex punctuation.definition.string.end.tex -% ^ - meta.environment.math - -$$f(x) = x^2$$ -% <- meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex -%^ meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex -% ^^^^^^^^^^ meta.environment.math.block.dollar.tex - string -% ^^ meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.end.tex -% ^ - meta.environment.math - -\(f(x) = x^2\) -% <- meta.environment.math.inline.paren.latex string.other.math.latex punctuation.definition.string.begin.latex -%^ meta.environment.math.inline.paren.latex string.other.math.latex punctuation.definition.string.begin.latex -% ^^^^^^^^^^ meta.environment.math.inline.paren.latex - string -% ^^ meta.environment.math.inline.paren.latex string.other.math.latex punctuation.definition.string.end.latex -% ^ - meta.environment.math - -\[ -% <- meta.environment.math.block.bracket.latex string.other.math.latex punctuation.definition.string.begin.latex -%^ meta.environment.math.block.bracket.latex string.other.math.latex punctuation.definition.string.begin.latex -% ^ meta.environment.math.block.bracket.latex - string + $f(x) = x^2$ +%^ string.other.math.tex punctuation.definition.string.begin.tex +%^^^^^^^^^^^^ meta.environment.math.inline.dollar.tex +% ^^^^^^^^^^ markup.math.inline - string +% ^ punctuation.definition.string.end.tex - markup.math.inline + + $$f(x) = x^2$$ +%^^ string.other.math.tex punctuation.definition.string.begin.tex +%^^^^^^^^^^^^^^ meta.environment.math.block.dollar.tex +% ^^^^^^^^^^ markup.math.block - string +% ^^ string.other.math.tex punctuation.definition.string.end.tex - markup.math.block + + \(f(x) = x^2\) +%^^^^^^^^^^^^^^ meta.environment.math.inline.paren.latex +% ^^^^^^^^^^ markup.math.inline - string +%^^ string.other.math.latex punctuation.definition.string.begin.latex +% ^^ string.other.math.latex punctuation.definition.string.end.latex - markup.math.inline + + + \[ +%^^ string.other.math.latex punctuation.definition.string.begin.latex f(x) = x^2 \text{ $f$ is a function} -%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.environment.math.block.bracket.latex -\] -% <- meta.environment.math.block.bracket.latex string.other.math.latex punctuation.definition.string.end.latex -%^ meta.environment.math.block.bracket.latex string.other.math.latex punctuation.definition.string.end.latex -% ^ - meta.environment.math +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.environment.math.block.bracket.latex markup.math.block +% ^^^^^^^^^^ - string + \] +%^^ meta.environment.math.block.bracket.latex punctuation.definition.string.end.latex - markup.math.inline +% ^ - meta.environment.math \ensuremath{f(x) = x^2} % <- meta.function.ensuremath.latex support.function.ensuremath.latex punctuation.definition.backslash.latex -%^^^^^^^^^^ meta.function.ensuremath.latex -% ^ meta.function.ensuremath.latex - meta.environment.math -% ^^^^^^^^^^ meta.function.ensuremath.latex meta.environment.math.inline.ensuremath.latex -% ^ meta.function.ensuremath.latex - meta.environment.math +%^^^^^^^^^^^^^^^^^^^^^^ meta.function.ensuremath.latex +% ^ - meta.environment.math - markup.math +% ^^^^^^^^^^ meta.environment.math.inline.ensuremath.latex markup.math.inline +% ^ - meta.environment.math - markup.math %^^^^^^^^^^ support.function.ensuremath.latex % ^ punctuation.definition.group.brace.begin.tex % ^ punctuation.definition.group.brace.end.tex +\ensuremath % +%^^^^^^^^^^^^^ meta.function.ensuremath.latex +%^^^^^^^^^^ support.function.ensuremath.latex +% ^^ comment.line.percentage.tex + {x^2}{normal text} +%^^^^^^^^^ meta.function.ensuremath.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^^^ meta.environment.math.inline.ensuremath.latex markup.math.inline +% ^ punctuation.definition.group.brace.end.tex +% ^^^^^^^^^^^^^ - meta.function.ensuremath.latex + +\ensuremaths{5} +% ^ - meta.function.ensuremath.latex + \begin{equation} % <- support.function.begin.latex keyword.control.flow.begin.latex punctuation.definition.backslash.latex %^^^^^ support.function.begin.latex keyword.control.flow.begin.latex @@ -820,6 +831,12 @@ \subsubsection{name} % ^ 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 + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Boxes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/LaTeX/tests/syntax_test_tex.math.tex b/LaTeX/tests/syntax_test_tex.math.tex new file mode 100644 index 0000000000..3942f9e9b0 --- /dev/null +++ b/LaTeX/tests/syntax_test_tex.math.tex @@ -0,0 +1,178 @@ +% SYNTAX TEST "Packages/LaTeX/TeX.sublime-syntax" + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Inline Math +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + $f(x) = x^2$ +%^ string.other.math.tex punctuation.definition.string.begin.tex +%^^^^^^^^^^^^ meta.environment.math.inline.dollar.tex +% ^^^^^^^^^^ markup.math.inline - string +% ^ string.other.math.tex punctuation.definition.string.end.tex - markup.math.inline +% ^ variable.other.math.tex markup.italic.math.tex +% ^ punctuation.section.parens.begin.tex - markup.italic +% ^ variable.other.math.tex markup.italic.math.tex +% ^ punctuation.section.parens.end.tex - markup.italic +% ^^^ - markup.italic +% ^ variable.other.math.tex markup.italic.math.tex +% ^ - markup.italic + +$\iota$ +%^^^^^ keyword.other.math.greek.tex +%^ punctuation.definition.backslash.tex + +$\Iota$ +%^^^^^ support.function.math.tex - keyword.other +%^ punctuation.definition.backslash.tex + +$\alpha _$ +%^^^^^^ keyword.other.math.greek.tex +%^ punctuation.definition.backslash.tex +% ^ punctuation.separator.subscript.tex + +$\alpha_$ +%^^^^^^ keyword.other.math.greek.tex +%^ punctuation.definition.backslash.tex +% ^ punctuation.separator.subscript.tex + + $\sum_{i=1}^{1} i^2$ +%^^^^^^^^^^^^^^^^^^^^ meta.environment.math.inline.dollar +% ^^^^^^^^^^^^^^^^^^ markup.math.inline - string +% ^ punctuation.definition.backslash.tex +% ^^^^ keyword.other.math.large-operator.tex +% ^ variable.other.math.tex markup.italic.math.tex +% ^ variable.other.math.tex markup.italic.math.tex +% ^ keyword.operator.comparison.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^^^ meta.group.brace.tex + +$\lim_{x \rightarrow 0} \sin x$ +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.environment.math.inline.dollar.tex +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.math.inline +%^^^^ keyword.other.math.function.tex +%^ punctuation.definition.backslash.tex +% ^ punctuation.separator.subscript.tex +% ^^^^^^^^^^^^^^^^^ meta.group.brace.tex +% ^ punctuation.definition.group.brace.begin.tex +% ^ variable.other.math.tex markup.italic.math.tex +% ^^^^^^^^^^^ keyword.other.math.arrow.tex +% ^ punctuation.definition.backslash.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ punctuation.definition.group.brace.end.tex +% ^^^^ keyword.other.math.function.tex +% ^ punctuation.definition.backslash.tex +% ^ variable.other.math.tex markup.italic.math.tex +% ^ string.other.math.tex punctuation.definition.string.end.tex + + +% make sure that we see $$ here as close-open, not as starting a $$ display math + $x$$y$ +%^^^^^^ meta.environment.math.inline.dollar.tex +%^ string.other.math.tex punctuation.definition.string.begin.tex +% ^ markup.math.inline variable.other.math.tex markup.italic.math.tex +% ^^ string.other.math.tex - markup.math.inline +% ^ punctuation.definition.string.end.tex +% ^ punctuation.definition.string.begin.tex +% ^ markup.math.inline variable.other.math.tex markup.italic.math.tex +% ^ string.other.math.tex punctuation.definition.string.end.tex +% ^ - meta.environment.math + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Display Math +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + $$f(x) = x^2$$ +%^^ string.other.math.tex punctuation.definition.string.begin.tex +%^^^^^^^^^^^^^^ meta.environment.math.block.dollar.tex +% ^^^^^^^^^^ markup.math.block - string +% ^^ string.other.math.tex punctuation.definition.string.end.tex - markup.math.block + +$$ +% <- meta.environment.math.block.dollar.tex punctuation.definition.string.begin.tex +%^^ meta.environment.math.block.dollar.tex +%^ punctuation.definition.string.begin.tex + + 0 1 2 3 4 5 6 7 8 9 10 11 +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex +% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex + + 1.0 +%^ - meta.number - constant +% ^^^ meta.number.float.decimal.tex constant.numeric.value.tex +% ^ punctuation.separator.decimal.tex +% ^ - meta.number - constant + + 0.2 +%^ - meta.number - constant +% ^^^ meta.number.float.decimal.tex constant.numeric.value.tex +% ^ punctuation.separator.decimal.tex +% ^ - meta.number - constant + + .4 +%^ - meta.number - constant +% ^^ meta.number.float.decimal.tex constant.numeric.value.tex +% ^ punctuation.separator.decimal.tex +% ^ - meta.number - constant + + () +% ^ punctuation.section.parens.begin.tex +% ^ punctuation.section.parens.end.tex + + [] +% ^ punctuation.section.brackets.begin.tex +% ^ punctuation.section.brackets.end.tex + + \{ \} +%^ - constant +% ^^ constant.character.escape.tex +% ^ - constant +% ^^ constant.character.escape.tex +% ^ - constant + + c = a + b - d * f / g! +% ^ variable.other.math.tex +% ^ keyword.operator.comparison.tex +% ^ variable.other.math.tex +% ^ keyword.operator.arithmetic.tex +% ^ variable.other.math.tex +% ^ keyword.operator.arithmetic.tex +% ^ variable.other.math.tex +% ^ keyword.operator.arithmetic.tex +% ^ variable.other.math.tex +% ^ keyword.operator.arithmetic.tex +% ^ variable.other.math.tex +% ^ keyword.operator.arithmetic.tex + + a < b <= c +% ^ variable.other.math.tex +% ^ keyword.operator.comparison.tex +% ^ variable.other.math.tex +% ^^ keyword.operator.comparison.tex +% ^ variable.other.math.tex + + a > b >= c +% ^ variable.other.math.tex +% ^ keyword.operator.comparison.tex +% ^ variable.other.math.tex +% ^^ keyword.operator.comparison.tex +% ^ variable.other.math.tex + + a_n^2 +% ^ variable.other.math.tex markup.italic.math.tex +% ^ punctuation.separator.subscript.tex +% ^ variable.other.math.tex +% ^ punctuation.separator.superscript.tex +% ^ meta.number.integer.decimal.tex constant.numeric.value.tex + +$$ diff --git a/LaTeX/tests/syntax_test_tex.tex b/LaTeX/tests/syntax_test_tex.tex index 834649bf25..3b974602d3 100644 --- a/LaTeX/tests/syntax_test_tex.tex +++ b/LaTeX/tests/syntax_test_tex.tex @@ -865,131 +865,3 @@ % No value, the 5 is outside of the macro \def\macro{\abovedisplayskip=}5 % ^ - meta.number - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Math -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -$f(x) = x^2$ -% <- meta.environment.math.inline.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex -%^^^^^^^^^^ meta.environment.math.inline.dollar.tex - string -% ^ meta.environment.math.inline.dollar.tex string.other.math.tex punctuation.definition.string.end.tex - -$$f(x) = x^2$$ -% <- meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex -%^ meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex -% ^^^^^^^^^^ meta.environment.math.block.dollar.tex - string -% ^^ meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.end.tex - -$\iota$ -%^^^^^ keyword.other.math.greek.tex -%^ punctuation.definition.backslash.tex - -$\Iota$ -%^^^^^ support.function.math.tex - keyword.other -%^ punctuation.definition.backslash.tex - -$\alpha _$ -%^^^^^^ keyword.other.math.greek.tex -%^ punctuation.definition.backslash.tex -% ^ punctuation.separator.indice.tex - -$\alpha_$ -%^^^^^^ keyword.other.math.greek.tex -%^ punctuation.definition.backslash.tex -% ^ punctuation.separator.indice.tex - -$$ -% <- meta.environment.math.block.dollar.tex string.other.math.tex punctuation.definition.string.begin.tex -%^^ meta.environment.math.block.dollar.tex -%^ string.other.math.tex punctuation.definition.string.begin.tex - - 0 1 2 3 4 5 6 7 8 9 10 11 -% ^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex -% ^^ meta.number.integer.decimal.tex constant.numeric.value.tex - - 1.0 -%^ - meta.number - constant -% ^^^ meta.number.float.decimal.tex constant.numeric.value.tex -% ^ punctuation.separator.decimal.tex -% ^ - meta.number - constant - - 0.2 -%^ - meta.number - constant -% ^^^ meta.number.float.decimal.tex constant.numeric.value.tex -% ^ punctuation.separator.decimal.tex -% ^ - meta.number - constant - - .4 -%^ - meta.number - constant -% ^^ meta.number.float.decimal.tex constant.numeric.value.tex -% ^ punctuation.separator.decimal.tex -% ^ - meta.number - constant - - () -% ^ punctuation.section.parens.begin.tex -% ^ punctuation.section.parens.end.tex - - [] -% ^ punctuation.section.brackets.begin.tex -% ^ punctuation.section.brackets.end.tex - - \{ \} -%^ - constant -% ^^ constant.character.escape.tex -% ^ - constant -% ^^ constant.character.escape.tex -% ^ - constant - - c = a + b - d * f / g! -% ^ variable.other.math.tex -% ^ keyword.operator.assignment.tex -% ^ variable.other.math.tex -% ^ keyword.operator.arithmetic.tex -% ^ variable.other.math.tex -% ^ keyword.operator.arithmetic.tex -% ^ variable.other.math.tex -% ^ keyword.operator.arithmetic.tex -% ^ variable.other.math.tex -% ^ keyword.operator.arithmetic.tex -% ^ variable.other.math.tex -% ^ keyword.operator.arithmetic.tex - - a < b <= c -% ^ variable.other.math.tex -% ^ keyword.operator.comparison.tex -% ^ variable.other.math.tex -% ^^ keyword.operator.comparison.tex -% ^ variable.other.math.tex - - a > b >= c -% ^ variable.other.math.tex -% ^ keyword.operator.comparison.tex -% ^ variable.other.math.tex -% ^^ keyword.operator.comparison.tex -% ^ variable.other.math.tex - - a_n^2 -% ^ variable.other.math.tex -% ^ punctuation.separator.indice.tex -% ^ variable.other.math.tex -% ^ keyword.operator.arithmetic.tex -% ^ meta.number.integer.decimal.tex constant.numeric.value.tex - -$$ - - $\sum_{i=1}^{1} i^2$ -%^^^^^^^^^^^^^^^^^^^^ meta.environment.math.inline.dollar. -% ^ punctuation.definition.backslash.tex -% ^^^^ keyword.other.math.large-operator.tex diff --git a/Markdown/tests/syntax_test_markdown.md b/Markdown/tests/syntax_test_markdown.md index 6a45725083..4088aa8e9e 100644 --- a/Markdown/tests/syntax_test_markdown.md +++ b/Markdown/tests/syntax_test_markdown.md @@ -8038,7 +8038,7 @@ $$ foo = 1 + 2 * \sqrt{a^2+b^2} | <- markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar variable.other.math |^^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.math.block.markdown text.tex.latex.embedded.markdown meta.environment.math.block.dollar -| ^ keyword.operator.assignment +| ^ keyword.operator.comparison | ^ constant.numeric.value | ^ keyword.operator.arithmetic | ^ constant.numeric.value @@ -8047,11 +8047,11 @@ foo = 1 + 2 * \sqrt{a^2+b^2} | ^^^^^^^^^ meta.group.brace | ^ punctuation.definition.group.brace.begin | ^ variable.other.math -| ^ keyword.operator.arithmetic +| ^ punctuation.separator.superscript.tex | ^ constant.numeric.value | ^ keyword.operator.arithmetic | ^ variable.other.math -| ^ keyword.operator.arithmetic +| ^ punctuation.separator.superscript.tex | ^ constant.numeric.value | ^ punctuation.definition.group.brace.end $$ From 28e4077a9df33094f22553950733b2508f37be30 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 2 Nov 2023 20:20:58 +0100 Subject: [PATCH 45/46] [LaTeX] sublime syntax version 2 --- Haskell/Literate Haskell.sublime-syntax | 1 + LaTeX/Bibtex.sublime-syntax | 27 +++--- LaTeX/DocStrip.sublime-syntax | 3 +- LaTeX/LaTeX Log.sublime-syntax | 1 + LaTeX/LaTeX.sublime-syntax | 123 +++++++++++------------- LaTeX/TeX.sublime-syntax | 17 ++-- LaTeX/tests/syntax_test_latex.tex | 37 +++++-- 7 files changed, 112 insertions(+), 97 deletions(-) diff --git a/Haskell/Literate Haskell.sublime-syntax b/Haskell/Literate Haskell.sublime-syntax index ef7e77ada3..62050a6b21 100644 --- a/Haskell/Literate Haskell.sublime-syntax +++ b/Haskell/Literate Haskell.sublime-syntax @@ -3,6 +3,7 @@ # https://www.sublimetext.com/docs/syntax.html name: Literate Haskell scope: text.tex.latex.haskell +version: 2 extends: Packages/LaTeX/LaTeX.sublime-syntax diff --git a/LaTeX/Bibtex.sublime-syntax b/LaTeX/Bibtex.sublime-syntax index 06238862ba..6cfac69a2f 100644 --- a/LaTeX/Bibtex.sublime-syntax +++ b/LaTeX/Bibtex.sublime-syntax @@ -6,6 +6,7 @@ # TODO: Does not support @preamble name: BibTeX scope: text.bibtex +version: 2 file_extensions: - bib @@ -25,7 +26,7 @@ contexts: push: - meta_scope: comment.line.at-sign.bibtex - match: $\n? - pop: true + pop: 1 - match: '((@)[Ss]tring)\s*(\{)\s*({{var}})' captures: 1: keyword.other.string-constant.bibtex @@ -36,7 +37,7 @@ contexts: - meta_scope: meta.string-constant.braces.bibtex - match: '\}' scope: punctuation.section.string-constant.end.bibtex - pop: true + pop: 1 - include: string_content - include: variables - include: operators @@ -50,7 +51,7 @@ contexts: - meta_scope: meta.string-constant.parenthesis.bibtex - match: \) scope: punctuation.section.string-constant.end.bibtex - pop: true + pop: 1 - include: string_content - include: variables - include: operators @@ -65,7 +66,7 @@ contexts: - meta_content_scope: meta.mapping.bibtex - match: '\}' scope: punctuation.section.entry.end.bibtex - pop: true + pop: 1 - match: '([a-zA-Z]+)(\s*(=)\s*)' captures: 1: meta.mapping.key.bibtex string.unquoted.key.bibtex @@ -74,8 +75,8 @@ contexts: push: - clear_scopes: 1 - meta_content_scope: meta.mapping.value.bibtex - - match: "(?=[,}])" - pop: true + - match: (?=[,}]) + pop: 1 - include: string_content - include: integer - include: variables @@ -93,7 +94,7 @@ contexts: - meta_content_scope: meta.mapping.bibtex - match: \) scope: punctuation.section.entry.end.bibtex - pop: true + pop: 1 - match: '([a-zA-Z]+)(\s*(=)\s*)' captures: 1: meta.mapping.key.bibtex string.unquoted.key.bibtex @@ -102,8 +103,8 @@ contexts: push: - clear_scopes: 1 - meta_content_scope: meta.mapping.value.bibtex - - match: "(?=[,)])" - pop: true + - match: (?=[,)]) + pop: 1 - include: string_content - include: integer - include: variables @@ -114,7 +115,7 @@ contexts: push: - meta_scope: comment.block.bibtex - match: (?=@) - pop: true + pop: 1 integer: - match: \d+ scope: meta.number.integer.decimal.bibtex constant.numeric.value.bibtex @@ -130,7 +131,7 @@ contexts: push: - match: '\}' scope: punctuation.definition.group.end.bibtex - pop: true + pop: 1 - include: nested_braces string_content: - match: '"' @@ -139,7 +140,7 @@ contexts: - meta_scope: string.quoted.double.bibtex - match: '"' scope: punctuation.definition.string.end.bibtex - pop: true + pop: 1 - include: nested_braces - match: '\{' scope: punctuation.definition.string.begin.bibtex @@ -147,7 +148,7 @@ contexts: - meta_scope: string.quoted.other.braces.bibtex - match: '\}' scope: punctuation.definition.string.end.bibtex - pop: true + pop: 1 - match: "@" scope: invalid.illegal.at-sign.bibtex - include: nested_braces diff --git a/LaTeX/DocStrip.sublime-syntax b/LaTeX/DocStrip.sublime-syntax index f4777a8eb4..73995e2f6f 100644 --- a/LaTeX/DocStrip.sublime-syntax +++ b/LaTeX/DocStrip.sublime-syntax @@ -4,7 +4,8 @@ # https://www.texlive.info/CTAN/macros/latex/base/docstrip.pdf name: TeX (DocStrip) scope: source.tex.docstrip -version: 1 +version: 2 + extends: Packages/LaTeX/TeX.sublime-syntax file_extensions: diff --git a/LaTeX/LaTeX Log.sublime-syntax b/LaTeX/LaTeX Log.sublime-syntax index 2d2890e2fa..00837d28d6 100644 --- a/LaTeX/LaTeX Log.sublime-syntax +++ b/LaTeX/LaTeX Log.sublime-syntax @@ -2,6 +2,7 @@ --- name: LaTeX Log scope: text.log.latex +version: 2 first_line_match: 'This is (pdf|pdfe)?TeXk?, Version ' diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index 0504e4963b..3558c88d44 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -3,6 +3,7 @@ # http://www.sublimetext.com/docs/syntax.html name: LaTeX scope: text.tex.latex +version: 2 extends: TeX.sublime-syntax @@ -47,7 +48,7 @@ contexts: - meta_scope: meta.group.bracket.latex - match: \] scope: punctuation.definition.group.bracket.end.latex - pop: true + pop: 1 - include: general-constants - include: general-commands - include: braces @@ -58,7 +59,7 @@ contexts: - meta_scope: meta.group.brace.tex - match: \} scope: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 - include: main argument: @@ -364,14 +365,14 @@ contexts: - meta_scope: meta.function.box.latex - match: \} scope: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 - include: main - match: ((\\)(?:framebox|makebox))\b captures: 1: support.function.box.latex 2: punctuation.definition.backslash.latex push: - - [{meta_scope: meta.function.box.latex}, {match: '', pop: true}] + - [{meta_scope: meta.function.box.latex}, {match: '', pop: 1}] - argument - optional-arguments - match: ((\\)parbox)\b @@ -379,7 +380,7 @@ contexts: 1: support.function.box.latex 2: punctuation.definition.backslash.latex push: - - [{meta_scope: meta.function.box.latex}, {match: '', pop: true}] + - [{meta_scope: meta.function.box.latex}, {match: '', pop: 1}] - argument - argument - optional-arguments @@ -388,48 +389,42 @@ contexts: 1: support.function.box.latex 2: punctuation.definition.backslash.latex push: - - [{meta_scope: meta.function.box.latex}, {match: '', pop: true}] + - [{meta_scope: meta.function.box.latex}, {match: '', pop: 1}] - argument - optional-arguments preamble: - match: (\\)documentclass\b + scope: meta.preamble.documentclass.latex keyword.control.preamble.latex captures: - 0: keyword.control.preamble.latex 1: punctuation.definition.backslash.latex push: - - meta_scope: meta.preamble.documentclass.latex + - meta_content_scope: meta.preamble.documentclass.latex - include: general-optional-arguments - match: \{ scope: punctuation.definition.group.brace.begin.tex set: - meta_scope: meta.preamble.documentclass.latex meta.group.brace.tex + - include: brace-group-end - match: '[A-Za-z[:digit:]-]' scope: support.class.latex - - match: \} - scope: punctuation.definition.group.brace.end.tex - pop: true - - match: '' - pop: true + - include: immediately-pop - match: (\\)usepackage\b + scope: meta.preamble.usepackage.latex keyword.control.preamble.latex captures: - 0: keyword.control.preamble.latex 1: punctuation.definition.backslash.latex push: - - meta_scope: meta.preamble.usepackage.latex + - meta_content_scope: meta.preamble.usepackage.latex - include: general-optional-arguments - match: \{ scope: punctuation.definition.group.brace.begin.tex set: - meta_scope: meta.preamble.usepackage.latex meta.group.brace.tex - - match: \} - scope: punctuation.definition.group.brace.end.tex - pop: true + - include: brace-group-end - match: '[A-Za-z[:digit:]-]*' scope: support.class.latex - - match: '' - pop: true + - include: immediately-pop includes: - match: ((\\)(?:include|includeonly))(\{) @@ -497,7 +492,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 lists: - match: ((\\)begin)(\{)\s*(itemize\*?)\s*(\}) @@ -516,7 +511,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 - include: main - match: ((\\)begin)(\{)\s*(enumerate\*?)\s*(\}) captures: @@ -534,7 +529,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 - include: main - match: ((\\)begin)(\{)\s*(list\*?)\s*(\}) captures: @@ -552,7 +547,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 - include: main - match: ((\\)begin)(\{)\s*(description\*?)\s*(\}) captures: @@ -570,7 +565,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 - include: main ###[ MATH ]#################################################################### @@ -582,20 +577,20 @@ contexts: inline-math-ensuremath: - match: (\\)ensuremath{{endcs}} - scope: support.function.ensuremath.latex + scope: meta.function.ensuremath.latex support.function.ensuremath.latex captures: 1: punctuation.definition.backslash.latex push: inline-math-ensuremath-begin inline-math-ensuremath-begin: - - meta_scope: meta.function.ensuremath.latex + - meta_content_scope: meta.function.ensuremath.latex - match: \{ scope: punctuation.definition.group.brace.begin.tex set: inline-math-ensuremath-body - include: paragraph-pop inline-math-ensuremath-body: - - meta_scope: meta.function.ensuremath.latex + - meta_scope: meta.function.ensuremath.latex meta.group.brace.tex - meta_content_scope: meta.environment.math.inline.ensuremath.latex markup.math.inline - include: brace-group-end - include: math-content @@ -614,7 +609,7 @@ contexts: inline-math-parens-end: - match: \\\) scope: string.other.math.latex punctuation.definition.string.end.latex - pop: true + pop: 1 block-math: - meta_append: true @@ -650,7 +645,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 block-math-brackets: - match: \\\[ @@ -666,12 +661,12 @@ contexts: block-math-brackets-end: - match: \\\] scope: string.other.math.latex punctuation.definition.string.end.latex - pop: true + pop: 1 math-content: - meta_prepend: true - match: (?=\}) - pop: true + pop: 1 - include: verb - include: text-decorators - include: references @@ -685,7 +680,7 @@ contexts: 1: support.function.includegraphics.latex 2: punctuation.definition.backslash.latex push: - - [{meta_scope: meta.function.includegraphics.latex}, {match: '', pop: true}] + - [{meta_scope: meta.function.includegraphics.latex}, {match: '', pop: 1}] - argument - optional-arguments @@ -711,7 +706,7 @@ contexts: - meta_content_scope: markup.raw.verb.latex - match: \3 scope: punctuation.definition.verb.latex - pop: true + pop: 1 ###[ FONTS ]#################################################################### @@ -1031,7 +1026,7 @@ contexts: expect-text-markup-open-brace: - match: \{ scope: punctuation.definition.group.brace.begin.tex - pop: true + pop: 1 - match: (?=\S) pop: 3 @@ -1111,7 +1106,7 @@ contexts: - include: brace-group-end - include: main - match: (?=\S) - pop: true + pop: 1 - match: |- (?x) ((\\)footnotemark)\b @@ -1162,7 +1157,7 @@ contexts: scope: constant.other.citation.latex - include: brace-group-end - match: '' - pop: true + pop: 1 - match: |- (?x) ( @@ -1184,7 +1179,7 @@ contexts: scope: constant.other.reference.latex - include: brace-group-end - match: '' - pop: true + pop: 1 - match: ((\\)label)(\{) captures: 1: support.function.label.latex storage.type.label.latex @@ -1207,7 +1202,7 @@ contexts: push: - include: general-optional-arguments - match: '' - pop: true + pop: 1 - match: ((\\)end)(\{)\s*(\w*)\*?\s*(\}) captures: 1: support.function.end.latex keyword.control.flow.end.latex @@ -1227,30 +1222,29 @@ contexts: # listings package pkglistings: - match: (\\)lstinline\b + scope: meta.environment.verbatim.lstinline.latex support.function.lstinline.latex captures: - 0: support.function.lstinline.latex 1: punctuation.definition.backslash.latex push: - meta_include_prototype: false - - meta_scope: meta.environment.verbatim.lstinline.latex + - meta_content_scope: meta.environment.verbatim.lstinline.latex - include: general-optional-arguments - match: \{ scope: punctuation.definition.group.brace.begin.tex set: - meta_include_prototype: false - - meta_scope: meta.group.brace.tex - - meta_content_scope: meta.environment.verbatim.lstinline.latex markup.raw.verb.latex - - match: '\}' - scope: meta.environment.verbatim.lstinline.latex punctuation.definition.group.brace.end.tex - pop: true + - meta_scope: meta.environment.verbatim.lstinline.latex meta.group.brace.tex + - meta_content_scope: markup.raw.verb.latex + - include: brace-group-end - match: (\W) scope: punctuation.definition.verb.latex set: - meta_include_prototype: false - - meta_content_scope: meta.environment.verbatim.lstinline.latex markup.raw.verb.latex + - meta_scope: meta.environment.verbatim.lstinline.latex + - meta_content_scope: markup.raw.verb.latex - match: \1 - scope: meta.environment.verbatim.lstinline.latex punctuation.definition.verb.latex - pop: true + scope: punctuation.definition.verb.latex + pop: 1 - match: ((\\)begin)(\{)(lstlisting)(\}) captures: @@ -1269,7 +1263,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 - include: general-optional-arguments - match: .*(%\s*(?i:c))$ captures: @@ -1377,7 +1371,7 @@ contexts: push: - meta_scope: meta.environment.embedded.generic.latex markup.raw.verb.latex - match: (?=\\end\{lstlisting\}) - pop: true + pop: 1 minted: - include: minted-env @@ -1401,7 +1395,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 - include: general-optional-arguments - match: (\{)(c)(\}) captures: @@ -1591,7 +1585,7 @@ contexts: push: - meta_scope: meta.environment.embedded.generic.latex markup.raw.verb.latex - match: (?=\\end\{minted\}) - pop: true + pop: 1 mint: - match: ((\\)mint)\b|((\\)mintinline)\b @@ -1926,7 +1920,7 @@ contexts: 1: punctuation.definition.group.brace.begin.tex 2: punctuation.definition.verb.latex - match: '' - pop: true + pop: 1 # comment package pkgcomment: @@ -1940,7 +1934,7 @@ contexts: captures: 0: punctuation.definition.comment.end.latex 1: punctuation.definition.backslash.latex - pop: true + pop: 1 - match: ((\\)begin)(\{)\s*(comment)\s*(\}) captures: 1: support.function.begin.latex keyword.control.flow.begin.latex @@ -1958,7 +1952,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 # beamer support beamer: @@ -1978,7 +1972,7 @@ contexts: 3: punctuation.definition.group.brace.begin.tex 4: variable.parameter.function.latex 5: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 - include: frametitles - include: main @@ -2046,18 +2040,17 @@ contexts: - meta_content_scope: meta.environment.tabular.latex meta.function.column-spec.latex - include: array-preamble - match: \} - scope: punctuation.definition.group.brace.end.tex + scope: meta.function.column-spec.latex punctuation.definition.group.brace.end.tex set: - - meta_content_scope: meta.environment.tabular.latex + - meta_scope: meta.environment.tabular.latex - match: ((\\)end)(\{)(tabular)(\}) - scope: meta.environment.tabular.latex captures: 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 5: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 - include: main @@ -2076,7 +2069,7 @@ contexts: - match: (?:p|m|b)(?=\s*\{) scope: support.function.parbox-column.latex push: - - [{meta_scope: meta.function.parbox-column.latex}, {match: '', pop: true}] + - [{meta_scope: meta.function.parbox-column.latex}, {match: '', pop: 1}] - argument - match: (>)\s*(\{) @@ -2136,7 +2129,7 @@ contexts: scope: constant.numeric.array-count.latex - include: general-commands - match: \} - scope: punctuation.definition.group.brace.end.tex + scope: meta.function.insert-repeated-count.latex punctuation.definition.group.brace.end.tex set: - match: \{ scope: meta.function.insert-repeated-content.latex punctuation.definition.group.brace.begin.tex @@ -2145,6 +2138,6 @@ contexts: - include: array-preamble - match: \} scope: meta.function.insert-repeated-content.latex punctuation.definition.group.brace.end.tex - pop: true + pop: 1 - match: '' - pop: true + pop: 1 diff --git a/LaTeX/TeX.sublime-syntax b/LaTeX/TeX.sublime-syntax index 1f76a6fc1c..87ee91868e 100644 --- a/LaTeX/TeX.sublime-syntax +++ b/LaTeX/TeX.sublime-syntax @@ -3,6 +3,7 @@ # http://www.sublimetext.com/docs/syntax.html name: TeX scope: text.tex +version: 2 file_extensions: - sty @@ -156,7 +157,7 @@ contexts: - meta_include_prototype: false - match: \{ scope: punctuation.definition.group.brace.begin.tex - pop: true + pop: 1 brace-group-body: - meta_scope: meta.group.brace.tex @@ -166,7 +167,7 @@ contexts: brace-group-end: - match: \} scope: punctuation.definition.group.brace.end.tex - pop: true + pop: 1 boxes: - match: ((\\)[hv]box)\s*(\{) @@ -550,7 +551,7 @@ contexts: inline-math-dollar-end: - match: \$ scope: string.other.math.tex punctuation.definition.string.end.tex - pop: true + pop: 1 block-math: - match: \$\$ @@ -566,7 +567,7 @@ contexts: block-math-dollar-end: - match: \$\$ scope: string.other.math.tex punctuation.definition.string.end.tex - pop: true + pop: 1 math-content: - include: math-builtin @@ -707,17 +708,17 @@ contexts: # matches any nospace and pops the context else-pop: - match: (?=\S) - pop: true + pop: 1 immediately-pop: - match: '' - pop: true + pop: 1 # pops out of the current context if there is a new paragraph paragraph-pop: - match: ^(?=\s*$) - pop: true + pop: 1 unmatched-brace-pop: - match: (?=}) - pop: true + pop: 1 diff --git a/LaTeX/tests/syntax_test_latex.tex b/LaTeX/tests/syntax_test_latex.tex index 0d943f0eb8..271c755bc3 100644 --- a/LaTeX/tests/syntax_test_latex.tex +++ b/LaTeX/tests/syntax_test_latex.tex @@ -3,14 +3,30 @@ % <- text.tex.latex \documentclass[12pt]{article} -% ^ keyword.control.preamble.latex -% ^ support.class.latex +% <- meta.preamble.documentclass.latex keyword.control.preamble.latex punctuation.definition.backslash.latex +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preamble.documentclass.latex - meta.preamble.documentclass meta.preamble.documentclass +% ^^^^^^ meta.group.bracket.latex +% ^^^^^^^^^ meta.group.brace.tex +%^^^^^^^^^^^^^ keyword.control.preamble.latex +% ^ punctuation.definition.group.bracket.begin.latex +% ^ punctuation.definition.group.bracket.end.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^^^^^^^ support.class.latex +% ^ punctuation.definition.group.brace.end.tex \usepackage[args]{mypackage, anotherpackage} -% ^ keyword.control.preamble.latex -% ^ support.class.latex -% ^ -support.class.latex -% ^ support.class.latex +% <- meta.preamble.usepackage.latex keyword.control.preamble.latex punctuation.definition.backslash.latex +%^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.preamble.usepackage.latex - meta.preamble.usepackage meta.preamble.usepackage +% ^^^^^^ meta.group.bracket.latex +% ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.group.brace.tex +%^^^^^^^^^^ keyword.control.preamble.latex +% ^ punctuation.definition.group.bracket.begin.latex +% ^^^^ +% ^ punctuation.definition.group.bracket.end.latex +% ^ punctuation.definition.group.brace.begin.tex +% ^^^^^^^^^ support.class.latex +% ^^^^^^^^^^^^^^ support.class.latex +% ^ punctuation.definition.group.brace.end.tex \usepackage[pdftex, %plainpages={false}, @@ -792,7 +808,8 @@ \subsubsection{name} \ensuremath{f(x) = x^2} % <- meta.function.ensuremath.latex support.function.ensuremath.latex punctuation.definition.backslash.latex -%^^^^^^^^^^^^^^^^^^^^^^ meta.function.ensuremath.latex +%^^^^^^^^^^ meta.function.ensuremath.latex - meta.function meta.function - meta.group +% ^^^^^^^^^^^^ meta.function.ensuremath.latex meta.group.brace.tex - meta.function meta.function % ^ - meta.environment.math - markup.math % ^^^^^^^^^^ meta.environment.math.inline.ensuremath.latex markup.math.inline % ^ - meta.environment.math - markup.math @@ -801,7 +818,7 @@ \subsubsection{name} % ^ punctuation.definition.group.brace.end.tex \ensuremath % -%^^^^^^^^^^^^^ meta.function.ensuremath.latex +%^^^^^^^^^^^^^ meta.function.ensuremath.latex - meta.function meta.function %^^^^^^^^^^ support.function.ensuremath.latex % ^^ comment.line.percentage.tex {x^2}{normal text} @@ -914,7 +931,7 @@ \subsubsection{name} \end{lstlisting} \lstinline{var x = 15;} -% ^^^^^^^^^^^^^^^^^^^^^ meta.environment.verbatim.lstinline.latex +% ^^^^^^^^^^^^^^^^^^^^^ meta.environment.verbatim.lstinline.latex - meta.environment meta.environment % ^^^^^^^^^^^^^ meta.group.brace.tex % ^ punctuation.definition.group.brace.begin % ^^^^^^^^^^^ markup.raw.verb.latex @@ -922,7 +939,7 @@ \subsubsection{name} % ^ - meta.environment.verbatim.lstinline.latex \lstinline|var x = 15;| -% ^^^^^^^^^^^^^^^^^^^^^ meta.environment.verbatim.lstinline.latex +% ^^^^^^^^^^^^^^^^^^^^^ meta.environment.verbatim.lstinline.latex - meta.environment meta.environment % ^^^^^^^^^^^ markup.raw.verb.latex % ^ - meta.environment.verbatim.lstinline.latex From 5af53cd4e0c084ad2ec9418a37c1d9682eef32d4 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 2 Nov 2023 20:59:00 +0100 Subject: [PATCH 46/46] [LaTeX] Replace some ugly anonymous multi-push contexts --- LaTeX/LaTeX.sublime-syntax | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/LaTeX/LaTeX.sublime-syntax b/LaTeX/LaTeX.sublime-syntax index 3558c88d44..94a81ac124 100644 --- a/LaTeX/LaTeX.sublime-syntax +++ b/LaTeX/LaTeX.sublime-syntax @@ -363,16 +363,14 @@ contexts: 3: punctuation.definition.group.brace.begin.tex push: - meta_scope: meta.function.box.latex - - match: \} - scope: punctuation.definition.group.brace.end.tex - pop: 1 + - include: brace-group-end - include: main - match: ((\\)(?:framebox|makebox))\b captures: 1: support.function.box.latex 2: punctuation.definition.backslash.latex push: - - [{meta_scope: meta.function.box.latex}, {match: '', pop: 1}] + - box-meta - argument - optional-arguments - match: ((\\)parbox)\b @@ -380,7 +378,7 @@ contexts: 1: support.function.box.latex 2: punctuation.definition.backslash.latex push: - - [{meta_scope: meta.function.box.latex}, {match: '', pop: 1}] + - box-meta - argument - argument - optional-arguments @@ -389,10 +387,15 @@ contexts: 1: support.function.box.latex 2: punctuation.definition.backslash.latex push: - - [{meta_scope: meta.function.box.latex}, {match: '', pop: 1}] + - box-meta - argument - optional-arguments + box-meta: + - meta_include_prototype: false + - meta_scope: meta.function.box.latex + - include: immediately-pop + preamble: - match: (\\)documentclass\b scope: meta.preamble.documentclass.latex keyword.control.preamble.latex @@ -680,10 +683,15 @@ contexts: 1: support.function.includegraphics.latex 2: punctuation.definition.backslash.latex push: - - [{meta_scope: meta.function.includegraphics.latex}, {match: '', pop: 1}] + - includegraphics-meta - argument - optional-arguments + includegraphics-meta: + - meta_include_prototype: false + - meta_scope: meta.function.includegraphics.latex + - include: immediately-pop + url: - match: ((\\)(?:url|href|path))(\{)([^}]*)(\}) scope: meta.function.link.url.latex @@ -1024,9 +1032,7 @@ contexts: # utility that waits for the brace, and pops the three contexts # we push for each \text... command otherwise expect-text-markup-open-brace: - - match: \{ - scope: punctuation.definition.group.brace.begin.tex - pop: 1 + - include: brace-group-begin - match: (?=\S) pop: 3