Skip to content

Commit 00af35d

Browse files
author
deathaxe
committed
Syntax: Add support for ==highlight== tags
1 parent a1faa62 commit 00af35d

6 files changed

+206
-5
lines changed

Default (Linux).sublime-keymap

+21
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,27 @@
205205
]
206206
},
207207

208+
//
209+
// Auto-Pairing Highlight
210+
//
211+
212+
{ "keys": ["="], "command": "insert_snippet", "args": {"contents": "==${0:$SELECTION}=="}, "context":
213+
[
214+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true },
215+
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
216+
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
217+
]
218+
},
219+
{ "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "Packages/MarkdownEditing/macros/Delete Left Right 2.sublime-macro"}, "context":
220+
[
221+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true },
222+
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
223+
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
224+
{ "key": "preceding_text", "operator": "regex_contains", "operand": "==$", "match_all": true },
225+
{ "key": "following_text", "operator": "regex_contains", "operand": "^==", "match_all": true }
226+
]
227+
},
228+
208229
//
209230
// Auto-Pairing Strike Through
210231
//

Default (OSX).sublime-keymap

+21
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,27 @@
205205
]
206206
},
207207

208+
//
209+
// Auto-Pairing Highlight
210+
//
211+
212+
{ "keys": ["="], "command": "insert_snippet", "args": {"contents": "==${0:$SELECTION}=="}, "context":
213+
[
214+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true },
215+
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
216+
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
217+
]
218+
},
219+
{ "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "Packages/MarkdownEditing/macros/Delete Left Right 2.sublime-macro"}, "context":
220+
[
221+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true },
222+
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
223+
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
224+
{ "key": "preceding_text", "operator": "regex_contains", "operand": "==$", "match_all": true },
225+
{ "key": "following_text", "operator": "regex_contains", "operand": "^==", "match_all": true }
226+
]
227+
},
228+
208229
//
209230
// Auto-Pairing Strike Through
210231
//

Default (Windows).sublime-keymap

+21
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,27 @@
205205
]
206206
},
207207

208+
//
209+
// Auto-Pairing Highlight
210+
//
211+
212+
{ "keys": ["="], "command": "insert_snippet", "args": {"contents": "==${0:$SELECTION}=="}, "context":
213+
[
214+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true },
215+
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
216+
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
217+
]
218+
},
219+
{ "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "Packages/MarkdownEditing/macros/Delete Left Right 2.sublime-macro"}, "context":
220+
[
221+
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true },
222+
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
223+
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
224+
{ "key": "preceding_text", "operator": "regex_contains", "operand": "==$", "match_all": true },
225+
{ "key": "following_text", "operator": "regex_contains", "operand": "^==", "match_all": true }
226+
]
227+
},
228+
208229
//
209230
// Auto-Pairing Strike Through
210231
//

messages/next.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ feedback you can use [GitHub issues][issues].
1111

1212
## New Features
1313

14+
* syntax highlighting for `==highlight==` emphasis (#764)
1415
* syntax highlighting for Groovy in fenced code blocks (#768)
1516

1617
## Changes

syntaxes/Markdown.sublime-syntax

+23-2
Original file line numberDiff line numberDiff line change
@@ -3017,6 +3017,7 @@ contexts:
30173017
emphasis:
30183018
- include: bold
30193019
- include: italic
3020+
- include: highlight
30203021
- include: strikethrough
30213022

30223023
images:
@@ -3142,6 +3143,7 @@ contexts:
31423143
scope: punctuation.definition.italic.end.markdown
31433144
set: bold-after-bold-italic-asterisk
31443145
- include: emphasis-common
3146+
- include: highlight
31453147
- include: strikethrough
31463148

31473149
bold-after-bold-italic-asterisk:
@@ -3188,6 +3190,7 @@ contexts:
31883190
scope: punctuation.definition.bold.end.markdown
31893191
set: italic-after-bold-italic-underscore
31903192
- include: emphasis-common
3193+
- include: highlight
31913194
- include: strikethrough
31923195

31933196
bold-after-bold-italic-underscore:
@@ -3217,6 +3220,7 @@ contexts:
32173220
bold-common:
32183221
- include: emphasis-common
32193222
- include: italic
3223+
- include: highlight
32203224
- include: strikethrough
32213225

32223226
italic:
@@ -3256,8 +3260,25 @@ contexts:
32563260
italic-common:
32573261
- include: emphasis-common
32583262
- include: bold
3263+
- include: highlight
32593264
- include: strikethrough
32603265

3266+
highlight:
3267+
- match: ==(?![=>\s]) # 2x = but no =>
3268+
scope: punctuation.definition.highlight.begin.markdown
3269+
push: highlight-content
3270+
- match: =+(?![=>\s]) # any number of = not looking like =>
3271+
3272+
highlight-content:
3273+
- meta_scope: markup.highlight.markdown
3274+
- match: ==(?!=) # 2x =
3275+
scope: punctuation.definition.highlight.end.markdown
3276+
pop: true
3277+
- match: '[ \t]*=+'
3278+
- include: emphasis-common
3279+
- include: bold
3280+
- include: italic
3281+
32613282
strikethrough:
32623283
# https://github.github.com/gfm/#strikethrough-extension-
32633284
- match: ~~(?![~}>\s]) # 2x ~ but no ~> or ~~}
@@ -3270,7 +3291,7 @@ contexts:
32703291
- match: ~~(?:(?!~)|(?=~~}|~>)) # 2x ~ maybe followed by ~> or ~~}
32713292
scope: punctuation.definition.strikethrough.end.markdown
32723293
pop: true
3273-
- match: ~+(?:(?!~)|(?=~~}|~>)) # any number of ~ maybe followed by ~> or ~~}
3294+
- match: '[ \t]*~+(?:(?!~)|(?=~~}|~>))' # any number of ~ maybe followed by ~> or ~~}
32743295
- include: emphasis-common
32753296
- include: bold
32763297
- include: italic
@@ -3759,7 +3780,7 @@ contexts:
37593780
- meta_scope: meta.link.inet.markdown markup.underline.link.markdown-gfm
37603781
# 1. When an autolink ends in ), we scan the entire autolink for the total
37613782
# number of parentheses. If there is a greater number of closing parentheses
3762-
# than opening ones, we don’t consider the last character part of the
3783+
# than opening ones, we dont consider the last character part of the
37633784
# autolink, in order to facilitate including an autolink inside a parenthesis
37643785
# 2. If an autolink ends in a semicolon (;), we check to see if it appears to
37653786
# resemble an entity reference; if the preceding text is & followed by one

