From 15dd57067226e6025c7c78bd9ca63de6ff6eb35a Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 2 Jul 2018 11:51:58 -0400 Subject: [PATCH 1/6] Change `$base` to `$self` The use of `'include': '$base'` causes LaTeX syntax highlighting to not work correctly when embedded in another grammar. --- grammars/latex.cson | 38 +++++++++++++++++++------------------- grammars/tex.cson | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/grammars/latex.cson b/grammars/latex.cson index 3d6c533..6a24e57 100644 --- a/grammars/latex.cson +++ b/grammars/latex.cson @@ -122,7 +122,7 @@ 'name': 'support.variable.expl3.latex' } { - 'include': '$base' + 'include': '$self' } ] } @@ -147,7 +147,7 @@ 'name': 'support.variable.expl3.latex' } { - 'include': '$base' + 'include': '$self' } ] } @@ -1448,7 +1448,7 @@ 'name': 'meta.function.environment.math.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -1476,7 +1476,7 @@ 'name': 'meta.function.environment.math.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -1504,7 +1504,7 @@ 'name': 'meta.function.environment.math.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -1526,7 +1526,7 @@ 'name': 'meta.function.environment.math.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -1580,17 +1580,17 @@ 'name': 'meta.cell.environment.tabular.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } { - 'include': '$base' + 'include': '$self' } ] } { - 'include': '$base' + 'include': '$self' } ] } @@ -1611,7 +1611,7 @@ 'name': 'meta.function.environment.list.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -1673,7 +1673,7 @@ 'name': 'meta.function.environment.general.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -1712,7 +1712,7 @@ 'name': 'punctuation.definition.marginpar.end.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -1745,7 +1745,7 @@ 'name': 'punctuation.definition.footnote.end.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -1766,7 +1766,7 @@ 'name': 'meta.function.emph.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -1788,7 +1788,7 @@ 'name': 'meta.function.textit.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -1809,7 +1809,7 @@ 'name': 'meta.function.textbf.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -1830,7 +1830,7 @@ 'name': 'meta.function.texttt.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -2018,7 +2018,7 @@ 'name': 'string.other.math.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } @@ -2034,7 +2034,7 @@ 'name': 'string.other.math.latex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } diff --git a/grammars/tex.cson b/grammars/tex.cson index 30db355..e3d06e0 100644 --- a/grammars/tex.cson +++ b/grammars/tex.cson @@ -82,7 +82,7 @@ 'name': 'meta.group.braces.tex' 'patterns': [ { - 'include': '$base' + 'include': '$self' } ] } From 1a02b73157a7e9f46ed4989eab965f211c86c2c4 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 2 Jul 2018 11:54:28 -0400 Subject: [PATCH 2/6] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index df5a22d..724ded1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ based on http://keepachangelog.com/en/1.0.0/ - Grammar for `comment` environment. ### Changed +- Changed `'include': '$base'` to `'include': '$self'`. This improves highlighting when embedded in another grammar, such as Markdown. - Set 'softWrap' to be true by default in LaTeX files. - Changed inline math snippet from `$...$` to `\(...\)`. From e6de13df22d1e43dc9c28c750f4004a842721e05 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 2 Jul 2018 14:19:43 -0400 Subject: [PATCH 3/6] Add $self recursion for {...} in text.tex.latex - Allows for use of text.tex.latex and text.tex rules within arbitrary brackets without resorting to using `$base` --- grammars/latex.cson | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/grammars/latex.cson b/grammars/latex.cson index 6a24e57..95bce0e 100644 --- a/grammars/latex.cson +++ b/grammars/latex.cson @@ -2054,6 +2054,22 @@ 'match': '(?:<|>)(\\{)\\$(\\})' 'name': 'meta.column-specials.latex' } + { + 'begin': '\\{' + 'beginCaptures': + '0': + 'name': 'punctuation.section.group.begin.tex.latex' + 'end': '\\}' + 'endCaptures': + '0': + 'name': 'punctuation.section.group.end.tex.latex' + 'name': 'meta.group.braces.tex.latex' + 'patterns': [ + { + 'include': '$self' + } + ] + } { 'include': 'text.tex' } From 198a37fe807f988695c4034324b9e2dca5298c58 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Thu, 19 Jul 2018 10:00:44 -0400 Subject: [PATCH 4/6] Add $self recursion for {...} in memoir and beamer files. - Allows for use of `$self` instead of `$base` within text.tex.latex. --- grammars/latex-beamer.cson | 16 ++++++++++++++++ grammars/latex-memoir.cson | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/grammars/latex-beamer.cson b/grammars/latex-beamer.cson index b16c267..13752fb 100644 --- a/grammars/latex-beamer.cson +++ b/grammars/latex-beamer.cson @@ -59,6 +59,22 @@ 'match': '((\\\\)frametitle)(\\{)(.*)(\\})' 'name': 'meta.function.frametitle.latex' } + { + 'begin': '\\{' + 'beginCaptures': + '0': + 'name': 'punctuation.section.group.begin.tex.latex.beamer' + 'end': '\\}' + 'endCaptures': + '0': + 'name': 'punctuation.section.group.end.tex.latex.beamer' + 'name': 'meta.group.braces.tex.latex.beamer' + 'patterns': [ + { + 'include': '$self' + } + ] + } { 'include': 'text.tex.latex' } diff --git a/grammars/latex-memoir.cson b/grammars/latex-memoir.cson index ea82460..7b8b7ff 100644 --- a/grammars/latex-memoir.cson +++ b/grammars/latex-memoir.cson @@ -67,6 +67,22 @@ } ] } + { + 'begin': '\\{' + 'beginCaptures': + '0': + 'name': 'punctuation.section.group.begin.tex.latex.memoir' + 'end': '\\}' + 'endCaptures': + '0': + 'name': 'punctuation.section.group.end.tex.latex.memoir' + 'name': 'meta.group.braces.tex.latex.memoir' + 'patterns': [ + { + 'include': '$self' + } + ] + } { 'include': 'text.tex.latex' } From ff44fa6fc2ab3567ce517a335cb6637d18ae938a Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Tue, 14 Aug 2018 10:45:32 -0400 Subject: [PATCH 5/6] Add arbitrary \begin-\end environments to memoir and beamer files --- grammars/latex-beamer.cson | 24 ++++++++++++++++++++++++ grammars/latex-memoir.cson | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/grammars/latex-beamer.cson b/grammars/latex-beamer.cson index 13752fb..2ceca8d 100644 --- a/grammars/latex-beamer.cson +++ b/grammars/latex-beamer.cson @@ -59,6 +59,9 @@ 'match': '((\\\\)frametitle)(\\{)(.*)(\\})' 'name': 'meta.function.frametitle.latex' } + # These two rules are repeated from `latex.cson` in order to support the use + # of `$self` instead of `$base`. The former allows for correct embedding of + # LaTeX rules within other grammars, for example Markdown. { 'begin': '\\{' 'beginCaptures': @@ -75,6 +78,27 @@ } ] } + { + 'begin': '(?:\\s*)((\\\\)begin)(\\{)(\\w+[*]?)(\\})' + 'captures': + '1': + 'name': 'support.function.be.latex.beamer' + '2': + 'name': 'punctuation.definition.function.latex.beamer' + '3': + 'name': 'punctuation.definition.arguments.latex.beamer' + '4': + 'name': 'variable.parameter.function.latex.beamer' + '5': + 'name': 'punctuation.definition.arguments.latex.beamer' + 'end': '((\\\\)end)(\\{)(\\4)(\\})(?:\\s*\\n)?' + 'name': 'meta.function.environment.$4.latex.beamer' + 'patterns': [ + { + 'include': '$self' + } + ] + } { 'include': 'text.tex.latex' } diff --git a/grammars/latex-memoir.cson b/grammars/latex-memoir.cson index 7b8b7ff..d2309ed 100644 --- a/grammars/latex-memoir.cson +++ b/grammars/latex-memoir.cson @@ -67,6 +67,9 @@ } ] } + # These two rules are repeated from `latex.cson` in order to support the use + # of `$self` instead of `$base`. The former allows for correct embedding of + # LaTeX rules within other grammars, for example Markdown. { 'begin': '\\{' 'beginCaptures': @@ -83,6 +86,27 @@ } ] } + { + 'begin': '(?:\\s*)((\\\\)begin)(\\{)(\\w+[*]?)(\\})' + 'captures': + '1': + 'name': 'support.function.be.latex.memoir' + '2': + 'name': 'punctuation.definition.function.latex.memoir' + '3': + 'name': 'punctuation.definition.arguments.latex.memoir' + '4': + 'name': 'variable.parameter.function.latex.memoir' + '5': + 'name': 'punctuation.definition.arguments.latex.memoir' + 'end': '((\\\\)end)(\\{)(\\4)(\\})(?:\\s*\\n)?' + 'name': 'meta.function.environment.$4.latex.memoir' + 'patterns': [ + { + 'include': '$self' + } + ] + } { 'include': 'text.tex.latex' } From 58362185e27cacc72dbcb7b589c9aa9df2553dbf Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Tue, 4 Sep 2018 10:06:07 -0400 Subject: [PATCH 6/6] Revert last commit --- grammars/latex-beamer.cson | 25 ++----------------------- grammars/latex-memoir.cson | 25 ++----------------------- 2 files changed, 4 insertions(+), 46 deletions(-) diff --git a/grammars/latex-beamer.cson b/grammars/latex-beamer.cson index 2ceca8d..31f820b 100644 --- a/grammars/latex-beamer.cson +++ b/grammars/latex-beamer.cson @@ -59,8 +59,8 @@ 'match': '((\\\\)frametitle)(\\{)(.*)(\\})' 'name': 'meta.function.frametitle.latex' } - # These two rules are repeated from `latex.cson` in order to support the use - # of `$self` instead of `$base`. The former allows for correct embedding of + # The following rule is repeated from `latex.cson` in order to support the use + # of `$self` instead of `$base`. This allows for correct embedding of # LaTeX rules within other grammars, for example Markdown. { 'begin': '\\{' @@ -78,27 +78,6 @@ } ] } - { - 'begin': '(?:\\s*)((\\\\)begin)(\\{)(\\w+[*]?)(\\})' - 'captures': - '1': - 'name': 'support.function.be.latex.beamer' - '2': - 'name': 'punctuation.definition.function.latex.beamer' - '3': - 'name': 'punctuation.definition.arguments.latex.beamer' - '4': - 'name': 'variable.parameter.function.latex.beamer' - '5': - 'name': 'punctuation.definition.arguments.latex.beamer' - 'end': '((\\\\)end)(\\{)(\\4)(\\})(?:\\s*\\n)?' - 'name': 'meta.function.environment.$4.latex.beamer' - 'patterns': [ - { - 'include': '$self' - } - ] - } { 'include': 'text.tex.latex' } diff --git a/grammars/latex-memoir.cson b/grammars/latex-memoir.cson index d2309ed..7395900 100644 --- a/grammars/latex-memoir.cson +++ b/grammars/latex-memoir.cson @@ -67,8 +67,8 @@ } ] } - # These two rules are repeated from `latex.cson` in order to support the use - # of `$self` instead of `$base`. The former allows for correct embedding of + # The following rule is repeated from `latex.cson` in order to support the use + # of `$self` instead of `$base`. This allows for correct embedding of # LaTeX rules within other grammars, for example Markdown. { 'begin': '\\{' @@ -86,27 +86,6 @@ } ] } - { - 'begin': '(?:\\s*)((\\\\)begin)(\\{)(\\w+[*]?)(\\})' - 'captures': - '1': - 'name': 'support.function.be.latex.memoir' - '2': - 'name': 'punctuation.definition.function.latex.memoir' - '3': - 'name': 'punctuation.definition.arguments.latex.memoir' - '4': - 'name': 'variable.parameter.function.latex.memoir' - '5': - 'name': 'punctuation.definition.arguments.latex.memoir' - 'end': '((\\\\)end)(\\{)(\\4)(\\})(?:\\s*\\n)?' - 'name': 'meta.function.environment.$4.latex.memoir' - 'patterns': [ - { - 'include': '$self' - } - ] - } { 'include': 'text.tex.latex' }