Skip to content

Commit 6d58e1e

Browse files
committed
Syntax: fix ==highlight== at beginning of paragraphs
1 parent 58a8236 commit 6d58e1e

File tree

2 files changed

+81
-13
lines changed

2 files changed

+81
-13
lines changed

syntaxes/Markdown.sublime-syntax

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ variables:
1919
atx_heading_space: (?:(?=[ \t]+#+[ \t]*$)|[ \t]+|$) # consume spaces only if heading is not empty to ensure `atx_heading_end` can fully match closing hashes
2020
atx_heading_end: (?:[ \t]+(#+))?[ \t]*($\n?) # \n is optional so ## is matched as end punctuation in new document (at eof)
2121

22-
setext_heading_or_paragraph: ^(?:[ ]{,3}=+|(?=[ ]{,3}\S)) # between 0 and 3 spaces, followed by non-whitespace (consume equal signs as paragraphs may start with them)
23-
setext_heading_escape: ^(?=[ ]{,3}(?:=+|-+)[ \t]*$) # between 0 and 3 spaces, followed by at least one hyphen or equal sign (setext underline can be of any length)
24-
setext_heading1_escape: ^(?=[ ]{,3}=+[ \t]*$) # between 0 and 3 spaces, followed by at least one equal sign (setext underline can be of any length)
25-
setext_heading1_end: ^[ ]{,3}(=+)[ \t]*$(\n?) # between 0 and 3 spaces, followed by at least one equal sign (setext underline can be of any length)
26-
setext_heading2_end: ^[ ]{,3}(-+)[ \t]*$(\n?) # between 0 and 3 spaces, followed by at least one hyphen (setext underline can be of any length)
27-
28-
list_setext_heading_or_paragraph: (?:[ \t]*=+|(?=[ \t]*\S)) # any number of spaces, followed by non-whitespace (consume equal signs as paragraphs may start with them)
29-
list_setext_heading_escape: ^(?=[ \t]{2,}(?:==+|--+)[ \t]*$) # two or more spaces, followed by at least one hyphen or equal sign (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items)
30-
list_setext_heading1_escape: ^(?=[ \t]{2,}==+[ \t]*$) # two or more spaces, followed by at least one equal sign (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items)
31-
list_setext_heading1_end: ^[ \t]{2,}(==+)[ \t]*$(\n?) # two or more spaces, followed by at least one equal sign (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items)
32-
list_setext_heading2_end: ^[ \t]{2,}(--+)[ \t]*$(\n?) # two or more spaces, followed by at least one hyphen (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items)
22+
setext_heading_or_paragraph: ^(?:[ ]{,3}=+[ \t]*$|(?=[ ]{,3}\S)) # between 0 and 3 spaces, followed by non-whitespace (consume equal signs as paragraphs may start with them)
23+
setext_heading_escape: ^(?=[ ]{,3}(?:=+|-+)[ \t]*$) # between 0 and 3 spaces, followed by at least one hyphen or equal sign (setext underline can be of any length)
24+
setext_heading1_escape: ^(?=[ ]{,3}=+[ \t]*$) # between 0 and 3 spaces, followed by at least one equal sign (setext underline can be of any length)
25+
setext_heading1_end: ^[ ]{,3}(=+)[ \t]*$(\n?) # between 0 and 3 spaces, followed by at least one equal sign (setext underline can be of any length)
26+
setext_heading2_end: ^[ ]{,3}(-+)[ \t]*$(\n?) # between 0 and 3 spaces, followed by at least one hyphen (setext underline can be of any length)
27+
28+
list_setext_heading_or_paragraph: (?:[ \t]*=+[ \t]*$|(?=[ \t]*\S)) # any number of spaces, followed by non-whitespace (consume equal signs as paragraphs may start with them)
29+
list_setext_heading_escape: ^(?=[ \t]{2,}(?:==+|--+)[ \t]*$) # two or more spaces, followed by at least one hyphen or equal sign (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items)
30+
list_setext_heading1_escape: ^(?=[ \t]{2,}==+[ \t]*$) # two or more spaces, followed by at least one equal sign (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items)
31+
list_setext_heading1_end: ^[ \t]{2,}(==+)[ \t]*$(\n?) # two or more spaces, followed by at least one equal sign (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items)
32+
list_setext_heading2_end: ^[ \t]{2,}(--+)[ \t]*$(\n?) # two or more spaces, followed by at least one hyphen (setext underline can be of any length, but ST needs at least 2 to avoid ambiguity with empty list items)
3333

3434
block_quote: (?:[ ]{,3}(>)[ ]?) # between 0 and 3 spaces, followed by a greater than sign, (followed by any character or the end of the line = "only care about optional space!")
3535
indented_code_block: (?:[ ]{4}|[ ]{0,3}\t) # a visual tab of width 4 consisting of 4 spaces or 0 to 3 spaces followed by 1 tab

tests/syntax_test_markdown.md

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7288,6 +7288,11 @@ __test <span>text__ *formatted</span>*
72887288
72897289
# TEST: HIGHLIGHT #############################################################
72907290
7291+
==highlight==
7292+
| ^^^^^^^^^^^^^ markup.highlight.markdown
7293+
| ^^ punctuation.definition.highlight.begin.markdown
7294+
| ^^ punctuation.definition.highlight.end.markdown
7295+
72917296
__==bold highlight==__
72927297
| <- markup.bold.markdown punctuation.definition.bold.begin.markdown
72937298
|^ markup.bold.markdown - markup.highlight
@@ -7352,9 +7357,9 @@ ___==bold italic highlight==___
73527357
| ^ punctuation.definition.italic.end.markdown
73537358
| ^^ punctuation.definition.bold.end.markdown
73547359
7355-
=Hi= Hello, world!
7360+
=Hi= Hello, ===world===!
73567361
| <- - punctuation.definition.highlight
7357-
|^^^^^^^^^^^^^^^^^ meta.paragraph - markup
7362+
|^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph - markup
73587363
| ^ - punctuation.definition.highlight
73597364
73607365
This =text==== is ====curious=.
@@ -7417,6 +7422,69 @@ A ==![image $\ce{H2O}$.](./img/image6.png){#fig:image6 height=12.09cm }==
74177422
| ^ punctuation.definition.attributes.end.markdown
74187423
| ^^ punctuation.definition.highlight.end.markdown
74197424
7425+
- ==highlight==
7426+
| ^^^^^^^^^^^^^ markup.highlight.markdown
7427+
| ^^ punctuation.definition.highlight.begin.markdown
7428+
| ^^ punctuation.definition.highlight.end.markdown
7429+
7430+
1. ==highlight==
7431+
| ^^^^^^^^^^^^^ markup.highlight.markdown
7432+
| ^^ punctuation.definition.highlight.begin.markdown
7433+
| ^^ punctuation.definition.highlight.end.markdown
7434+
7435+
Heading
7436+
=======
7437+
==highlight==
7438+
| <- meta.paragraph.markdown markup.highlight.markdown punctuation.definition.highlight.begin.markdown
7439+
|^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown
7440+
7441+
Heading
7442+
-------
7443+
==highlight==
7444+
| <- meta.paragraph.markdown markup.highlight.markdown punctuation.definition.highlight.begin.markdown
7445+
|^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown
7446+
7447+
==
7448+
==highlight==
7449+
| <- meta.paragraph.markdown markup.highlight.markdown punctuation.definition.highlight.begin.markdown
7450+
|^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown
7451+
7452+
===
7453+
==highlight==
7454+
| <- meta.paragraph.markdown markup.highlight.markdown punctuation.definition.highlight.begin.markdown
7455+
|^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown
7456+
7457+
---
7458+
==highlight==
7459+
| <- meta.paragraph.markdown markup.highlight.markdown punctuation.definition.highlight.begin.markdown
7460+
|^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown
7461+
7462+
Heading
7463+
==
7464+
===not highlighted===
7465+
| <- meta.paragraph.markdown - markup
7466+
|^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup
7467+
7468+
Heading
7469+
--
7470+
===not highlighted===
7471+
| <- meta.paragraph.markdown - markup
7472+
|^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup
7473+
7474+
==
7475+
===not highlighted===
7476+
| <- meta.paragraph.markdown - markup
7477+
|^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup
7478+
7479+
===
7480+
===not highlighted===
7481+
| <- meta.paragraph.markdown - markup
7482+
|^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup
7483+
7484+
---
7485+
===not highlighted===
7486+
| <- meta.paragraph.markdown - markup
7487+
|^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown - markup
74207488
74217489
# TEST: STRIKETHROUGH #########################################################
74227490

0 commit comments

Comments
 (0)