From 342e0b5b1ac927c26c1e6872d5c2db8eac7fdd94 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Fri, 26 Apr 2024 17:54:59 +0200 Subject: [PATCH] Syntax: Fix backticks and code-spans in table cells This commit... 1. removes `invalid.deprecated` scoping from backticks in table cells 2. fixes code spans treatment in tables. They are terminated by - `|` cell separator - end of line --- messages/next.md | 1 + syntaxes/Markdown.sublime-syntax | 16 ++++++++++++---- tests/syntax_test_markdown.md | 16 +++++++++++++--- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/messages/next.md b/messages/next.md index b6173b75..825aa4b4 100644 --- a/messages/next.md +++ b/messages/next.md @@ -7,6 +7,7 @@ feedback you can use [GitHub issues][issues]. - fix premature block quote termination - fix extra backticks when creating fenced code blocks (#749) +- fix syntax highlighting of single backticks and code-spans in table cells ## New Features diff --git a/syntaxes/Markdown.sublime-syntax b/syntaxes/Markdown.sublime-syntax index a7c590a9..f043fcfd 100644 --- a/syntaxes/Markdown.sublime-syntax +++ b/syntaxes/Markdown.sublime-syntax @@ -9,7 +9,7 @@ # # The scope suffix should indicate which flavor of Markdown the feature came from, # to help make this syntax definition easier to maintain. -name: Markdown +name: Markdown (MDE) scope: text.html.markdown hidden: true @@ -2910,14 +2910,22 @@ contexts: table-cell-content: - match: (?={{balanced_emphasis}}) push: table-cell-emphasis - - match: (?!{{backticks}})`+ - scope: invalid.deprecated.unescaped-backticks.markdown + - include: table-cell-code-spans - include: table-cell-separators - include: images - - include: literals + - include: critics + - include: math-inline + - include: escapes - include: links - include: markups + table-cell-code-spans: + - match: (`+)[^`|]+(\1) + scope: markup.raw.inline.markdown + captures: + 1: punctuation.definition.raw.begin.markdown + 2: punctuation.definition.raw.end.markdown + table-cell-emphasis: - include: emphasis - include: immediately-pop diff --git a/tests/syntax_test_markdown.md b/tests/syntax_test_markdown.md index 139b54d9..d9165a20 100644 --- a/tests/syntax_test_markdown.md +++ b/tests/syntax_test_markdown.md @@ -2921,8 +2921,9 @@ bar | baz | f\|oo | | ------ | | b `|` az | -| ^^^ meta.table markup.raw.inline - meta.table.header-separator -| ^ meta.table punctuation.separator.table-cell +|^^^^^^^^^^^ meta.table.markdown-gfm - markup.raw +| ^ punctuation.separator.table-cell.markdown +| ^ punctuation.separator.table-cell.markdown | b **|** im | | <- meta.table punctuation.separator.table-cell | ^^^^^ meta.table markup.bold - punctuation.separator.table-cell @@ -2991,8 +2992,17 @@ not a table | | ^ punctuation.separator.table-cell | ^ punctuation.separator.table-cell |`test | me | -|^ invalid.deprecated.unescaped-backticks +|^^^^^^^^^^^^^ meta.table.markdown-gfm - markup.raw | ^ punctuation.separator.table-cell +| ` ` | ` me ` | +| <- meta.table.markdown-gfm punctuation.separator.table-cell.markdown +| ^^^ meta.table.markdown-gfm markup.raw.inline.markdown +| ^ punctuation.definition.raw.begin.markdown +| ^ punctuation.definition.raw.end.markdown +| ^ punctuation.separator.table-cell +| ^^^^^^ markup.raw.inline.markdown +| ^ punctuation.definition.raw.begin.markdown +| ^ punctuation.definition.raw.end.markdown | table | followed by paragraph