vimwiki/syntax/vimwiki_html.vim
Tinmarino 1b16720b7b Refactor: Syntax highlighting typeface: match -> region: (Issues #847, #640)
- Less code, Easyer to maintain, to add a markup language
- Faster to load, and to highlight
- Support multiline tags: #847
- Support nested tags
- Support intraword tags: this<b>bold</b>type #640
2020-08-02 03:57:22 -04:00

35 lines
1.4 KiB
VimL

" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Home: https://github.com/vimwiki/vimwiki/
" Description: Defines html syntax
" Loaded: conditionaly by syntax/vimwiki.vim
" Copied from $VIMRUNTIME
" Note: The me=s-1 was omited from the region definition
" See: `syn region VimwikiBoldUnderlineItalic contained start="<i\>" end="</i\_s*>"me=s-1 contains=VimwikiHTMLTag...`
" Note: Not configurable
let s:html_tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.s:html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
" Typeface:
let html_typeface = {
\ 'bold': [['<b>', '</b\_s*>'], ['<strong>', '</strong\_s*>']],
\ 'italic': [['<i>', '</i\_s*>'], ['<em>', '</em\_s*>']],
\ 'underline': [['<u>', '</u\_s*>']],
\ }
call vimwiki#u#hi_typeface(html_typeface)
" Comment: home made
execute 'syntax match VimwikiComment /'.vimwiki#vars#get_syntaxlocal('rxComment').
\ '/ contains=@Spell,VimwikiTodo'
" Only do syntax highlighting for multiline comments if they exist
let s:mc_start = vimwiki#vars#get_syntaxlocal('rxMultilineCommentStart')
let s:mc_end = vimwiki#vars#get_syntaxlocal('rxMultilineCommentEnd')
if !empty(s:mc_start) && !empty(s:mc_end)
execute 'syntax region VimwikiMultilineComment start=/'.s:mc_start.
\ '/ end=/'.s:mc_end.'/ contains=@NoSpell,VimwikiTodo'
endif