Skip to content

Commit 0a30732

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 e875717 commit 0a30732

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
@@ -72,7 +72,6 @@ syn match markdownRule "- *- *-[ -]*$" contained
7272

7373
syn match markdownLineBreak " \{2,\}$"
7474

75-
syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite
7675
syn match markdownUrl "\S\+" nextgroup=markdownUrlTitle skipwhite contained
7776
syn region markdownUrl matchgroup=markdownUrlDelimiter start="<" end=">" oneline keepend nextgroup=markdownUrlTitle skipwhite contained
7877
syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+"+ end=+"+ keepend contained
@@ -83,6 +82,8 @@ syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(
8382
syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained
8483
syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained
8584
syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline
85+
syn region markdownShortcutLink matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\_[^][]*]\%( \=[[(]\)\@!\)\@=" end="\]" contains=@markdownInline,markdownLineStart
86+
syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite
8687

8788
let s:concealends = ''
8889
if has('conceal') && get(g:, 'markdown_syntax_conceal', 1) == 1
@@ -144,6 +145,7 @@ hi def link markdownLinkText htmlLink
144145
hi def link markdownIdDeclaration Typedef
145146
hi def link markdownId Type
146147
hi def link markdownAutomaticLink markdownUrl
148+
hi def link markdownShortcutLink markdownId
147149
hi def link markdownUrl Float
148150
hi def link markdownUrlTitle String
149151
hi def link markdownIdDelimiter markdownLinkDelimiter

0 commit comments

Comments
 (0)