Skip to content

Commit 0d5a62a

Browse files
committed
[Markdown] Simplify context structure
This commit drops pushing dedicated `fenced-div-body` to workaround hitting pattern repetition sanity limits of which reason is not yet clear.
1 parent ba42d70 commit 0d5a62a

File tree

3 files changed

+84
-47
lines changed

3 files changed

+84
-47
lines changed

Markdown/Fold.tmPreferences

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
</dict>
2626
<dict>
2727
<key>begin</key>
28-
<string>punctuation.section.block.begin.markdown</string>
28+
<string>punctuation.section.div.begin.markdown</string>
2929
<key>end</key>
30-
<string>punctuation.section.block.end.markdown</string>
30+
<string>punctuation.section.div.end.markdown</string>
3131
<key>excludeTrailingNewlines</key>
3232
<false/>
3333
</dict>

Markdown/Markdown.sublime-syntax

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ variables:
173173
fenced_code_block_escape: ^{{fenced_code_block_end}}
174174

175175
# https://pandoc.org/MANUAL.html#divs-and-spans
176-
fenced_div_block: :{3,}
176+
fenced_div_block: '[ \t]*(:{3,})'
177177

178178
# https://spec.commonmark.org/0.30/#email-autolink
179179
email_domain_commonmark: '[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?'
@@ -3520,11 +3520,14 @@ contexts:
35203520

35213521
fenced-div-blocks:
35223522
# https://pandoc.org/MANUAL.html#divs-and-spans
3523-
- match: ^[ \t]*({{fenced_div_block}})[ \t]*(?=\S)
3523+
- match: '{{fenced_div_block}}[ \t]*$\n?'
3524+
scope: meta.div.markdown
35243525
captures:
3525-
1: punctuation.section.block.begin.markdown
3526+
1: punctuation.section.div.end.markdown
3527+
- match: '{{fenced_div_block}}'
3528+
captures:
3529+
1: punctuation.section.div.begin.markdown
35263530
push:
3527-
- fenced-div-body
35283531
- fenced-div-puncuation
35293532
- fenced-div-attr
35303533

@@ -3542,20 +3545,12 @@ contexts:
35423545

35433546
fenced-div-puncuation:
35443547
- meta_include_prototype: false
3548+
- meta_scope: meta.div.markdown
35453549
- match: ':+'
3546-
scope: punctuation.section.block.markdown
3550+
scope: punctuation.section.div.markdown
35473551
pop: 1
35483552
- include: else-pop
35493553

3550-
fenced-div-body:
3551-
- meta_include_prototype: false
3552-
- meta_scope: meta.block.div.markdown
3553-
- match: ^[ \t]*(\1)(\s*\n)
3554-
captures:
3555-
1: punctuation.section.block.end.markdown
3556-
pop: 1
3557-
- include: markdown
3558-
35593554
###[ PROTOTYPES ]#############################################################
35603555

35613556
else-pop:

