Skip to content

Commit

Permalink
[Markdown] Fix premature block quote termination (#3900)
Browse files Browse the repository at this point in the history
* [Markdown] Fix premature block quote termination

Fixes #3892 (comment)

Follow up commit for #3892.

* [Markdown] Remove useless context pushes

This commit removes block-quote punctuation contexts from being pushed on stack,
which do not have any effect in conjunction with Github Alerts.

They are required support multiple > > > markers in front of content, which is
not supported by Github Alerts.

Due to consuming caption text pushing those contexts does actually nothing, but
causing some extra round-trips.
  • Loading branch information
deathaxe authored Jan 1, 2024
1 parent 215bba1 commit 9ba6b93
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 14 deletions.
18 changes: 4 additions & 14 deletions Markdown/Markdown.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ contexts:
push:
- block-quote-caution-meta
- block-quote-body
- block-quote-punctuation-body
- match: '[ \t]{,3}(>)[ ]?((\[)!WARNING(\]))'
captures:
1: punctuation.definition.blockquote.markdown
Expand All @@ -373,7 +372,6 @@ contexts:
push:
- block-quote-warning-meta
- block-quote-body
- block-quote-punctuation-body
- match: '[ \t]{,3}(>)[ ]?((\[)!IMPORTANT(\]))'
captures:
1: punctuation.definition.blockquote.markdown
Expand All @@ -383,7 +381,6 @@ contexts:
push:
- block-quote-important-meta
- block-quote-body
- block-quote-punctuation-body
- match: '[ \t]{,3}(>)[ ]?((\[)!NOTE(\]))'
captures:
1: punctuation.definition.blockquote.markdown
Expand All @@ -393,7 +390,6 @@ contexts:
push:
- block-quote-note-meta
- block-quote-body
- block-quote-punctuation-body
- match: '[ \t]{,3}(>)[ ]?((\[)!TIP(\]))'
captures:
1: punctuation.definition.blockquote.markdown
Expand All @@ -403,7 +399,6 @@ contexts:
push:
- block-quote-tip-meta
- block-quote-body
- block-quote-punctuation-body
- match: '[ \t]{,3}(>)[ ]?'
captures:
1: punctuation.definition.blockquote.markdown
Expand Down Expand Up @@ -631,14 +626,14 @@ contexts:
4: markup.checkbox.begin.markdown-gfm punctuation.definition.checkbox.begin.markdown-gfm
5: markup.checkbox.mark.markdown-gfm
6: markup.checkbox.end.markdown-gfm punctuation.definition.checkbox.end.markdown-gfm
set: block-quote-unordered-list-block-body
push: block-quote-unordered-list-block-body
- match: ([ \t]*)(\d{1,9}([.)]))(\s)
captures:
1: markup.list.numbered.markdown
2: markup.list.numbered.bullet.markdown
3: punctuation.definition.list_item.markdown
4: markup.list.numbered.markdown
set: block-quote-ordered-list-block-body
push: block-quote-ordered-list-block-body

block-quote-ordered-list-block-body:
- meta_content_scope: markup.list.numbered.markdown
Expand Down Expand Up @@ -697,7 +692,7 @@ contexts:

block-quote-paragraph:
- match: '[ \t]*(?=\S)'
set: block-quote-paragraph-body
push: block-quote-paragraph-body

block-quote-paragraph-body:
- meta_scope: markup.paragraph.markdown
Expand Down Expand Up @@ -793,7 +788,6 @@ contexts:
push:
- block-quote-caution-meta
- list-block-quote-body
- block-quote-punctuation-body
- match: '[ \t]{,3}(>)[ ]?((\[)!WARNING(\]))'
captures:
1: punctuation.definition.blockquote.markdown
Expand All @@ -803,7 +797,6 @@ contexts:
push:
- block-quote-warning-meta
- list-block-quote-body
- block-quote-punctuation-body
- match: '[ \t]{,3}(>)[ ]?((\[)!IMPORTANT(\]))'
captures:
1: punctuation.definition.blockquote.markdown
Expand All @@ -813,7 +806,6 @@ contexts:
push:
- block-quote-important-meta
- list-block-quote-body
- block-quote-punctuation-body
- match: '[ \t]{,3}(>)[ ]?((\[)!NOTE(\]))'
captures:
1: punctuation.definition.blockquote.markdown
Expand All @@ -823,7 +815,6 @@ contexts:
push:
- block-quote-note-meta
- list-block-quote-body
- block-quote-punctuation-body
- match: '[ \t]{,3}(>)[ ]?((\[)!TIP(\]))'
captures:
1: punctuation.definition.blockquote.markdown
Expand All @@ -833,7 +824,6 @@ contexts:
push:
- block-quote-tip-meta
- list-block-quote-body
- block-quote-punctuation-body
- match: '[ \t]*(>)[ ]?'
captures:
1: punctuation.definition.blockquote.markdown
Expand All @@ -860,7 +850,7 @@ contexts:

list-block-quote-paragraph:
- match: '[ \t]*(?=\S)'
set: list-block-quote-paragraph-body
push: list-block-quote-paragraph-body

