diff --git a/Default (Linux).sublime-keymap b/Default (Linux).sublime-keymap index d0f839e7..af96e827 100644 --- a/Default (Linux).sublime-keymap +++ b/Default (Linux).sublime-keymap @@ -205,6 +205,27 @@ ] }, + // + // Auto-Pairing Highlight + // + + { "keys": ["="], "command": "insert_snippet", "args": {"contents": "==${0:$SELECTION}=="}, "context": + [ + { "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true }, + { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, + { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true } + ] + }, + { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "Packages/MarkdownEditing/macros/Delete Left Right 2.sublime-macro"}, "context": + [ + { "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true }, + { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, + { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "==$", "match_all": true }, + { "key": "following_text", "operator": "regex_contains", "operand": "^==", "match_all": true } + ] + }, + // // Auto-Pairing Strike Through // diff --git a/Default (OSX).sublime-keymap b/Default (OSX).sublime-keymap index e7500b82..08df0d66 100644 --- a/Default (OSX).sublime-keymap +++ b/Default (OSX).sublime-keymap @@ -205,6 +205,27 @@ ] }, + // + // Auto-Pairing Highlight + // + + { "keys": ["="], "command": "insert_snippet", "args": {"contents": "==${0:$SELECTION}=="}, "context": + [ + { "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true }, + { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, + { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true } + ] + }, + { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "Packages/MarkdownEditing/macros/Delete Left Right 2.sublime-macro"}, "context": + [ + { "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true }, + { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, + { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "==$", "match_all": true }, + { "key": "following_text", "operator": "regex_contains", "operand": "^==", "match_all": true } + ] + }, + // // Auto-Pairing Strike Through // diff --git a/Default (Windows).sublime-keymap b/Default (Windows).sublime-keymap index d0f839e7..af96e827 100644 --- a/Default (Windows).sublime-keymap +++ b/Default (Windows).sublime-keymap @@ -205,6 +205,27 @@ ] }, + // + // Auto-Pairing Highlight + // + + { "keys": ["="], "command": "insert_snippet", "args": {"contents": "==${0:$SELECTION}=="}, "context": + [ + { "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true }, + { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, + { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true } + ] + }, + { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "Packages/MarkdownEditing/macros/Delete Left Right 2.sublime-macro"}, "context": + [ + { "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter - meta.disable-markdown - markup.raw - markup.kbd", "match_all": true }, + { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, + { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, + { "key": "preceding_text", "operator": "regex_contains", "operand": "==$", "match_all": true }, + { "key": "following_text", "operator": "regex_contains", "operand": "^==", "match_all": true } + ] + }, + // // Auto-Pairing Strike Through // diff --git a/messages/next.md b/messages/next.md index 730f4729..0cc6f0cb 100644 --- a/messages/next.md +++ b/messages/next.md @@ -11,6 +11,7 @@ feedback you can use [GitHub issues][issues]. ## New Features +* syntax highlighting for `==highlight==` emphasis (#764) * syntax highlighting for Groovy in fenced code blocks (#768) ## Changes diff --git a/syntaxes/Markdown.sublime-syntax b/syntaxes/Markdown.sublime-syntax index ecf50ff4..52d58fa4 100644 --- a/syntaxes/Markdown.sublime-syntax +++ b/syntaxes/Markdown.sublime-syntax @@ -3017,6 +3017,7 @@ contexts: emphasis: - include: bold - include: italic + - include: highlight - include: strikethrough images: @@ -3142,6 +3143,7 @@ contexts: scope: punctuation.definition.italic.end.markdown set: bold-after-bold-italic-asterisk - include: emphasis-common + - include: highlight - include: strikethrough bold-after-bold-italic-asterisk: @@ -3188,6 +3190,7 @@ contexts: scope: punctuation.definition.bold.end.markdown set: italic-after-bold-italic-underscore - include: emphasis-common + - include: highlight - include: strikethrough bold-after-bold-italic-underscore: @@ -3217,6 +3220,7 @@ contexts: bold-common: - include: emphasis-common - include: italic + - include: highlight - include: strikethrough italic: @@ -3256,8 +3260,25 @@ contexts: italic-common: - include: emphasis-common - include: bold + - include: highlight - include: strikethrough + highlight: + - match: ==(?![=>\s]) # 2x = but no => + scope: punctuation.definition.highlight.begin.markdown + push: highlight-content + - match: =+(?![=>\s]) # any number of = not looking like => + + highlight-content: + - meta_scope: markup.highlight.markdown + - match: ==(?!=) # 2x = + scope: punctuation.definition.highlight.end.markdown + pop: true + - match: '[ \t]*=+' + - include: emphasis-common + - include: bold + - include: italic + strikethrough: # https://github.github.com/gfm/#strikethrough-extension- - match: ~~(?![~}>\s]) # 2x ~ but no ~> or ~~} @@ -3270,7 +3291,7 @@ contexts: - match: ~~(?:(?!~)|(?=~~}|~>)) # 2x ~ maybe followed by ~> or ~~} scope: punctuation.definition.strikethrough.end.markdown pop: true - - match: ~+(?:(?!~)|(?=~~}|~>)) # any number of ~ maybe followed by ~> or ~~} + - match: '[ \t]*~+(?:(?!~)|(?=~~}|~>))' # any number of ~ maybe followed by ~> or ~~} - include: emphasis-common - include: bold - include: italic @@ -3759,7 +3780,7 @@ contexts: - meta_scope: meta.link.inet.markdown markup.underline.link.markdown-gfm # 1. When an autolink ends in ), we scan the entire autolink for the total # number of parentheses. If there is a greater number of closing parentheses - # than opening ones, we don’t consider the last character part of the + # than opening ones, we don’t consider the last character part of the # autolink, in order to facilitate including an autolink inside a parenthesis # 2. If an autolink ends in a semicolon (;), we check to see if it appears to # resemble an entity reference; if the preceding text is & followed by one diff --git a/tests/syntax_test_markdown.md b/tests/syntax_test_markdown.md index 79cdade7..beb66b8a 100644 --- a/tests/syntax_test_markdown.md +++ b/tests/syntax_test_markdown.md @@ -6947,6 +6947,117 @@ __test text__ *formatted* | ^ punctuation | ^ punctuation +# TEST: HIGHLIGHT ############################################################# + +__==bold highlight==__ +| <- markup.bold.markdown punctuation.definition.bold.begin.markdown +|^ markup.bold.markdown - markup.highlight +| ^^^^^^^^^^^^^^^^^^ markup.bold.markdown markup.highlight.markdown +| ^^ markup.bold.markdown - markup.highlight +|^ punctuation.definition.bold.begin.markdown +| ^^ punctuation.definition.highlight.begin.markdown +| ^^ punctuation.definition.highlight.end.markdown +| ^^ punctuation.definition.bold.end.markdown + +**==bold highlight==** +| <- markup.bold.markdown punctuation.definition.bold.begin.markdown +|^ markup.bold.markdown - markup.highlight +| ^^^^^^^^^^^^^^^^^^ markup.bold.markdown markup.highlight.markdown +| ^^ markup.bold.markdown - markup.highlight +|^ punctuation.definition.bold.begin.markdown +| ^^ punctuation.definition.highlight.begin.markdown +| ^^ punctuation.definition.highlight.end.markdown +| ^^ punctuation.definition.bold.end.markdown + +_==italic highlight==_ +| <- markup.italic.markdown punctuation.definition.italic.begin.markdown +|^^^^^^^^^^^^^^^^^^^^ markup.italic.markdown markup.highlight.markdown +| ^ markup.italic.markdown - markup.highlight +|^^ punctuation.definition.highlight.begin.markdown +| ^^ punctuation.definition.highlight.end.markdown +| ^ punctuation.definition.italic.end.markdown + +*==italic highlight==* +| <- markup.italic.markdown punctuation.definition.italic.begin.markdown +|^^^^^^^^^^^^^^^^^^^^ markup.italic.markdown markup.highlight.markdown +| ^ markup.italic.markdown - markup.highlight +|^^ punctuation.definition.highlight.begin.markdown +| ^^ punctuation.definition.highlight.end.markdown +| ^ punctuation.definition.italic.end.markdown + +___==bold italic highlight==___ +| <- markup.bold.markdown punctuation.definition.bold.begin.markdown +|^ markup.bold.markdown - markup.italic - markup.highlight +| ^ markup.bold.markdown markup.italic.markdown - markup.highlight +| ^^^^^^^^^^^^^^^^^^^^^^^^^ markup.bold.markdown markup.italic.markdown markup.highlight.markdown +| ^ markup.bold.markdown markup.italic.markdown - markup.highlight +| ^^ markup.bold.markdown - markup.italic - markup.highlight +|^ punctuation.definition.bold.begin.markdown +| ^ punctuation.definition.italic.begin.markdown +| ^^ punctuation.definition.highlight.begin.markdown +| ^^ punctuation.definition.highlight.end.markdown +| ^ punctuation.definition.italic.end.markdown +| ^^ punctuation.definition.bold.end.markdown + +***==bold italic highlight==*** +| <- markup.bold.markdown punctuation.definition.bold.begin.markdown +|^ markup.bold.markdown - markup.italic - markup.highlight +| ^ markup.bold.markdown markup.italic.markdown - markup.highlight +| ^^^^^^^^^^^^^^^^^^^^^^^^^ markup.bold.markdown markup.italic.markdown markup.highlight.markdown +| ^ markup.bold.markdown markup.italic.markdown - markup.highlight +| ^^ markup.bold.markdown - markup.italic - markup.highlight +|^ punctuation.definition.bold.begin.markdown +| ^ punctuation.definition.italic.begin.markdown +| ^^ punctuation.definition.highlight.begin.markdown +| ^^ punctuation.definition.highlight.end.markdown +| ^ punctuation.definition.italic.end.markdown +| ^^ punctuation.definition.bold.end.markdown + +=Hi= Hello, world! +| <- - punctuation.definition.highlight +|^^^^^^^^^^^^^^^^^ meta.paragraph - markup +| ^ - punctuation.definition.highlight + +This =text==== is ====curious=. +|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph - markup +| ^ - punctuation.definition.highlight +| ^^^^ - punctuation.definition.highlight +| ^^^^ - punctuation.definition.highlight +| ^ - punctuation.definition.highlight + +This ==text==== is ====curious==. +|^^^^ meta.paragraph - markup +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph markup.highlight +| ^^ meta.paragraph - markup +| ^^ punctuation.definition.highlight.begin +| ^^^^ - punctuation.definition.highlight +| ^^^^ - punctuation.definition.highlight +| ^^ punctuation.definition.highlight.end + +This ==is ==highlighted== inline text +|^^^^ - markup.highlight +| ^^^^^^^^^^^^^^^^^^^^ markup.highlight.markdown +| ^^^^^^^^^^^^ - markup.highlight + +This ==has a +| ^^^^^^^^ meta.paragraph markup.highlight + +| <- meta.paragraph markup.highlight invalid.illegal.non-terminated.bold-italic +new paragraph==. +| ^^ meta.paragraph markup.highlight punctuation.definition.highlight.begin + +| <- invalid.illegal.non-terminated.bold-italic + +A ==[highlight](https://link-url)== +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown + +A ==![highlight](https://image-url)== +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown + +A ==[![highlight](image-url)](link-url)== +| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.highlight.markdown + + # TEST: STRIKETHROUGH ######################################################### __~~bold striked~~__ @@ -7034,6 +7145,11 @@ This ~~text~~~~ is ~~~~curious~~. | ^^^^ - punctuation.definition.strikethrough | ^^ punctuation.definition.strikethrough.end +This ~~is ~~striked~~ inline text +|^^^^ - markup.strikethrough +| ^^^^^^^^^^^^^^^^ markup.strikethrough.markdown-gfm +| ^^^^^^^^^^^^^ - markup.strikethrough + This ~~has a | ^^^^^^^^ meta.paragraph markup.strikethrough @@ -7043,13 +7159,13 @@ new paragraph~~. | <- invalid.illegal.non-terminated.bold-italic -A ~~[striked](https://link-url)~~ +A ~~[highlight](https://link-url)~~ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.strikethrough.markdown-gfm -A ~~![striked](https://image-url)~~ +A ~~![highlight](https://image-url)~~ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.strikethrough.markdown-gfm -A ~~[![striked](image-url)](link-url)~~ +A ~~[![highlight](image-url)](link-url)~~ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.paragraph.markdown markup.strikethrough.markdown-gfm