Markdown/tests/syntax_test_markdown.md

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9040,75 +9040,117 @@ Handle incomplete $\sqrt{b$ expressions well.
90409040
90419041
# TEST: PANDOC FENCED DIVS ####################################################
90429042
9043-
| Opening div tags must have attributes
9044-
:::
9045-
| <- - punctuation
9046-
|^^ - punctuation
9047-
90489043
::: class
9049-
| <- meta.block.div.markdown punctuation.section.block.begin.markdown
9050-
|^^^^^^^^ meta.block.div.markdown - meta.block meta.block
9051-
|^^ punctuation.section.block.begin.markdown
9044+
| <- meta.div.markdown punctuation.section.div.begin.markdown
9045+
|^^^^^^^^ meta.div.markdown
9046+
|^^ punctuation.section.div.begin.markdown
90529047
| ^^^^^ meta.attribute-with-value.markdown entity.other.attribute-name.markdown
90539048
- list
9054-
|^^^^^ meta.block.div.markdown
90559049
|^^^^^ markup.list.unnumbered.markdown
90569050
| ^^^^ meta.paragraph.list.markdown
90579051
- list
9058-
|^^^^^ meta.block.div.markdown
90599052
|^^^^^ markup.list.unnumbered.markdown
90609053
| ^^^^ meta.paragraph.list.markdown
90619054
:::
9062-
| <- meta.block.div.markdown punctuation.section.block.end.markdown
9063-
|^^ meta.block.div.markdown punctuation.section.block.end.markdown
9055+
| <- meta.div.markdown punctuation.section.div.end.markdown
9056+
|^^ meta.div.markdown punctuation.section.div.end.markdown
9057+
9058+
---
90649059
90659060
::: {.class #id} :::
9066-
|^^^^^^^^^^^^^^^^^^^ meta.block.div.markdown
9067-
|^^ punctuation.section.block.begin.markdown
9061+
|^^^^^^^^^^^^^^^^^^^ meta.div.markdown
9062+
|^^ punctuation.section.div.begin.markdown
90689063
| ^^^^^^^^^^^^ meta.attributes.markdown
90699064
| ^ punctuation.definition.attributes.begin.markdown
90709065
| ^^^^^^ meta.attribute-with-value.markdown entity.other.attribute-name.markdown
90719066
| ^^^ meta.attribute-with-value.markdown entity.other.attribute-name.markdown
90729067
| ^ punctuation.definition.attributes.end.markdown
9073-
| ^^^ punctuation.section.block.markdown
9068+
| ^^^ punctuation.section.div.markdown
90749069
::: inner
9075-
|^^^^^^^^ meta.block.div.markdown meta.block.div.markdown
9076-
|^^ punctuation.section.block.begin.markdown
9070+
|^^^^^^^^ meta.div.markdown
9071+
|^^ punctuation.section.div.begin.markdown
90779072
| ^^^^^ meta.attribute-with-value.markdown entity.other.attribute-name.markdown
90789073
paragraph
9079-
|^^^^^^^^ meta.block.div.markdown meta.block.div.markdown meta.paragraph.markdown
9074+
|^^^^^^^^ meta.paragraph.markdown
90809075
:::
9081-
|^^ meta.block.div.markdown meta.block.div.markdown punctuation.section.block.end.markdown
9076+
|^^ meta.div.markdown punctuation.section.div.end.markdown
9077+
| ^ meta.div.markdown - punctuation
90829078
:::
9083-
|^^ meta.block.div.markdown punctuation.section.block.end.markdown - meta.block meta.block
9079+
|^^ meta.div.markdown punctuation.section.div.end.markdown
9080+
| ^ meta.div.markdown - punctuation
9081+
9082+
---
90849083
90859084
::: block-quote
90869085
> quoted block
9087-
|^^^^^^^^^^^^^ meta.block.div.markdown markup.quote.markdown
9086+
|^^^^^^^^^^^^^ markup.quote.markdown
90889087
| ^^^^^^^^^^^^ markup.paragraph.markdown
90899088
> > nested quote
9090-
| <- meta.block.div.markdown markup.quote.markdown markup.paragraph.markdown punctuation.definition.blockquote.markdown
9091-
|^^^^^^^^^^^^^^^ meta.block.div.markdown markup.quote.markdown markup.paragraph.markdown
9089+
| <- markup.quote.markdown markup.paragraph.markdown punctuation.definition.blockquote.markdown
9090+
|^^^^^^^^^^^^^^^ markup.quote.markdown markup.paragraph.markdown
90929091
| ^ punctuation.definition.blockquote.markdown
90939092
:::
9094-
| <- meta.block.div.markdown punctuation.section.block.end.markdown
9095-
|^^ meta.block.div.markdown punctuation.section.block.end.markdown
9093+
| <- meta.div.markdown punctuation.section.div.end.markdown
9094+
|^^ meta.div.markdown punctuation.section.div.end.markdown
9095+
9096+
---
90969097
90979098
::: code-block
90989099
```css
9099-
|^^^^^ meta.block.div.markdown meta.code-fence.definition.begin.css.markdown-gfm
9100+
|^^^^^ meta.code-fence.definition.begin.css.markdown-gfm
91009101
|^^ punctuation.definition.raw.code-fence.begin.markdown
91019102
| ^^^ constant.other.language-name.markdown
91029103
```
91039104
:::
9104-
| <- meta.block.div.markdown punctuation.section.block.end.markdown
9105-
|^^ meta.block.div.markdown punctuation.section.block.end.markdown
9105+
| <- meta.div.markdown punctuation.section.div.end.markdown
9106+
|^^ meta.div.markdown punctuation.section.div.end.markdown
9107+
9108+
---
91069109
91079110
::: table
91089111
| column | column
91099112
| --- | ---
91109113
| foo | bar
9111-
| <- meta.block.div.markdown meta.table.markdown-gfm punctuation.separator.table-cell.markdown
9114+
| <- meta.table.markdown-gfm punctuation.separator.table-cell.markdown
91129115
:::
9113-
| <- meta.block.div.markdown punctuation.section.block.end.markdown
9114-
|^^ meta.block.div.markdown punctuation.section.block.end.markdown
9116+
| <- meta.div.markdown punctuation.section.div.end.markdown
9117+
|^^ punctuation.section.div.end.markdown
9118+
9119+
---
9120+
9121+
1. ordered list item
9122+
9123+
::: div
9124+
| <- markup.list.numbered.markdown meta.div.markdown punctuation.section.div.begin.markdown
9125+
|^^^^^^ markup.list.numbered.markdown meta.div.markdown
9126+
|^^ punctuation.section.div.begin.markdown
9127+
| ^^^ meta.attribute-with-value.markdown entity.other.attribute-name.markdown
9128+
:::
9129+
| <- markup.list.numbered.markdown meta.div.markdown punctuation.section.div.end.markdown
9130+
|^^^ markup.list.numbered.markdown meta.div.markdown
9131+
|^^ punctuation.section.div.end.markdown
9132+
9133+
---
9134+
9135+
- unordered list item
9136+
9137+
::: div
9138+
| <- markup.list.unnumbered.markdown meta.div.markdown punctuation.section.div.begin.markdown
9139+
|^^^^^^ markup.list.unnumbered.markdown meta.div.markdown
9140+
|^^ punctuation.section.div.begin.markdown
9141+
| ^^^ meta.attribute-with-value.markdown entity.other.attribute-name.markdown
9142+
:::
9143+
|^^^ markup.list.unnumbered.markdown meta.div.markdown
9144+
|^^ punctuation.section.div.end.markdown
9145+
9146+
---
9147+
9148+
::: indendet-code-block
9149+
| <- markup.raw.block.markdown
9150+
|^^^^^^^^^^^^^^^^^^^^^^^^^^^ markup.raw.block.markdown
9151+
9152+
::: indendet-code-block
9153+
code
9154+
:::
9155+
|<- markup.raw.block.markdown
9156+
|^^^^^^^ markup.raw.block.markdown

0 commit comments

Comments
 (0)