Skip to content

Commit 9869533

Browse files
committed
Add syntax highlighting for shortcut reference links
Shortcut reference links are defined in three of the most common Markdown implementations: - [Pandoc](https://pandoc.org/MANUAL.html#extension-shortcut_reference_links) - [CommonMark](https://spec.commonmark.org/0.29/#shortcut-reference-link) - [Github Flavored Markdown](https://github.github.com/gfm/#shortcut-reference-link)
1 parent 296eeaa commit 9869533

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

syntax/markdown.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ syn match markdownRule "- *- *-[ -]*$" contained
8181

8282
syn match markdownLineBreak " \{2,\}$"
8383

84-
syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite
8584
syn match markdownUrl "\S\+" nextgroup=markdownUrlTitle skipwhite contained
8685
syn region markdownUrl matchgroup=markdownUrlDelimiter start="<" end=">" oneline keepend nextgroup=markdownUrlTitle skipwhite contained
8786
syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+"+ end=+"+ keepend contained
@@ -92,6 +91,8 @@ syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(
9291
syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained
9392
syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained
9493
syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline
94+
syn region markdownShortcutLink matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\_[^][]*]\%( \=[[(]\)\@!\)\@=" end="\]" contains=@markdownInline,markdownLineStart
95+
syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite
9596

9697
let s:concealends = ''
9798
if has('conceal') && get(g:, 'markdown_syntax_conceal', 1) == 1
@@ -155,6 +156,7 @@ hi def link markdownLinkText htmlLink
155156
hi def link markdownIdDeclaration Typedef
156157
hi def link markdownId Type
157158
hi def link markdownAutomaticLink markdownUrl
159+
hi def link markdownShortcutLink markdownId
158160
hi def link markdownUrl Float
159161
hi def link markdownUrlTitle String
160162
hi def link markdownIdDelimiter markdownLinkDelimiter

0 commit comments

Comments
 (0)