Skip to content

Commit

Permalink
Syntax: Fix backticks and code-spans in table cells
Browse files Browse the repository at this point in the history
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
  • Loading branch information
deathaxe committed Apr 26, 2024
1 parent 2278c5c commit 342e0b5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions messages/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 12 additions & 4 deletions syntaxes/Markdown.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions tests/syntax_test_markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 342e0b5

Please sign in to comment.