list-block-quote-paragraph-body:
- meta_scope: markup.paragraph.markdown
Expand Down
120 changes: 120 additions & 0 deletions Markdown/tests/syntax_test_markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -8209,6 +8209,66 @@ This is a [[wiki link]].
|^ markup.quote.alert.caution.markdown - markup.paragraph
| ^^^^^ markup.quote.alert.caution.markdown markup.paragraph.markdown
> [!CAUTION]
>
> Paragraph 1
>
> Paragraph 2
| <- markup.quote.alert.caution.markdown punctuation.definition.blockquote.markdown
|^ markup.quote.alert.caution.markdown - markup.paragraph
| ^^^^^^^^^^^ markup.quote.alert.caution.markdown markup.paragraph.markdown
> [!CAUTION]
>
> - list item
>
> - list item
| <- markup.quote.alert.caution.markdown punctuation.definition.blockquote.markdown
|^ markup.quote.alert.caution.markdown
| ^ markup.quote.alert.caution.markdown markup.list.unnumbered.bullet.markdown punctuation.definition.list_item.markdown
| ^^^^^^^^^^^ markup.quote.alert.caution.markdown markup.list.unnumbered.markdown
> [!CAUTION]
>
> 1. list item
>
> 2. list item
| <- markup.quote.alert.caution.markdown punctuation.definition.blockquote.markdown
|^ markup.quote.alert.caution.markdown
| ^^ markup.quote.alert.caution.markdown markup.list.numbered.bullet.markdown
| ^ punctuation.definition.list_item.markdown
| ^^^^^^^^^^ markup.quote.alert.caution.markdown markup.list.numbered.markdown
> [!CAUTION]
>
> 1. list item
>
> 2. list item paragraph 1
>
> list item paragraph 2
| <- markup.quote.alert.caution.markdown markup.list.numbered.markdown punctuation.definition.blockquote.markdown
|^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.quote.alert.caution.markdown markup.list.numbered.markdown
> [!CAUTION]
>
> Paragraph 1
>
> # Heading
>
> Paragraph 2
| <- markup.quote.alert.caution.markdown punctuation.definition.blockquote.markdown
|^^^^^^^^^^^^^ markup.quote.alert.caution.markdown
> [!CAUTION]
>
> ```
> fenced code
> ```
>
> Paragraph 2
| <- markup.quote.alert.caution.markdown punctuation.definition.blockquote.markdown
|^^^^^^^^^^^^^ markup.quote.alert.caution.markdown
> [!WARNING]
| <- markup.quote.alert.warning.markdown punctuation.definition.blockquote.markdown
|^^^^^^^^^^^^ markup.quote.alert.warning.markdown
Expand Down Expand Up @@ -8281,6 +8341,66 @@ This is a [[wiki link]].
|^ markup.quote.alert.caution.markdown - markup.paragraph
| ^^^^^ markup.quote.alert.caution.markdown markup.paragraph.markdown
> [!CAUTION]
>
> Paragraph 1
>
> Paragraph 2
| <- markup.quote.alert.caution.markdown punctuation.definition.blockquote.markdown
|^ markup.quote.alert.caution.markdown - markup.paragraph
| ^^^^^^^^^^^ markup.quote.alert.caution.markdown markup.paragraph.markdown
> [!CAUTION]
>
> - list item
>
> - list item
| <- markup.quote.alert.caution.markdown punctuation.definition.blockquote.markdown
|^ markup.quote.alert.caution.markdown
| ^ markup.quote.alert.caution.markdown markup.list.unnumbered.bullet.markdown punctuation.definition.list_item.markdown
| ^^^^^^^^^^^ markup.quote.alert.caution.markdown markup.list.unnumbered.markdown
> [!CAUTION]
>
> 1. list item
>
> 2. list item
| <- markup.quote.alert.caution.markdown punctuation.definition.blockquote.markdown
|^ markup.quote.alert.caution.markdown
| ^^ markup.quote.alert.caution.markdown markup.list.numbered.bullet.markdown
| ^ punctuation.definition.list_item.markdown
| ^^^^^^^^^^ markup.quote.alert.caution.markdown markup.list.numbered.markdown
> [!CAUTION]
>
> 1. list item
>
> 2. list item paragraph 1
>
> list item paragraph 2
| <- markup.quote.alert.caution.markdown markup.list.numbered.markdown punctuation.definition.blockquote.markdown
|^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.quote.alert.caution.markdown markup.list.numbered.markdown
> [!CAUTION]
>
> Paragraph 1
>
> # Heading
>
> Paragraph 2
| <- markup.quote.alert.caution.markdown punctuation.definition.blockquote.markdown
|^^^^^^^^^^^^^ markup.quote.alert.caution.markdown
> [!CAUTION]
>
> ```
> fenced code
> ```
>
> Paragraph 2
| <- markup.quote.alert.caution.markdown punctuation.definition.blockquote.markdown
|^^^^^^^^^^^^^ markup.quote.alert.caution.markdown
1. list item
> [!WARNING]
| <- markup.quote.alert.warning.markdown punctuation.definition.blockquote.markdown
Expand Down

0 comments on commit 9ba6b93

Please sign in to comment.