tests/syntax_test_markdown.md

+119-3
Original file line numberDiff line numberDiff line change
@@ -6947,6 +6947,117 @@ __test <span>text__ *formatted</span>*
69476947
| ^ punctuation
69486948
| ^ punctuation
69496949
6950+
# TEST: HIGHLIGHT #############################################################
6951+
6952+
__==bold highlight==__
6953+
| <- markup.bold.markdown punctuation.definition.bold.begin.markdown
6954+
|^ markup.bold.markdown - markup.highlight
6955+
| ^^^^^^^^^^^^^^^^^^ markup.bold.markdown markup.highlight.markdown
6956+
| ^^ markup.bold.markdown - markup.highlight
6957+
|^ punctuation.definition.bold.begin.markdown
6958+
| ^^ punctuation.definition.highlight.begin.markdown
6959+
| ^^ punctuation.definition.highlight.end.markdown
6960+
| ^^ punctuation.definition.bold.end.markdown
6961+
6962+
**==bold highlight==**
6963+
| <- markup.bold.markdown punctuation.definition.bold.begin.markdown
6964+
|^ markup.bold.markdown - markup.highlight
6965+
| ^^^^^^^^^^^^^^^^^^ markup.bold.markdown markup.highlight.markdown
6966+
| ^^ markup.bold.markdown - markup.highlight
6967+
|^ punctuation.definition.bold.begin.markdown
6968+
| ^^ punctuation.definition.highlight.begin.markdown
6969+
| ^^ punctuation.definition.highlight.end.markdown
6970+
| ^^ punctuation.definition.bold.end.markdown
6971+
6972+
_==italic highlight==_
6973+
| <- markup.italic.markdown punctuation.definition.italic.begin.markdown
6974+
|^^^^^^^^^^^^^^^^^^^^ markup.italic.markdown markup.highlight.markdown
6975+
| ^ markup.italic.markdown - markup.highlight
6976+
|^^ punctuation.definition.highlight.begin.markdown
6977+
| ^^ punctuation.definition.highlight.end.markdown
6978+
| ^ punctuation.definition.italic.end.markdown
6979+
6980+
*==italic highlight==*
6981+
| <- markup.italic.markdown punctuation.definition.italic.begin.markdown
6982+
|^^^^^^^^^^^^^^^^^^^^ markup.italic.markdown markup.highlight.markdown
6983+
| ^ markup.italic.markdown - markup.highlight
6984+
|^^ punctuation.definition.highlight.begin.markdown
6985+
| ^^ punctuation.definition.highlight.end.markdown
6986+
| ^ punctuation.definition.italic.end.markdown
6987+
6988+
___==bold italic highlight==___
6989+
| <- markup.bold.markdown punctuation.definition.bold.begin.markdown
6990+
|^ markup.bold.markdown - markup.italic - markup.highlight
6991+
| ^ markup.bold.markdown markup.italic.markdown - markup.highlight
6992+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ markup.bold.markdown markup.italic.markdown markup.highlight.markdown
6993+
| ^ markup.bold.markdown markup.italic.markdown - markup.highlight
6994+
| ^^ markup.bold.markdown - markup.italic - markup.highlight
6995+
|^ punctuation.definition.bold.begin.markdown
6996+
| ^ punctuation.definition.italic.begin.markdown
6997+
| ^^ punctuation.definition.highlight.begin.markdown
6998+
| ^^ punctuation.definition.highlight.end.markdown
6999+
| ^ punctuation.definition.italic.end.markdown
7000+
| ^^ punctuation.definition.bold.end.markdown
7001+
7002+
***==bold italic highlight==***
7003+
| <- markup.bold.markdown punctuation.definition.bold.begin.markdown
7004+
|^ markup.bold.markdown - markup.italic - markup.highlight
7005+
| ^ markup.bold.markdown markup.italic.markdown - markup.highlight
7006+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ markup.bold.markdown markup.italic.markdown markup.highlight.markdown
7007+
| ^ markup.bold.markdown markup.italic.markdown - markup.highlight
7008+
| ^^ markup.bold.markdown - markup.italic - markup.highlight
7009+
|^ punctuation.definition.bold.begin.markdown
7010+
| ^ punctuation.definition.italic.begin.markdown
7011+
| ^^ punctuation.definition.highlight.begin.markdown
7012+
| ^^ punctuation.definition.highlight.end.markdown
7013+
| ^ punctuation.definition.italic.end.markdown
7014+
| ^^ punctuation.definition.bold.end.markdown
7015+
7016+
=Hi= Hello, world!
7017+
| <- - punctuation.definition.highlight
7018+
|^^^^^^^^^^^^^^^^^ meta.paragraph - markup
7019+
| ^ - punctuation.definition.highlight
7020+
7021+
This =text==== is ====curious=.
7022+
|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph - markup
7023+
| ^ - punctuation.definition.highlight
7024+
| ^^^^ - punctuation.definition.highlight
7025+
| ^^^^ - punctuation.definition.highlight
7026+
| ^ - punctuation.definition.highlight
7027+
7028+
This ==text==== is ====curious==.
7029+
|^^^^ meta.paragraph - markup
7030+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph markup.highlight
7031+
| ^^ meta.paragraph - markup
7032+
| ^^ punctuation.definition.highlight.begin
7033+
| ^^^^ - punctuation.definition.highlight
7034+
| ^^^^ - punctuation.definition.highlight
7035+
| ^^ punctuation.definition.highlight.end
7036+
7037+
This ==is ==highlighted== inline text
7038+
|^^^^ - markup.highlight
7039+
| ^^^^^^^^^^^^^^^^^^^^ markup.highlight.markdown
7040+
| ^^^^^^^^^^^^ - markup.highlight
7041+
7042+
This ==has a
7043+
| ^^^^^^^^ meta.paragraph markup.highlight
7044+
7045+
| <- meta.paragraph markup.highlight invalid.illegal.non-terminated.bold-italic
7046+
new paragraph==.
7047+
| ^^ meta.paragraph markup.highlight punctuation.definition.highlight.begin
7048+
7049+
| <- invalid.illegal.non-terminated.bold-italic
7050+
7051+
A ==[highlight](https://link-url)==
7052+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown
7053+
7054+
A ==![highlight](https://image-url)==
7055+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown
7056+
7057+
A ==[![highlight](image-url)](link-url)==
7058+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown
7059+
7060+
69507061
# TEST: STRIKETHROUGH #########################################################
69517062
69527063
__~~bold striked~~__
@@ -7034,6 +7145,11 @@ This ~~text~~~~ is ~~~~curious~~.
70347145
| ^^^^ - punctuation.definition.strikethrough
70357146
| ^^ punctuation.definition.strikethrough.end
70367147
7148+
This ~~is ~~striked~~ inline text
7149+
|^^^^ - markup.strikethrough
7150+
| ^^^^^^^^^^^^^^^^ markup.strikethrough.markdown-gfm
7151+
| ^^^^^^^^^^^^^ - markup.strikethrough
7152+
70377153
This ~~has a
70387154
| ^^^^^^^^ meta.paragraph markup.strikethrough
70397155
@@ -7043,13 +7159,13 @@ new paragraph~~.
70437159
70447160
| <- invalid.illegal.non-terminated.bold-italic
70457161
7046-
A ~~[striked](https://link-url)~~
7162+
A ~~[highlight](https://link-url)~~
70477163
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.strikethrough.markdown-gfm
70487164
7049-
A ~~![striked](https://image-url)~~
7165+
A ~~![highlight](https://image-url)~~
70507166
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.strikethrough.markdown-gfm
70517167
7052-
A ~~[![striked](image-url)](link-url)~~
7168+
A ~~[![highlight](image-url)](link-url)~~
70537169
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.strikethrough.markdown-gfm
70547170
70557171

0 commit comments

Comments
 (0)