Skip to content

Commit ecab949

Browse files
committed
scdoc: fix link highlighting
1 parent e2b945b commit ecab949

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

syntax/scdoc.vim

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,18 @@ syn match scdocDiscussion /\<discussion::/
7474
syn region scdocStrong matchgroup=scdocSimpleTag start=/\<strong::/ skip=/\\::/ end=/::/
7575
syn region scdocEmphasis matchgroup=scdocSimpleTag start=/\<emphasis::/ skip=/\\::/ end=/::/
7676
syn region scdocSoft matchgroup=scdocSimpleTag start=/\<soft::/ skip=/\\::/ end=/::/
77-
syn region scdocLink matchgroup=scdocSimpleTag start=/\<link::/ skip=/\\::/ end=/::/
77+
78+
" only highlight the first part of the link. order is important here
79+
syn region scdocRealLink keepend start=/\(\<link::\)\@<=/ end=/::/he=s-1 contained
80+
syn region scdocRealLink keepend start=/\(\<link::\)\@<=/ end=/#/he=s-1 contained
81+
syn region scdocRealLink keepend start=/\(\<link::[^#]*#\)\@<=/ end=/::/he=s-1 contained
82+
syn region scdocRealLink keepend start=/\(\<link::[^#]*#\)\@<=/ end=/#/he=s-1 contained
83+
syn region scdocLink keepend matchgroup=scdocSimpleTag start=/\<link::/ skip=/\\::/ end=/::/ contains=scdocRealLink
84+
7885
syn region scdocAnchor matchgroup=scdocSimpleTag start=/\<anchor::/ skip=/\\::/ end=/::/
7986
syn region scdocImage matchgroup=scdocSimpleTag start=/\<image::/ skip=/\\::/ end=/::/
8087

88+
8189
" teletype and code have inline and block forms
8290
" NOTE: make sure oneline version is last so it has priority!
8391
syn region scdocTeletype matchgroup=scdocSimpleTag start=/\<teletype::/ end=/^::/
@@ -179,7 +187,8 @@ hi def link scdocDiscussion Statement
179187
hi scdocStrong cterm=bold
180188
hi scdocEmphasis cterm=italic
181189
hi def link scdocSoft Comment
182-
hi def link scdocLink Underlined
190+
hi def link scdocRealLink Underlined
191+
" don't link scdocLink
183192
hi def link scdocAnchor Underlined
184193
hi def link scdocImage Underlined
185194
hi def link scdocTeletype Statement

0 commit comments

Comments
 (0)