Skip to content

Commit

Permalink
Syntax: Fix thematic break after fenced codeblocks
Browse files Browse the repository at this point in the history
Fenced codeblocks are a separate type of block, which must not be part
of ordinary paragraphs.

see: https://spec.commonmark.org/0.30/#leaf-blocks
  • Loading branch information
deathaxe committed Aug 12, 2021
1 parent 332c6b5 commit 8b99048
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion syntaxes/Markdown.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ contexts:
pop: true
- include: inline-bold-italic
- include: reference-link-definition
- include: fenced-code-blocks
- match: '^(?=\S)(?![=-]{3,}\s*$)'
push:
- meta_scope: meta.paragraph.markdown
Expand All @@ -318,7 +319,6 @@ contexts:
)
)
pop: true
- include: fenced-code-blocks
- include: inline-bold-italic-linebreak
- include: tag-kbd
- include: scope:text.html.basic
Expand Down
18 changes: 13 additions & 5 deletions tests/syntax_test_markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ underlined heading followed by another one that should be treated as a normal pa
=====
| <- - markup.heading

```
Fenced codeblocks are no no setext heading
```
---
| <- meta.separator.thematic-break.markdown punctuation.definition.thematic-break.markdown
|^^ meta.separator.thematic-break.markdown punctuation.definition.thematic-break.markdown


Paragraph of text that should be scoped as meta.paragraph.
|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph
A [link](https://example.com){ :_attr = value }, *italic text* and **bold**.
Expand Down Expand Up @@ -554,9 +562,9 @@ paragraph
> Block quote followed by fenced code block
```
| <- meta.paragraph.markdown meta.code-fence.definition.begin.text.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - meta.quote
| <- meta.code-fence.definition.begin.text.markdown-gfm punctuation.definition.raw.code-fence.begin.markdown - meta.quote
```
| <- meta.paragraph.markdown meta.code-fence.definition.end.text.markdown-gfm punctuation.definition.raw.code-fence.end.markdown - meta.quote
| <- meta.code-fence.definition.end.text.markdown-gfm punctuation.definition.raw.code-fence.end.markdown - meta.quote
> Quoted fenced code block is terminated by missing > at bol
> ```
Expand All @@ -574,9 +582,9 @@ no code block
> Unterminated quoted fenced code block followed by unquoted fenced code block
> ```
```
| <- meta.paragraph.markdown meta.code-fence.definition.begin.text.markdown-gfm - markup.quote
| <- meta.code-fence.definition.begin.text.markdown-gfm - markup.quote
```
| <- meta.paragraph.markdown meta.code-fence.definition.end.text.markdown-gfm - markup.quote
| <- meta.code-fence.definition.end.text.markdown-gfm - markup.quote

> Block quote followed by heading
# heading
Expand Down Expand Up @@ -2412,7 +2420,7 @@ var_dump(expression);
(?x)
\s+
```
|^^^ meta.paragraph meta.code-fence.definition.end.regexp - markup
|^^^ meta.code-fence.definition.end.regexp - markup
|^^ punctuation.definition.raw.code-fence.end

```bash
Expand Down

0 comments on commit 8b99048

Please sign in to comment.