From 0e8b42fa44e15df2692f34621e4e34d286415134 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 25 Jun 2026 15:01:42 +0200 Subject: [PATCH] feature: improve `$...$` and `$$...$$` and add `\(...\)` and `\[...\]` (#34) Signed-off-by: squidfunk --- .../scripts/grammar/tokenizer.ts | 4 +- .../src/python-markdown.tmLanguage.yml | 31 +- .../inline_flow/emphasis.scopes.json | 16 +- .../inline_flow/footnote.scopes.json | 4 +- .../snapshots/inline_flow/image.scopes.json | 53 ++- .../inline_flow/image_reference.scopes.json | 53 ++- .../snapshots/inline_flow/keys.scopes.json | 4 +- .../snapshots/inline_flow/link.scopes.json | 4 +- .../inline_flow/link_reference.scopes.json | 33 +- .../snapshots/inline_flow/math.scopes.json | 397 ++++++++++-------- .../inline_flow/smart_symbol.scopes.json | 4 +- .../test/specs/inline_flow/math.md | 105 ++--- .../syntaxes/python-markdown.tmLanguage.json | 33 +- 13 files changed, 474 insertions(+), 267 deletions(-) diff --git a/grammars/textmate/python-markdown/scripts/grammar/tokenizer.ts b/grammars/textmate/python-markdown/scripts/grammar/tokenizer.ts index cf5fcc4..c0990e2 100644 --- a/grammars/textmate/python-markdown/scripts/grammar/tokenizer.ts +++ b/grammars/textmate/python-markdown/scripts/grammar/tokenizer.ts @@ -175,8 +175,8 @@ function getEmbeddedGrammar( if (scope === "source.yaml") { return getYamlGrammar(); } - if (scope === "text.tex.latex") { - return { name: "Test LaTeX", scopeName: scope, patterns: [] }; + if (scope === "text.html.markdown.math") { + return { name: "Test Markdown Math", scopeName: scope, patterns: [] }; } // Return a minimal grammar for every embedded language scope diff --git a/grammars/textmate/python-markdown/src/python-markdown.tmLanguage.yml b/grammars/textmate/python-markdown/src/python-markdown.tmLanguage.yml index fd8d017..74bad72 100644 --- a/grammars/textmate/python-markdown/src/python-markdown.tmLanguage.yml +++ b/grammars/textmate/python-markdown/src/python-markdown.tmLanguage.yml @@ -48,7 +48,6 @@ repository: flow: patterns: - - include: "#escape" - include: "#table" - include: "#admonition" - include: "#details" @@ -377,25 +376,25 @@ repository: math: patterns: - name: markup.math.block.markdown - begin: (?:^|\G)(\$\$) + begin: (?:^|\G)[ \t]*(\$\$)[ \t]*$ beginCaptures: 1: { name: punctuation.definition.math.begin.markdown } - contentName: meta.embedded.block.latex - end: (\$\$)([ \t]*)(\r?\n|\r)? + contentName: meta.embedded.math.markdown + end: (?:^|\G)[ \t]*(\$\$)([ \t]*)(\r?\n|\r)? endCaptures: 1: { name: punctuation.definition.math.end.markdown } patterns: - - include: text.tex.latex + - include: text.html.markdown.math - name: markup.math.block.markdown - begin: (?:^|\G)(\\\[) + begin: (?:^|\G)[ \t]*(\\\[)[ \t]*$ beginCaptures: 1: { name: punctuation.definition.math.begin.markdown } - contentName: meta.embedded.block.latex - end: (\\\])([ \t]*)(\r?\n|\r)? + contentName: meta.embedded.math.markdown + end: (?:^|\G)[ \t]*(\\\])([ \t]*)(\r?\n|\r)? endCaptures: 1: { name: punctuation.definition.math.end.markdown } patterns: - - include: text.tex.latex + - include: text.html.markdown.math fenced_code: patterns: @@ -654,25 +653,25 @@ repository: inline_math: patterns: - name: markup.math.inline.markdown - begin: (\$)(?=[^\s$]) + begin: (?