Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions syntax/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ endif
syntax region mkdItalic matchgroup=mkdItalic start="\%(\*\|_\)" end="\%(\*\|_\)"
syntax region mkdBold matchgroup=mkdBold start="\%(\*\*\|__\)" end="\%(\*\*\|__\)"
syntax region mkdBoldItalic matchgroup=mkdBoldItalic start="\%(\*\*\*\|___\)" end="\%(\*\*\*\|___\)"
execute 'syntax region htmlItalic matchgroup=mkdItalic start="\%(^\|\s\)\zs\*\ze[^\\\*\t ]\%(\%([^*]\|\\\*\|\n\)*[^\\\*\t ]\)\?\*\_W" end="[^\\\*\t ]\zs\*\ze\_W" keepend contains=@Spell' . s:oneline . s:concealends
execute 'syntax region htmlItalic matchgroup=mkdItalic start="\%(^\|\s\)\zs_\ze[^\\_\t ]" end="[^\\_\t ]\zs_\ze\_W" keepend contains=@Spell' . s:oneline . s:concealends
execute 'syntax region htmlBold matchgroup=mkdBold start="\%(^\|\s\)\zs\*\*\ze\S" end="\S\zs\*\*" keepend contains=@Spell' . s:oneline . s:concealends
execute 'syntax region htmlBold matchgroup=mkdBold start="\%(^\|\s\)\zs__\ze\S" end="\S\zs__" keepend contains=@Spell' . s:oneline . s:concealends
execute 'syntax region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs\*\*\*\ze\S" end="\S\zs\*\*\*" keepend contains=@Spell' . s:oneline . s:concealends
execute 'syntax region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs___\ze\S" end="\S\zs___" keepend contains=@Spell' . s:oneline . s:concealends
execute 'syntax region htmlItalic matchgroup=mkdItalic start="\%(^\|[[:space:][:punct:] 、。()「」『』[]【】〚〛{}〈〉《》‹›«»〔〕〘〙‘’❛❜“”❝❞]\)\zs\*\ze[^\\\*\t ]\%(\%([^*]\|\\\*\|\n\)*[^\\\*\t ]\)\?\*\_W" end="[^\\\*\t ]\zs\*\ze\_W" keepend contains=@Spell' . s:oneline . s:concealends
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of repetition in here. Lets move this regex fragment to an s: variable that we setup once with the required expression, then reuse it in each place these matter. Otherwise the expressions quickly became unwieldy and it is easy to miss intended/unintended differences between them.

execute 'syntax region htmlItalic matchgroup=mkdItalic start="\%(^\|[[:space:][:punct:] 、。()「」『』[]【】〚〛{}〈〉《》‹›«»〔〕〘〙‘’❛❜“”❝❞]\)\zs_\ze[^\\_\t ]" end="[^\\_\t ]\zs_\ze\_W" keepend contains=@Spell' . s:oneline . s:concealends
execute 'syntax region htmlBold matchgroup=mkdBold start="\%(^\|[[:space:][:punct:] 、。()「」『』[]【】〚〛{}〈〉《》‹›«»〔〕〘〙‘’❛❜“”❝❞]\)\zs\*\*\ze\S" end="\S\zs\*\*" keepend contains=@Spell' . s:oneline . s:concealends
execute 'syntax region htmlBold matchgroup=mkdBold start="\%(^\|[[:space:][:punct:] 、。()「」『』[]【】〚〛{}〈〉《》‹›«»〔〕〘〙‘’❛❜“”❝❞]\)\zs__\ze\S" end="\S\zs__" keepend contains=@Spell' . s:oneline . s:concealends
execute 'syntax region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|[[:space:][:punct:] 、。()「」『』[]【】〚〛{}〈〉《》‹›«»〔〕〘〙‘’❛❜“”❝❞]\)\zs\*\*\*\ze\S" end="\S\zs\*\*\*" keepend contains=@Spell' . s:oneline . s:concealends
execute 'syntax region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|[[:space:][:punct:] 、。()「」『』[]【】〚〛{}〈〉《》‹›«»〔〕〘〙‘’❛❜“”❝❞]\)\zs___\ze\S" end="\S\zs___" keepend contains=@Spell' . s:oneline . s:concealends

" [link](URL) | [link][id] | [link][] | ![image](URL)
syntax region mkdFootnotes matchgroup=mkdDelimiter start="\[^" end="\]"
Expand Down