From f8cc75937ab893da082746fc037c7f59284d0966 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 5 Aug 2021 13:30:30 -0700 Subject: [PATCH] Fix syntax highlighting of math in markdown lists Fixes #128411 --- .../syntaxes/md-math-block.tmLanguage.json | 48 +- .../test/colorize-fixtures/md-math.md | 13 + .../test/colorize-results/md-math_md.json | 528 ++++++++++++++++++ 3 files changed, 583 insertions(+), 6 deletions(-) diff --git a/extensions/markdown-math/syntaxes/md-math-block.tmLanguage.json b/extensions/markdown-math/syntaxes/md-math-block.tmLanguage.json index 5cb158b2c7a..02a476e1dff 100644 --- a/extensions/markdown-math/syntaxes/md-math-block.tmLanguage.json +++ b/extensions/markdown-math/syntaxes/md-math-block.tmLanguage.json @@ -3,20 +3,22 @@ "injectionSelector": "L:text.html.markdown - (comment, string, meta.paragraph.markdown, markup.math.block.markdown, markup.fenced_code.block.markdown)", "patterns": [ { - "include": "#math_block" + "include": "#double_quote_math_block" + }, + { + "include": "#single_math_block" } ], "repository": { - "math_block": { + "double_quote_math_block": { "name": "markup.math.block.markdown", - "contentName": "meta.embedded.math.markdown", - "begin": "(?<=(^|\\G)\\s*)(\\${1,2})(?=\\s*$)", + "begin": "(?<=(^|\\G)\\s*)(\\${2})(?=\\s*$)", "beginCaptures": { "1": { "name": "punctuation.definition.math.begin.markdown" } }, - "end": "^\\s*(\\${1,2})\\s*$", + "end": "(\\${2})", "endCaptures": { "1": { "name": "punctuation.definition.math.end.markdown" @@ -24,7 +26,41 @@ }, "patterns": [ { - "include": "text.html.markdown.math#math" + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!.*(\\${2}))", + "contentName": "meta.embedded.math.markdown", + "patterns": [ + { + "include": "text.html.markdown.math#math" + } + ] + } + ] + }, + "single_quote_math_block": { + "name": "markup.math.block.markdown", + "begin": "(?<=(^|\\G)\\s*)(\\$)(?=\\s*$)", + "beginCaptures": { + "1": { + "name": "punctuation.definition.math.begin.markdown" + } + }, + "end": "(\\$)", + "endCaptures": { + "1": { + "name": "punctuation.definition.math.end.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!.*(\\$))", + "contentName": "meta.embedded.math.markdown", + "patterns": [ + { + "include": "text.html.markdown.math#math" + } + ] } ] } diff --git a/extensions/vscode-colorize-tests/test/colorize-fixtures/md-math.md b/extensions/vscode-colorize-tests/test/colorize-fixtures/md-math.md index 60963eb8b03..7161eb99a15 100644 --- a/extensions/vscode-colorize-tests/test/colorize-fixtures/md-math.md +++ b/extensions/vscode-colorize-tests/test/colorize-fixtures/md-math.md @@ -74,3 +74,16 @@ $$ \left( \sum_{k=1}^n b_k^2 \right) $$ ``` + + + +- list item + **abc** + $$ + \begin{aligned} + &\text{Any equation} + \\ + &\text {Inconsistent KaTeX keyword highlighting} + \end{aligned} + $$ + **xyz** diff --git a/extensions/vscode-colorize-tests/test/colorize-results/md-math_md.json b/extensions/vscode-colorize-tests/test/colorize-results/md-math_md.json index 888734ec794..9a20eba5bd9 100644 --- a/extensions/vscode-colorize-tests/test/colorize-results/md-math_md.json +++ b/extensions/vscode-colorize-tests/test/colorize-results/md-math_md.json @@ -3903,5 +3903,533 @@ "light_vs": "default: #000000", "hc_black": "default: #FFFFFF" } + }, + { + "c": "", + "t": "text.html.markdown comment.block.html punctuation.definition.comment.html", + "r": { + "dark_plus": "comment: #6A9955", + "light_plus": "comment: #008000", + "dark_vs": "comment: #6A9955", + "light_vs": "comment: #008000", + "hc_black": "comment: #7CA668" + } + }, + { + "c": "-", + "t": "text.html.markdown markup.list.unnumbered.markdown punctuation.definition.list.begin.markdown", + "r": { + "dark_plus": "punctuation.definition.list.begin.markdown: #6796E6", + "light_plus": "punctuation.definition.list.begin.markdown: #0451A5", + "dark_vs": "punctuation.definition.list.begin.markdown: #6796E6", + "light_vs": "punctuation.definition.list.begin.markdown: #0451A5", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "list item", + "t": "text.html.markdown markup.list.unnumbered.markdown meta.paragraph.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "**", + "t": "text.html.markdown markup.list.unnumbered.markdown meta.paragraph.markdown markup.bold.markdown punctuation.definition.bold.markdown", + "r": { + "dark_plus": "markup.bold: #569CD6", + "light_plus": "markup.bold: #000080", + "dark_vs": "markup.bold: #569CD6", + "light_vs": "markup.bold: #000080", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "abc", + "t": "text.html.markdown markup.list.unnumbered.markdown meta.paragraph.markdown markup.bold.markdown", + "r": { + "dark_plus": "markup.bold: #569CD6", + "light_plus": "markup.bold: #000080", + "dark_vs": "markup.bold: #569CD6", + "light_vs": "markup.bold: #000080", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "**", + "t": "text.html.markdown markup.list.unnumbered.markdown meta.paragraph.markdown markup.bold.markdown punctuation.definition.bold.markdown", + "r": { + "dark_plus": "markup.bold: #569CD6", + "light_plus": "markup.bold: #000080", + "dark_vs": "markup.bold: #569CD6", + "light_vs": "markup.bold: #000080", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "$$", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "\\", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex storage.type.function.math.tex punctuation.definition.function.math.tex", + "r": { + "dark_plus": "storage.type: #569CD6", + "light_plus": "storage.type: #0000FF", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "storage.type: #569CD6" + } + }, + { + "c": "begin", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex storage.type.function.math.tex entity.name.function.math.tex", + "r": { + "dark_plus": "entity.name.function: #DCDCAA", + "light_plus": "entity.name.function: #795E26", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "entity.name.function: #DCDCAA" + } + }, + { + "c": "{", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex punctuation.definition.arguments.begin.math.tex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "aligned", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "}", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex punctuation.definition.arguments.end.math.tex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": " &", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "\\", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex storage.type.function.math.tex punctuation.definition.function.math.tex", + "r": { + "dark_plus": "storage.type: #569CD6", + "light_plus": "storage.type: #0000FF", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "storage.type: #569CD6" + } + }, + { + "c": "text", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex storage.type.function.math.tex entity.name.function.math.tex", + "r": { + "dark_plus": "entity.name.function: #DCDCAA", + "light_plus": "entity.name.function: #795E26", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "entity.name.function: #DCDCAA" + } + }, + { + "c": "{", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex punctuation.definition.arguments.begin.math.tex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "Any equation", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "}", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex punctuation.definition.arguments.end.math.tex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "\\\\", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown line.separator.math.tex punctuation.line.separator.math.tex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": " &", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "\\", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown constant.character.math.tex punctuation.definition.constant.math.tex", + "r": { + "dark_plus": "constant.character: #569CD6", + "light_plus": "constant.character: #0000FF", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "constant.character: #569CD6" + } + }, + { + "c": "text", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown constant.character.math.tex", + "r": { + "dark_plus": "constant.character: #569CD6", + "light_plus": "constant.character: #0000FF", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "constant.character: #569CD6" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "{", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown punctuation.math.begin.bracket.curly", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "Inconsistent KaTeX keyword highlighting", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "}", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown punctuation.math.end.bracket.curly", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "\\", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex storage.type.function.math.tex punctuation.definition.function.math.tex", + "r": { + "dark_plus": "storage.type: #569CD6", + "light_plus": "storage.type: #0000FF", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "storage.type: #569CD6" + } + }, + { + "c": "end", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex storage.type.function.math.tex entity.name.function.math.tex", + "r": { + "dark_plus": "entity.name.function: #DCDCAA", + "light_plus": "entity.name.function: #795E26", + "dark_vs": "storage.type: #569CD6", + "light_vs": "storage.type: #0000FF", + "hc_black": "entity.name.function: #DCDCAA" + } + }, + { + "c": "{", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex punctuation.definition.arguments.begin.math.tex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "aligned", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "}", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown meta.function.math.tex punctuation.definition.arguments.end.math.tex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "$$", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": " ", + "t": "text.html.markdown markup.list.unnumbered.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "**", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown punctuation.math.operator.latex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "xyz", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } + }, + { + "c": "**", + "t": "text.html.markdown markup.list.unnumbered.markdown markup.math.block.markdown meta.embedded.math.markdown punctuation.math.operator.latex", + "r": { + "dark_plus": "meta.embedded: #D4D4D4", + "light_plus": "meta.embedded: #000000", + "dark_vs": "meta.embedded: #D4D4D4", + "light_vs": "meta.embedded: #000000", + "hc_black": "meta.embedded: #FFFFFF" + } } ] \ No newline at end of file