Version 2.0.stu

This release is partly incompatible with 1.2.

You should delete previous version of vimwiki before install.

= Summary =

    * Quick page-link creation.
    * Redesign of link syntaxes (!)
        * No more CamelCase links. Check the ways to convert them http://goo.gl/15ctX
        * No more [[link][desc]] links.
        * No more [http://link description] links.
        * No more plain image links. Use transclusions.
        * No more image links identified by extension. Use transclusions.
    * Interwiki links.
    * Link schemes.
    * Transclusions.
    * Normalize link command.
    * Improved diary organization and generation.
    * List manipulation.
    * Markdown support.
    * Mathjax support.
    * Improved handling of special characters and punctuation in filenames and urls.
    * Back links command: list links referring to the current page.
    * Highlighting nonexisted links are off by default.
    * Table syntax change. Row separator uses | instead of +.
    * Fold multilined list items.
    * Custom wiki to HTML converters.
    * Conceal long weblinks.
    * Option to disable table mappings.

For detailed information see issues list on
http://code.google.com/p/vimwiki/issues/list
This commit is contained in:
Maxim Kim 2012-06-07 00:00:00 +00:00 committed by Able Scraper
parent 84297c9051
commit d5a6d097da
17 changed files with 4161 additions and 2011 deletions

39
README
View File

@ -5,8 +5,6 @@ A Personal Wiki For Vim Plugin
Screenshots are available on http://code.google.com/p/vimwiki/
There are also zipped vimwiki files there in case you do not like vimball archives.
Vimwiki quick reference card http://vimwiki.googlecode.com/hg/misc/Vimwiki1.1.1QR.pdf.
Prerequisites
==============================================================================
@ -24,31 +22,35 @@ Intro
Vimwiki is a personal wiki for Vim -- a number of linked text files that have
their own syntax highlighting.
With vimwiki you can
- organize notes and ideas
- manage todo-lists
- write documentation
With vimwiki you can:
- organize notes and ideas;
- manage todo-lists;
- write documentation.
To do a quick start press <Leader>ww (this is usually \ww) to go to your index
wiki file. By default it is located in:
wiki file. By default it is located in:
~/vimwiki/index.wiki
Feed it with the following example:
= My knowledge base =
* MyUrgentTasks -- things to be done _yesterday_!!!
* ProjectGutenberg -- good books are power.
* ScratchPad -- various temporary stuff.
* Tasks -- things to be done _yesterday_!!!
* Project Gutenberg -- good books are power.
* Scratchpad -- various temporary stuff.
Place your cursor on 'Tasks' and press Enter to create a link. Once pressed,
'Tasks' will become '[[Tasks]]' -- a vimwiki link. Press Enter again to
open it. Edit the file, save it, and then press Backspace to jump back to your
index.
Notice that !ProjectGutenberg, !MyUrgentTasks and !ScratchPad curly underlined.
These are links in CamelCase form that do not exists yet. (CamelCase
form -- capitalized word connected with other capitalized words)
A vimwiki link can be constructed from more than one word. Just visually
select the words to be linked and press Enter. Try it with 'Project
Gutenberg'. The result should look something like:
Place cursor on ProjectGutenberg and press <Enter>. Now you are in
ProjectGutenberg. Edit and save it, then press Backspace to return to parent
wiki page. You should see the difference now -- ProjectGutenberg is
highlighted as a link.
= My knowledge base =
* [[Tasks]] -- things to be done _yesterday_!!!
* [[Project Gutenberg]] -- good books are power.
* Scratchpad -- various temporary stuff.
For the various options see :h vimwiki-options.
@ -60,9 +62,8 @@ see :h vimwiki-syntax
*bold* -- bold
_italic_ -- italic
WikiWord -- link to WikiWord
[[wiki link]] -- link with spaces
[[wiki link][description]] -- link with description
[[wiki link|description]] -- link with description
Lists:

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,9 @@ endif
let g:loaded_vimwiki_diary_auto = 1
"}}}
let s:vimwiki_max_scan_for_caption = 5
" Helpers {{{
function! s:prefix_zero(num) "{{{
if a:num < 10
return '0'.a:num
@ -18,10 +21,6 @@ function! s:prefix_zero(num) "{{{
return a:num
endfunction "}}}
function! s:desc(d1, d2) "{{{
return a:d1 == a:d2 ? 0 : a:d1 < a:d2 ? 1 : -1
endfunction "}}}
function! s:get_date_link(fmt) "{{{
return strftime(a:fmt)
endfunction "}}}
@ -37,76 +36,26 @@ function! s:link_exists(lines, link) "{{{
return link_exists
endfunction "}}}
function! s:diary_path() "{{{
return VimwikiGet('path').VimwikiGet('diary_rel_path')
function! s:diary_path(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
return VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx)
endfunction "}}}
function! s:diary_index() "{{{
return s:diary_path().VimwikiGet('diary_index').VimwikiGet('ext')
function! s:diary_index(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
return s:diary_path(idx).VimwikiGet('diary_index', idx).VimwikiGet('ext', idx)
endfunction "}}}
function! s:get_diary_range(lines, header) "{{{
let rx = '\[\[\d\{4}-\d\d-\d\d\]\]'
let idx = 0
let ln_start = -1
let ln_end = -1
for line in a:lines
if ln_start != -1
if line =~ '^\s*\(=\)\+.*\1\s*$' || (line !~ rx && line !~ '^\s*$')
break
endif
endif
if line =~ '^\s*\(=\)\+\s*'.a:header.'\s*\1\s*$'
let ln_start = idx + 1
endif
let idx += 1
endfor
let ln_end = idx
return [ln_start, ln_end]
endfunction "}}}
function! s:diary_date_link() "{{{
return s:get_date_link(VimwikiGet('diary_link_fmt'))
endfunction "}}}
function! s:get_file_contents(file_name) "{{{
let lines = []
let bufnr = bufnr(expand(a:file_name))
if bufnr != -1
let lines = getbufline(bufnr, 1, '$')
else
try
let lines = readfile(expand(a:file_name))
catch
endtry
endif
return [lines, bufnr]
endfunction "}}}
function! s:get_links() "{{{
let rx = '\d\{4}-\d\d-\d\d'
let s_links = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').
\ '*'.VimwikiGet('ext'))
let s_links = substitute(s_links, '\'.VimwikiGet('ext'), "", "g")
let links = split(s_links, '\n')
" remove backup files (.wiki~)
call filter(links, 'v:val !~ ''.*\~$''')
" remove paths
call map(links, 'fnamemodify(v:val, ":t")')
call filter(links, 'v:val =~ "'.escape(rx, '\').'"')
return links
function! s:diary_date_link(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
return s:get_date_link(VimwikiGet('diary_link_fmt', idx))
endfunction "}}}
function! s:get_position_links(link) "{{{
let idx = -1
let links = []
if a:link =~ '\d\{4}-\d\d-\d\d'
let links = s:get_links()
if a:link =~ '^\d\{4}-\d\d-\d\d'
let links = keys(s:get_diary_links())
" include 'today' into links
if index(links, s:diary_date_link()) == -1
call add(links, s:diary_date_link())
@ -117,103 +66,263 @@ function! s:get_position_links(link) "{{{
return [idx, links]
endfunction "}}}
function! s:format_links(links) "{{{
let lines = []
let line = '| '
let idx = 0
let trigger = 0
while idx < len(a:links)
if idx/VimwikiGet('diary_link_count') > trigger
let trigger = idx/VimwikiGet('diary_link_count')
call add(lines, substitute(line, '\s\+$', '', ''))
let line = '| '
endif
let line .= a:links[idx].' | '
let idx += 1
endwhile
call add(lines, substitute(line, '\s\+$', '', ''))
call extend(lines, [''])
fun! s:get_month_name(month) "{{{
return g:vimwiki_diary_months[str2nr(a:month)]
endfun "}}}
return lines
endfunction "}}}
" Helpers }}}
function! s:add_link(page, header, link) "{{{
let [lines, bufnr] = s:get_file_contents(a:page)
" Diary index stuff {{{
fun! s:read_captions(files) "{{{
let result = {}
for fl in a:files
" remove paths and extensions
let fl_key = fnamemodify(fl, ':t:r')
let [ln_start, ln_end] = s:get_diary_range(lines, a:header)
let link = '[['.a:link.']]'
let link_exists = s:link_exists(lines[ln_start : ln_end], link)
if !link_exists
if ln_start == -1
call insert(lines, '= '.a:header.' =')
let ln_start = 1
let ln_end = 1
if filereadable(fl)
for line in readfile(fl, '', s:vimwiki_max_scan_for_caption)
if line =~ g:vimwiki_rxHeader && !has_key(result, fl_key)
let result[fl_key] = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
endif
endfor
endif
" removing 'old' links
let idx = ln_end - ln_start
while idx > 0
call remove(lines, ln_start)
let idx -= 1
endwhile
" get all diary links from filesystem
let links = s:get_links()
call map(links, '"[[".v:val."]]"')
" add current link
if index(links, link) == -1
call add(links, link)
if !has_key(result, fl_key)
let result[fl_key] = ''
endif
let links = sort(links, 's:desc')
call extend(lines, s:format_links(links), ln_start)
endfor
return result
endfun "}}}
if bufnr != -1
exe 'buffer '.bufnr
if !&readonly
1,$delete _
call append(1, lines)
1,1delete _
endif
fun! s:get_diary_links(...) "{{{
let rx = '^\d\{4}-\d\d-\d\d'
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
let files = split(s_files, '\n')
call filter(files, 'fnamemodify(v:val, ":t") =~ "'.escape(rx, '\').'"')
" remove backup files (.wiki~)
call filter(files, 'v:val !~ ''.*\~$''')
if a:0
call add(files, a:1)
endif
let links_with_captions = s:read_captions(files)
return links_with_captions
endfun "}}}
fun! s:group_links(links) "{{{
let result = {}
let p_year = 0
let p_month = 0
for fl in sort(keys(a:links))
let year = strpart(fl, 0, 4)
let month = strpart(fl, 5, 2)
if p_year != year
let result[year] = {}
let p_month = 0
endif
if p_month != month
let result[year][month] = {}
endif
let result[year][month][fl] = a:links[fl]
let p_year = year
let p_month = month
endfor
return result
endfun "}}}
fun! s:sort(lst) "{{{
if VimwikiGet("diary_sort") == 'desc'
return reverse(sort(a:lst))
else
return sort(a:lst)
endif
endfun "}}}
fun! s:format_diary(...) "{{{
let result = []
call add(result, substitute(g:vimwiki_rxH1_Template, '__Header__', VimwikiGet('diary_header'), ''))
if a:0
let g_files = s:group_links(s:get_diary_links(a:1))
else
let g_files = s:group_links(s:get_diary_links())
endif
" for year in s:rev(sort(keys(g_files)))
for year in s:sort(keys(g_files))
call add(result, '')
call add(result, substitute(g:vimwiki_rxH2_Template, '__Header__', year , ''))
" for month in s:rev(sort(keys(g_files[year])))
for month in s:sort(keys(g_files[year]))
call add(result, '')
call add(result, substitute(g:vimwiki_rxH3_Template, '__Header__', s:get_month_name(month), ''))
" for [fl, cap] in s:rev(sort(items(g_files[year][month])))
for [fl, cap] in s:sort(items(g_files[year][month]))
if empty(cap)
let entry = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', fl, '')
let entry = substitute(entry, '__LinkDescription__', cap, '')
call add(result, repeat(' ', &sw).'* '.entry)
else
let entry = substitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__', fl, '')
let entry = substitute(entry, '__LinkDescription__', cap, '')
call add(result, repeat(' ', &sw).'* '.entry)
endif
endfor
endfor
endfor
call add(result, '')
return result
endfun "}}}
function! s:delete_diary_section() "{{{
" remove diary section
let old_pos = getpos('.')
let ln_start = -1
let ln_end = -1
call cursor(1, 1)
if search(substitute(g:vimwiki_rxH1_Template, '__Header__', VimwikiGet('diary_header'), ''), 'Wc')
let ln_start = line('.')
if search(g:vimwiki_rxH1, 'W')
let ln_end = line('.') - 1
else
call writefile(lines, expand(a:page))
let ln_end = line('$')
endif
endif
if ln_start < 0 || ln_end < 0
call setpos('.', old_pos)
return
endif
if !&readonly
exe ln_start.",".ln_end."delete _"
endif
call setpos('.', old_pos)
endfunction "}}}
function! s:insert_diary_section() "{{{
if !&readonly
let ln = line('.')
call append(ln, s:format_diary())
if ln == 1 && getline(ln) == ''
1,1delete
endif
endif
endfunction "}}}
function! s:make_date_link(...) "{{{
if a:0
let link = a:1
else
let link = s:diary_date_link()
" Diary index stuff }}}
function! vimwiki#diary#make_note(wnum, ...) "{{{
if a:wnum > len(g:vimwiki_list)
echom "vimwiki: Wiki ".a:wnum." is not registered in g:vimwiki_list!"
return
endif
let header = VimwikiGet('diary_header')
call s:add_link(s:diary_index(), header, link)
return VimwikiGet('diary_rel_path').link
endfunction "}}}
function! vimwiki#diary#make_note(index, ...) "{{{
call vimwiki#base#select(a:index)
call vimwiki#base#mkdir(VimwikiGet('path').VimwikiGet('diary_rel_path'))
if a:0
let link = s:make_date_link(a:1)
" TODO: refactor it. base#goto_index uses the same
if a:wnum > 0
let idx = a:wnum - 1
else
let link = s:make_date_link()
let idx = 0
endif
call vimwiki#base#open_link(':e ', link, s:diary_index())
call vimwiki#base#validate_wiki_options(idx)
call vimwiki#base#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
if a:0
let cmd = 'tabedit'
else
let cmd = 'edit'
endif
if len(a:0)>1
let link = 'diary:'.a:2
else
let link = 'diary:'.s:diary_date_link(idx)
endif
call vimwiki#base#open_link(cmd, link, s:diary_index(idx))
call vimwiki#base#setup_buffer_state(idx)
endfunction "}}}
function! vimwiki#diary#goto_index(index) "{{{
call vimwiki#base#select(a:index)
call vimwiki#base#edit_file(':e', s:diary_index())
function! vimwiki#diary#goto_diary_index(wnum) "{{{
if a:wnum > len(g:vimwiki_list)
echom "vimwiki: Wiki ".a:wnum." is not registered in g:vimwiki_list!"
return
endif
" TODO: refactor it. base#goto_index uses the same
if a:wnum > 0
let idx = a:wnum - 1
else
let idx = 0
endif
call vimwiki#base#validate_wiki_options(idx)
call vimwiki#base#edit_file('e', s:diary_index(idx))
call vimwiki#base#setup_buffer_state(idx)
endfunction "}}}
" Calendar.vim callback function.
function! vimwiki#diary#goto_next_day() "{{{
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
if idx == (len(links) - 1)
return
endif
if idx != -1 && idx < len(links) - 1
let link = 'diary:'.links[idx+1]
else
" goto today
let link = 'diary:'.s:diary_date_link()
endif
if len(link)
call vimwiki#base#open_link(':e ', link)
endif
endfunction "}}}
function! vimwiki#diary#goto_prev_day() "{{{
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
if idx == 0
return
endif
if idx > 0
let link = 'diary:'.links[idx-1]
else
" goto today
let link = 'diary:'.s:diary_date_link()
endif
if len(link)
call vimwiki#base#open_link(':e ', link)
endif
endfunction "}}}
function! vimwiki#diary#generate_diary_section() "{{{
let current_file = vimwiki#u#path_norm(expand("%:p"))
let diary_file = vimwiki#u#path_norm(s:diary_index())
if current_file == diary_file
call s:delete_diary_section()
call s:insert_diary_section()
else
echom "vimwiki: You can generate diary links only in a diary index page!"
endif
endfunction "}}}
" Calendar.vim {{{
" Callback function.
function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
@ -233,10 +342,10 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
endif
" Create diary note for a selected date in default wiki.
call vimwiki#diary#make_note(1, link)
call vimwiki#diary#make_note(1, 0, link)
endfunction "}}}
" Calendar.vim sign function.
" Sign function.
function vimwiki#diary#calendar_sign(day, month, year) "{{{
let day = s:prefix_zero(a:day)
let month = s:prefix_zero(a:month)
@ -245,42 +354,5 @@ function vimwiki#diary#calendar_sign(day, month, year) "{{{
return filereadable(expand(sfile))
endfunction "}}}
function! vimwiki#diary#goto_next_day() "{{{
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
" Calendar.vim }}}
if idx == (len(links) - 1)
return
endif
if idx != -1 && idx < len(links) - 1
let link = VimwikiGet('diary_rel_path').links[idx+1]
else
" goto today
let link = VimwikiGet('diary_rel_path').s:diary_date_link()
endif
if len(link)
call vimwiki#base#open_link(':e ', link)
endif
endfunction "}}}
function! vimwiki#diary#goto_prev_day() "{{{
let link = ''
let [idx, links] = s:get_position_links(expand('%:t:r'))
if idx == 0
return
endif
if idx > 0
let link = VimwikiGet('diary_rel_path').links[idx-1]
else
" goto today
let link = VimwikiGet('diary_rel_path').s:diary_date_link()
endif
if len(link)
call vimwiki#base#open_link(':e ', link)
endif
endfunction "}}}

View File

@ -14,6 +14,15 @@ let g:loaded_vimwiki_html_auto = 1
"}}}
" UTILITY "{{{
function s:get_completion_index(sym) "{{{
for idx in range(1, 5)
if match(g:vimwiki_listsyms, '\C\%'.idx.'v'.a:sym) != -1
return (idx-1)
endif
endfor
return 0
endfunction "}}}
function! s:root_path(subdir) "{{{
return repeat('../', len(split(a:subdir, '[/\\]')))
endfunction "}}}
@ -36,7 +45,7 @@ function! s:is_web_link(lnk) "{{{
endfunction "}}}
function! s:is_img_link(lnk) "{{{
if a:lnk =~ '\.\%(png\|jpg\|gif\|jpeg\)$'
if tolower(a:lnk) =~ '\.\%(png\|jpg\|gif\|jpeg\)$'
return 1
endif
return 0
@ -59,9 +68,14 @@ function! s:find_autoload_file(name) " {{{
return ''
endfunction " }}}
function! s:create_default_CSS(path) " {{{
function! s:default_CSS_full_name(path) " {{{
let path = expand(a:path)
let css_full_name = path.VimwikiGet('css_name')
return css_full_name
endfunction "}}}
function! s:create_default_CSS(path) " {{{
let css_full_name = s:default_CSS_full_name(a:path)
if glob(css_full_name) == ""
call vimwiki#base#mkdir(fnamemodify(css_full_name, ':p:h'))
let default_css = s:find_autoload_file('style.css')
@ -81,8 +95,7 @@ function! s:template_full_name(name) "{{{
endif
let fname = expand(VimwikiGet('template_path').
\name.
\VimwikiGet('template_ext'))
\ name.VimwikiGet('template_ext'))
if filereadable(fname)
return fname
@ -95,8 +108,8 @@ function! s:get_html_template(wikifile, template) "{{{
" TODO: refactor it!!!
let lines=[]
let template_name = s:template_full_name(a:template)
if template_name != ''
if a:template != ''
let template_name = s:template_full_name(a:template)
try
let lines = readfile(template_name)
return lines
@ -106,27 +119,40 @@ function! s:get_html_template(wikifile, template) "{{{
endtry
endif
" if no VimwikiGet('html_template') set up or error while reading template
" file -- use default one.
let default_tpl = s:find_autoload_file('default.tpl')
if default_tpl != ''
let lines = readfile(default_tpl)
let default_tpl = s:template_full_name('')
if default_tpl == ''
let default_tpl = s:find_autoload_file('default.tpl')
endif
let lines = readfile(default_tpl)
return lines
endfunction "}}}
function! s:safe_html_tags(line) "{{{
let line = substitute(a:line,'<','\&lt;', 'g')
let line = substitute(line,'>','\&gt;', 'g')
return line
endfunction "}}}
function! s:safe_html(line) "{{{
" escape & < > when producing HTML text
" uses variables s:lt_pattern, s:gt_pattern that are
" set in vimwiki#html#Wiki2HTML() according to g:vimwiki_valid_html_tags
"" htmlize symbols: < > &
let line = substitute(a:line, '&', '\&amp;', 'g')
" the following depends on g:vimwiki_valid_html_tags
let line = substitute(line,s:lt_pattern,'\&lt;', 'g')
let line = substitute(line,s:gt_pattern,'\&gt;', 'g')
let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
let line = substitute(line,'<\%(/\?\%('
\.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!',
\'\&lt;', 'g')
let line = substitute(line,'\%(</\?\%('
\.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>',
\'\&gt;', 'g')
"let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
"let line = substitute(line,'<\%(/\?\%('
" \.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!',
" \'\&lt;', 'g')
"let line = substitute(line,'\%(</\?\%('
" \.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>',
" \'\&gt;', 'g')
return line
endfunction "}}}
@ -140,8 +166,8 @@ function! s:delete_html_files(path) "{{{
" delete if there is no corresponding wiki file
let subdir = vimwiki#base#subdir(VimwikiGet('path_html'), fname)
let wikifile = VimwikiGet("path").subdir.
\fnamemodify(fname, ":t:r").VimwikiGet("ext")
let wikifile = VimwikiGet('path').subdir.
\fnamemodify(fname, ":t:r").VimwikiGet('ext')
if filereadable(wikifile)
continue
endif
@ -182,12 +208,6 @@ function! s:save_vimwiki_buffer() "{{{
endif
endfunction "}}}
function! s:trim(string) "{{{
let res = substitute(a:string, '^\s\+', '', '')
let res = substitute(res, '\s\+$', '', '')
return res
endfunction "}}}
function! s:get_html_toc(toc_list) "{{{
" toc_list is list of [level, header_text, header_id]
" ex: [[1, "Header", "toc1"], [2, "Header2", "toc2"], ...]
@ -265,8 +285,7 @@ function! s:is_html_uptodate(wikifile) "{{{
endif
let wikifile = fnamemodify(a:wikifile, ":p")
let subdir = vimwiki#base#subdir(VimwikiGet('path'), wikifile)
let htmlfile = expand(VimwikiGet('path_html').subdir.
let htmlfile = expand(VimwikiGet('path_html').VimwikiGet('subdir').
\fnamemodify(wikifile, ":t:r").".html")
if getftime(wikifile) <= getftime(htmlfile) && tpl_time <= getftime(htmlfile)
@ -299,6 +318,11 @@ endfunction "}}}
"}}}
" INLINE TAGS "{{{
function! s:tag_eqin(value) "{{{
" mathJAX wants \( \) for inline maths
return '\('.s:mid(a:value, 1).'\)'
endfunction "}}}
function! s:tag_em(value) "{{{
return '<em>'.s:mid(a:value, 1).'</em>'
endfunction "}}}
@ -324,141 +348,113 @@ function! s:tag_sub(value) "{{{
endfunction "}}}
function! s:tag_code(value) "{{{
return '<code>'.s:mid(a:value, 1).'</code>'
return '<code>'.s:safe_html_tags(s:mid(a:value, 1)).'</code>'
endfunction "}}}
function! s:tag_pre(value) "{{{
return '<code>'.s:mid(a:value, 3).'</code>'
"function! s:tag_pre(value) "{{{
" return '<code>'.s:mid(a:value, 3).'</code>'
"endfunction "}}}
"FIXME dead code?
"function! s:tag_math(value) "{{{
" return '\['.s:mid(a:value, 3).'\]'
"endfunction "}}}
"{{{ v2.0 links
" match n-th ARG within {{URL[|ARG1|ARG2|...]}} " {{{
" *c,d,e),...
function! vimwiki#html#incl_match_arg(nn_index)
let rx = g:vimwiki_rxWikiInclPrefix. g:vimwiki_rxWikiInclUrl
let rx = rx. repeat(g:vimwiki_rxWikiInclSeparator. g:vimwiki_rxWikiInclArg, a:nn_index-1)
if a:nn_index > 0
let rx = rx. g:vimwiki_rxWikiInclSeparator. '\zs'. g:vimwiki_rxWikiInclArg. '\ze'
endif
let rx = rx. g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
return rx
endfunction
"}}}
function! vimwiki#html#linkify_link(src, descr) "{{{
let src_str = ' href="'.a:src.'"'
let descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','')
let descr = (descr == "" ? a:src : descr)
let descr_str = (descr =~ g:vimwiki_rxWikiIncl
\ ? s:tag_wikiincl(descr)
\ : descr)
return '<a'.src_str.'>'.descr_str.'</a>'
endfunction "}}}
function! s:tag_internal_link(value) "{{{
" Make <a href="This is a link">This is a link</a>
" from [[This is a link]]
" Make <a href="link">This is a link</a>
" from [[link|This is a link]]
" Make <a href="link">This is a link</a>
" from [[link][This is a link]]
" TODO: rename function -- it makes not only internal links.
" TODO: refactor it.
function! vimwiki#html#linkify_image(src, descr, verbatim_str) "{{{
let src_str = ' src="'.a:src.'"'
let descr_str = (a:descr != '' ? ' alt="'.a:descr.'"' : '')
let verbatim_str = (a:verbatim_str != '' ? ' '.a:verbatim_str : '')
return '<img'.src_str.descr_str.verbatim_str.' />'
endfunction "}}}
function! s:linkify(src, caption, style) "{{{
if a:style == ''
let style_str = ''
else
let style_str = ' style="'.a:style.'"'
endif
if s:is_img_link(a:caption)
let link = '<a href="'.a:src.'"><img src="'.a:caption.'"'.style_str.' />'.
\ '</a>'
elseif vimwiki#base#is_non_wiki_link(a:src)
let link = '<a href="'.a:src.'">'.a:caption.'</a>'
elseif s:is_img_link(a:src)
let link = '<img src="'.a:src.'" alt="'.a:caption.'"'. style_str.' />'
elseif vimwiki#base#is_link_to_dir(a:src)
if g:vimwiki_dir_link == ''
let link = '<a href="'.vimwiki#base#safe_link(a:src).'">'.a:caption.'</a>'
else
let link = '<a href="'.vimwiki#base#safe_link(a:src).
\ g:vimwiki_dir_link.'.html">'.a:caption.'</a>'
endif
else
let link = '<a href="'.vimwiki#base#safe_link(a:src).
\ '.html">'.a:caption.'</a>'
endif
return link
endfunction "}}}
let value = s:mid(a:value, 2)
let line = ''
if value =~ '|'
let link_parts = split(value, "|", 1)
else
let link_parts = split(value, "][", 1)
endif
if len(link_parts) > 1
if len(link_parts) < 3
let style = ""
else
let style = link_parts[2]
endif
let line = s:linkify(link_parts[0], link_parts[1], style)
else
let line = s:linkify(value, value, '')
endif
function! s:tag_weblink(value) "{{{
" Weblink Template -> <a href="url">descr</a>
let str = a:value
let url = matchstr(str, g:vimwiki_rxWeblinkMatchUrl)
let descr = matchstr(str, g:vimwiki_rxWeblinkMatchDescr)
let line = vimwiki#html#linkify_link(url, descr)
return line
endfunction "}}}
function! s:tag_external_link(value) "{{{
"" Make <a href="link">link desc</a>
"" from [link link desc]
let value = s:mid(a:value, 1)
let line = ''
if s:is_web_link(value)
let lnkElements = split(value)
let head = lnkElements[0]
let rest = join(lnkElements[1:])
if rest==""
let rest=head
function! s:tag_wikiincl(value) "{{{
" {{imgurl|arg1|arg2}} -> ???
" {{imgurl}} -> <img src="imgurl"/>
" {{imgurl|descr|style="A"}} -> <img src="imgurl" alt="descr" style="A" />
" {{imgurl|descr|class="B"}} -> <img src="imgurl" alt="descr" class="B" />
let str = a:value
" custom transclusions
let line = VimwikiWikiIncludeHandler(str)
" otherwise, assume image transclusion
if line == ''
let url_0 = matchstr(str, g:vimwiki_rxWikiInclMatchUrl)
let descr = matchstr(str, vimwiki#html#incl_match_arg(1))
let verbatim_str = matchstr(str, vimwiki#html#incl_match_arg(2))
" resolve url
let [idx, scheme, path, subdir, lnk, ext, url] =
\ vimwiki#base#resolve_scheme(url_0, 1)
" generate html output
" TODO: migrate non-essential debugging messages into g:VimwikiLog
if g:vimwiki_debug > 1
echom '{{idx='.idx.', scheme='.scheme.', path='.path.', subdir='.subdir.', lnk='.lnk.', ext='.ext.'}}'
endif
if s:is_img_link(rest)
if rest!=head
let line = '<a href="'.head.'"><img src="'.rest.'" /></a>'
else
let line = '<img src="'.rest.'" />'
endif
else
let line = '<a href="'.head.'">'.rest.'</a>'
endif
elseif s:is_img_link(value)
let line = '<img src="'.value.'" />'
else
" [alskfj sfsf] shouldn't be a link. So return it as it was --
" enclosed in [...]
let line = '['.value.']'
endif
return line
endfunction "}}}
function! s:tag_wikiword_link(value) "{{{
" Make <a href="WikiWord">WikiWord</a> from WikiWord
if a:value[0] == '!'
return a:value[1:]
elseif g:vimwiki_camel_case
let line = '<a href="'.a:value.'.html">'.a:value.'</a>'
let url = escape(url, '#')
let line = vimwiki#html#linkify_image(url, descr, verbatim_str)
return line
else
return a:value
endif
endfunction "}}}
function! s:tag_barebone_link(value) "{{{
"" Make <a href="http://habamax.ru">http://habamax.ru</a>
"" from http://habamax.ru
if s:is_img_link(a:value)
let line = '<img src="'.a:value.'" />'
else
let line = '<a href="'.a:value.'">'.a:value.'</a>'
endif
return line
endfunction "}}}
function! s:tag_no_wikiword_link(value) "{{{
if a:value[0] == '!'
return a:value[1:]
else
return a:value
function! s:tag_wikilink(value) "{{{
" [[url]] -> <a href="url.html">url</a>
" [[url|descr]] -> <a href="url.html">descr</a>
" [[url|{{...}}]] -> <a href="url.html"> ... </a>
" [[fileurl.ext|descr]] -> <a href="fileurl.ext">descr</a>
" [[dirurl/|descr]] -> <a href="dirurl/index.html">descr</a>
let str = a:value
let url = matchstr(str, g:vimwiki_rxWikiLinkMatchUrl)
let descr = matchstr(str, g:vimwiki_rxWikiLinkMatchDescr)
let descr = (substitute(descr,'^\s*\(.*\)\s*$','\1','') != '' ? descr : url)
" resolve url
let [idx, scheme, path, subdir, lnk, ext, url] =
\ vimwiki#base#resolve_scheme(url, 1)
" generate html output
" TODO: migrate non-essential debugging messages into g:VimwikiLog
if g:vimwiki_debug > 1
echom '[[idx='.idx.', scheme='.scheme.', path='.path.', subdir='.subdir.', lnk='.lnk.', ext='.ext.']]'
endif
let url = escape(url, '#')
let line = vimwiki#html#linkify_link(url, descr)
return line
endfunction "}}}
"}}} v1.3 links
function! s:tag_remove_internal_link(value) "{{{
let value = s:mid(a:value, 2)
@ -508,10 +504,16 @@ endfunction "}}}
function! s:make_tag(line, regexp, func) "{{{
" Make tags for a given matched regexp.
" Exclude preformatted text and href links.
" FIXME
let patt_splitter = '\(`[^`]\+`\)\|'.
\ '\('.g:vimwiki_rxPreStart.'.\+'.g:vimwiki_rxPreEnd.'\)\|'.
\ '\(<a href.\{-}</a>\)\|'.
\ '\(<img src.\{-}/>\)\|'.
\ '\('.g:vimwiki_rxEqIn.'\)'
let patt_splitter = '\(`[^`]\+`\)\|\({{{.\+}}}\)\|'.
\ '\(<a href.\{-}</a>\)\|\(<img src.\{-}/>\)'
if '`[^`]\+`' == a:regexp || '{{{.\+}}}' == a:regexp
"FIXME FIXME !!! these can easily occur on the same line!
"XXX {{{ }}} ??? obsolete
if '`[^`]\+`' == a:regexp || '{{{.\+}}}' == a:regexp || g:vimwiki_rxEqIn == a:regexp
let res_line = s:subst_func(a:line, a:regexp, a:func)
else
let pos = 0
@ -541,7 +543,6 @@ endfunction " }}}
function! s:process_tags_typefaces(line) "{{{
let line = a:line
let line = s:make_tag(line, g:vimwiki_rxNoWikiWord, 's:tag_no_wikiword_link')
let line = s:make_tag(line, g:vimwiki_rxItalic, 's:tag_em')
let line = s:make_tag(line, g:vimwiki_rxBold, 's:tag_strong')
let line = s:make_tag(line, g:vimwiki_rxTodo, 's:tag_todo')
@ -549,15 +550,15 @@ function! s:process_tags_typefaces(line) "{{{
let line = s:make_tag(line, g:vimwiki_rxSuperScript, 's:tag_super')
let line = s:make_tag(line, g:vimwiki_rxSubScript, 's:tag_sub')
let line = s:make_tag(line, g:vimwiki_rxCode, 's:tag_code')
let line = s:make_tag(line, g:vimwiki_rxEqIn, 's:tag_eqin')
return line
endfunction " }}}
function! s:process_tags_links(line) " {{{
let line = a:line
let line = s:make_tag(line, '\[\[.\{-}\]\]', 's:tag_internal_link')
let line = s:make_tag(line, '\[.\{-}\]', 's:tag_external_link')
let line = s:make_tag(line, g:vimwiki_rxWeblink, 's:tag_barebone_link')
let line = s:make_tag(line, g:vimwiki_rxWikiWord, 's:tag_wikiword_link')
let line = s:make_tag(line, g:vimwiki_rxWikiLink, 's:tag_wikilink')
let line = s:make_tag(line, g:vimwiki_rxWikiIncl, 's:tag_wikiincl')
let line = s:make_tag(line, g:vimwiki_rxWeblink, 's:tag_weblink')
return line
endfunction " }}}
@ -577,6 +578,14 @@ function! s:close_tag_pre(pre, ldest) "{{{
return a:pre
endfunction "}}}
function! s:close_tag_math(math, ldest) "{{{
if a:math[0]
call insert(a:ldest, "\\\]")
return 0
endif
return a:math
endfunction "}}}
function! s:close_tag_quote(quote, ldest) "{{{
if a:quote
call insert(a:ldest, "</blockquote>")
@ -745,11 +754,15 @@ endfunction! "}}}
function! s:process_tag_pre(line, pre) "{{{
" pre is the list of [is_in_pre, indent_of_pre]
"XXX always outputs a single line or empty list!
let lines = []
let pre = a:pre
let processed = 0
if !pre[0] && a:line =~ '^\s*{{{[^\(}}}\)]*\s*$'
"XXX huh?
"if !pre[0] && a:line =~ '^\s*{{{[^\(}}}\)]*\s*$'
if !pre[0] && a:line =~ '^\s*{{{'
let class = matchstr(a:line, '{{{\zs.*$')
"FIXME class cannot contain arbitrary strings
let class = substitute(class, '\s\+$', '', 'g')
if class != ""
call add(lines, "<pre ".class.">")
@ -764,11 +777,48 @@ function! s:process_tag_pre(line, pre) "{{{
let processed = 1
elseif pre[0]
let processed = 1
call add(lines, substitute(a:line, '^\s\{'.pre[1].'}', '', ''))
"XXX destroys indent in general!
"call add(lines, substitute(a:line, '^\s\{'.pre[1].'}', '', ''))
call add(lines, s:safe_html_tags(a:line))
endif
return [processed, lines, pre]
endfunction "}}}
function! s:process_tag_math(line, math) "{{{
" math is the list of [is_in_math, indent_of_math]
let lines = []
let math = a:math
let processed = 0
if !math[0] && a:line =~ '^\s*{{\$[^\(}}$\)]*\s*$'
let class = matchstr(a:line, '{{$\zs.*$')
"FIXME class cannot be any string!
let class = substitute(class, '\s\+$', '', 'g')
" Check the math placeholder (default: displaymath)
let b:vimwiki_mathEnv = matchstr(class, '^%\zs\S\+\ze%')
if b:vimwiki_mathEnv != ""
call add(lines, substitute(class, '^%\(\S\+\)%','\\begin{\1}', ''))
elseif class != ""
call add(lines, "\\\[".class)
else
call add(lines, "\\\[")
endif
let math = [1, len(matchstr(a:line, '^\s*\ze{{\$'))]
let processed = 1
elseif math[0] && a:line =~ '^\s*}}\$\s*$'
let math = [0, 0]
if b:vimwiki_mathEnv != ""
call add(lines, "\\end{".b:vimwiki_mathEnv."}")
else
call add(lines, "\\\]")
endif
let processed = 1
elseif math[0]
let processed = 1
call add(lines, substitute(a:line, '^\s\{'.math[1].'}', '', ''))
endif
return [processed, lines, math]
endfunction "}}}
function! s:process_tag_quote(line, quote) "{{{
let lines = []
let quote = a:quote
@ -800,7 +850,8 @@ function! s:process_tag_list(line, lists) "{{{
if chk[1] =~ '[.*\\^$~]'
let chk[1] ='\'.chk[1]
endif
let completion = match(g:vimwiki_listsyms, '\C' . chk[1])
" let completion = match(g:vimwiki_listsyms, '\C' . chk[1])
let completion = s:get_completion_index(chk[1])
if completion >= 0 && completion <=4
let st_tag = '<li class="done'.completion.'">'
endif
@ -935,18 +986,9 @@ function! s:process_tag_h(line, id) "{{{
let h_level = 0
let h_text = ''
let h_id = ''
if a:line =~ g:vimwiki_rxH6
let h_level = 6
elseif a:line =~ g:vimwiki_rxH5
let h_level = 5
elseif a:line =~ g:vimwiki_rxH4
let h_level = 4
elseif a:line =~ g:vimwiki_rxH3
let h_level = 3
elseif a:line =~ g:vimwiki_rxH2
let h_level = 2
elseif a:line =~ g:vimwiki_rxH1
let h_level = 1
if a:line =~ g:vimwiki_rxHeader
let h_level = vimwiki#u#count_first_sym(a:line)
endif
if h_level > 0
let a:id[h_level] += 1
@ -960,8 +1002,6 @@ function! s:process_tag_h(line, id) "{{{
let centered = 1
endif
let line = s:trim(line)
let h_number = ''
for l in range(1, h_level-1)
let h_number .= a:id[l].'.'
@ -978,7 +1018,8 @@ function! s:process_tag_h(line, id) "{{{
let h_part .= '>'
endif
let h_text = s:trim(strpart(line, h_level, len(line) - h_level * 2))
let h_text = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader))
if g:vimwiki_html_header_numbering
let num = matchstr(h_number,
\ '^\(\d.\)\{'.(g:vimwiki_html_header_numbering-1).'}\zs.*')
@ -1046,14 +1087,15 @@ function! s:process_tag_table(line, table) "{{{
let lines = []
let processed = 0
if a:line =~ '^\s*|[-+]\+|\s*$'
if vimwiki#tbl#is_separator(a:line)
call extend(table, s:table_add_row(a:table, a:line))
let processed = 1
elseif a:line =~ '^\s*|.\+|\s*$'
elseif vimwiki#tbl#is_table(a:line)
call extend(table, s:table_add_row(a:table, a:line))
let processed = 1
let cells = split(a:line, '\s*|\s*', 1)[1: -2]
" let cells = split(a:line, vimwiki#tbl#cell_splitter(), 1)[1: -2]
let cells = vimwiki#tbl#get_cells(a:line)
call map(cells, 's:table_empty_cell(v:val)')
call extend(table[-1], cells)
else
@ -1072,6 +1114,7 @@ function! s:parse_line(line, state) " {{{
let state.para = a:state.para
let state.quote = a:state.quote
let state.pre = a:state.pre[:]
let state.math = a:state.math[:]
let state.table = a:state.table[:]
let state.lists = a:state.lists[:]
let state.deflist = a:state.deflist
@ -1135,6 +1178,9 @@ function! s:parse_line(line, state) " {{{
" if processed && len(state.lists)
" call s:close_tag_list(state.lists, lines)
" endif
if !processed
let [processed, lines, state.math] = s:process_tag_math(line, state.math)
endif
if processed && len(state.table)
let state.table = s:close_tag_table(state.table, lines)
endif
@ -1160,6 +1206,9 @@ function! s:parse_line(line, state) " {{{
if processed && state.pre[0]
let state.pre = s:close_tag_pre(state.pre, lines)
endif
if processed && state.math[0]
let state.math = s:close_tag_math(state.math, lines)
endif
if processed && len(state.table)
let state.table = s:close_tag_table(state.table, lines)
endif
@ -1183,6 +1232,7 @@ function! s:parse_line(line, state) " {{{
call s:close_tag_list(state.lists, res_lines)
let state.table = s:close_tag_table(state.table, res_lines)
let state.pre = s:close_tag_pre(state.pre, res_lines)
let state.math = s:close_tag_math(state.math, res_lines)
let state.quote = s:close_tag_quote(state.quote, res_lines)
let state.para = s:close_tag_para(state.para, res_lines)
@ -1218,6 +1268,9 @@ function! s:parse_line(line, state) " {{{
if processed && state.pre[0]
let state.pre = s:close_tag_pre(state.pre, lines)
endif
if processed && state.math[0]
let state.math = s:close_tag_math(state.math, lines)
endif
if processed && state.para
let state.para = s:close_tag_para(state.para, lines)
endif
@ -1235,6 +1288,7 @@ function! s:parse_line(line, state) " {{{
call s:close_tag_list(state.lists, res_lines)
let state.table = s:close_tag_table(state.table, res_lines)
let state.pre = s:close_tag_pre(state.pre, res_lines)
let state.math = s:close_tag_math(state.math, res_lines)
call add(res_lines, line)
endif
endif
@ -1262,6 +1316,9 @@ function! s:parse_line(line, state) " {{{
if processed && state.pre[0]
let state.pre = s:close_tag_pre(state.pre, res_lines)
endif
if processed && state.math[0]
let state.math = s:close_tag_math(state.math, res_lines)
endif
if processed && len(state.table)
let state.table = s:close_tag_table(state.table, res_lines)
endif
@ -1281,128 +1338,174 @@ function! s:parse_line(line, state) " {{{
endfunction " }}}
function! vimwiki#html#Wiki2HTML(path, wikifile) "{{{
function! s:use_custom_wiki2html() "{{{
let custom_wiki2html = VimwikiGet('custom_wiki2html')
return !empty(custom_wiki2html) && s:file_exists(custom_wiki2html)
endfunction " }}}
function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) "{{{
call vimwiki#base#mkdir(a:path)
execute '!'.VimwikiGet('custom_wiki2html'). ' '
\ a:force. ' '.
\ VimwikiGet('syntax'). ' '.
\ strpart(VimwikiGet('ext'), 1). ' '.
\ a:path. ' '.
\ a:wikifile. ' '.
\ s:default_CSS_full_name(a:path)
endfunction " }}}
function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
let starttime = reltime() " start the clock
echo 'Generating HTML ... '
if !s:syntax_supported()
echomsg 'vimwiki: Only vimwiki_default syntax supported!!!'
return
endif
let done = 0
let wikifile = fnamemodify(a:wikifile, ":p")
let subdir = vimwiki#base#subdir(VimwikiGet('path'), wikifile)
let path = expand(a:path).subdir
let path_html = expand(a:path_html).VimwikiGet('subdir')
let htmlfile = fnamemodify(wikifile, ":t:r").'.html'
let lsource = readfile(wikifile)
let ldest = []
if s:use_custom_wiki2html()
let force = 1
call vimwiki#html#CustomWiki2HTML(path_html, wikifile, force)
let done = 1
endif
call vimwiki#base#mkdir(path)
if s:syntax_supported() && done == 0
let lsource = readfile(wikifile)
let ldest = []
" nohtml placeholder -- to skip html generation.
let nohtml = 0
"if g:vimwiki_debug
" echo 'Generating HTML ... '
"endif
" template placeholder
let template_name = ''
call vimwiki#base#mkdir(path_html)
" for table of contents placeholders.
let placeholders = []
" nohtml placeholder -- to skip html generation.
let nohtml = 0
" current state of converter
let state = {}
let state.para = 0
let state.quote = 0
let state.pre = [0, 0] " [in_pre, indent_pre]
let state.table = []
let state.deflist = 0
let state.lists = []
let state.placeholder = []
let state.toc = []
let state.toc_id = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0 }
" template placeholder
let template_name = ''
for line in lsource
let oldquote = state.quote
let [lines, state] = s:parse_line(line, state)
" for table of contents placeholders.
let placeholders = []
" Hack: There could be a lot of empty strings before s:process_tag_quote
" find out `quote` is over. So we should delete them all. Think of the way
" to refactor it out.
if oldquote != state.quote
call s:remove_blank_lines(ldest)
" current state of converter
let state = {}
let state.para = 0
let state.quote = 0
let state.pre = [0, 0] " [in_pre, indent_pre]
let state.math = [0, 0] " [in_math, indent_math]
let state.table = []
let state.deflist = 0
let state.lists = []
let state.placeholder = []
let state.toc = []
let state.toc_id = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0 }
" prepare constants for s:safe_html()
let s:lt_pattern = '<'
let s:gt_pattern = '>'
if g:vimwiki_valid_html_tags != ''
let tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
let s:lt_pattern = '<\%(/\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!'
let s:gt_pattern = '\%(</\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>'
endif
if !empty(state.placeholder)
if state.placeholder[0] == 'nohtml'
let nohtml = 1
break
elseif state.placeholder[0] == 'template'
let template_name = state.placeholder[1]
else
call add(placeholders, [state.placeholder, len(ldest), len(placeholders)])
for line in lsource
let oldquote = state.quote
let [lines, state] = s:parse_line(line, state)
" Hack: There could be a lot of empty strings before s:process_tag_quote
" find out `quote` is over. So we should delete them all. Think of the way
" to refactor it out.
if oldquote != state.quote
call s:remove_blank_lines(ldest)
endif
let state.placeholder = []
if !empty(state.placeholder)
if state.placeholder[0] == 'nohtml'
let nohtml = 1
break
elseif state.placeholder[0] == 'template'
let template_name = state.placeholder[1]
else
call add(placeholders, [state.placeholder, len(ldest), len(placeholders)])
endif
let state.placeholder = []
endif
call extend(ldest, lines)
endfor
if nohtml
echon "\r"."%nohtml placeholder found"
return
endif
let toc = s:get_html_toc(state.toc)
call s:process_toc(ldest, placeholders, toc)
call s:remove_blank_lines(ldest)
"" process end of file
"" close opened tags if any
let lines = []
call s:close_tag_quote(state.quote, lines)
call s:close_tag_para(state.para, lines)
call s:close_tag_pre(state.pre, lines)
call s:close_tag_math(state.math, lines)
call s:close_tag_list(state.lists, lines)
call s:close_tag_def_list(state.deflist, lines)
call s:close_tag_table(state.table, lines)
call extend(ldest, lines)
endfor
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
if nohtml
echon "\r"."%nohtml placeholder found"
let html_lines = s:get_html_template(a:wikifile, template_name)
" processing template variables (refactor to a function)
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
call map(html_lines, 'substitute(v:val, "%root_path%", "'.
\ s:root_path(VimwikiGet('subdir')) .'", "g")')
let css_name = expand(VimwikiGet('css_name'))
let css_name = substitute(css_name, '\', '/', 'g')
call map(html_lines, 'substitute(v:val, "%css%", "'. css_name .'", "g")')
let enc = &fileencoding
if enc == ''
let enc = &encoding
endif
call map(html_lines, 'substitute(v:val, "%encoding%", "'. enc .'", "g")')
let html_lines = s:html_insert_contents(html_lines, ldest) " %contents%
"" make html file.
call writefile(html_lines, path_html.htmlfile)
let done = 1
endif
if done == 0
echomsg 'vimwiki: conversion to HTML is not supported for this syntax!!!'
return
endif
let toc = s:get_html_toc(state.toc)
call s:process_toc(ldest, placeholders, toc)
call s:remove_blank_lines(ldest)
" measure the elapsed time
let time1 = vimwiki#u#time(starttime) "XXX
call VimwikiLog_extend('html',[htmlfile,time1])
"if g:vimwiki_debug
" echon "\r".htmlfile.' written (time: '.time1.'s)'
"endif
"" process end of file
"" close opened tags if any
let lines = []
call s:close_tag_quote(state.quote, lines)
call s:close_tag_para(state.para, lines)
call s:close_tag_pre(state.pre, lines)
call s:close_tag_list(state.lists, lines)
call s:close_tag_def_list(state.deflist, lines)
call s:close_tag_table(state.table, lines)
call extend(ldest, lines)
let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r"))
let html_lines = s:get_html_template(a:wikifile, template_name)
" processing template variables (refactor to a function)
call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")')
call map(html_lines, 'substitute(v:val, "%root_path%", "'.
\ s:root_path(subdir) .'", "g")')
let css_name = expand(VimwikiGet('css_name'))
let css_name = substitute(css_name, '\', '/', 'g')
call map(html_lines, 'substitute(v:val, "%css%", "'. css_name .'", "g")')
let enc = &fileencoding
if enc == ''
let enc = &encoding
endif
call map(html_lines, 'substitute(v:val, "%encoding%", "'. enc .'", "g")')
let html_lines = s:html_insert_contents(html_lines, ldest) " %contents%
"" make html file.
call writefile(html_lines, path.htmlfile)
" measure the elapsed time and cut away miliseconds and smaller
let elapsedtimestr = matchstr(reltimestr(reltime(starttime)),'\d\+\(\.\d\d\)\=')
echon "\r".htmlfile.' written (time: '.elapsedtimestr.'s)'
return path.htmlfile
return path_html.htmlfile
endfunction "}}}
function! vimwiki#html#WikiAll2HTML(path) "{{{
if !s:syntax_supported()
echomsg 'vimwiki: Only vimwiki_default syntax supported!!!'
function! vimwiki#html#WikiAll2HTML(path_html) "{{{
if !s:syntax_supported() && !s:use_custom_wiki2html()
echomsg 'vimwiki: conversion to HTML is not supported for this syntax!!!'
return
endif
@ -1414,28 +1517,63 @@ function! vimwiki#html#WikiAll2HTML(path) "{{{
exe 'buffer '.cur_buf
let &eventignore = save_eventignore
let path = expand(a:path)
call vimwiki#base#mkdir(path)
let path_html = expand(a:path_html)
call vimwiki#base#mkdir(path_html)
echomsg 'Deleting non-wiki html files...'
call s:delete_html_files(path)
call s:delete_html_files(path_html)
echomsg 'Converting wiki to html files...'
let setting_more = &more
setlocal nomore
" temporarily adjust current_subdir global state variable
let current_subdir = VimwikiGet('subdir')
let current_invsubdir = VimwikiGet('invsubdir')
let wikifiles = split(glob(VimwikiGet('path').'**/*'.VimwikiGet('ext')), '\n')
for wikifile in wikifiles
let wikifile = fnamemodify(wikifile, ":p")
" temporarily adjust 'subdir' and 'invsubdir' state variables
let subdir = vimwiki#base#subdir(VimwikiGet('path'), wikifile)
call VimwikiSet('subdir', subdir)
call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir))
if !s:is_html_uptodate(wikifile)
echomsg 'Processing '.wikifile
call vimwiki#html#Wiki2HTML(path, wikifile)
call vimwiki#html#Wiki2HTML(path_html, wikifile)
else
echomsg 'Skipping '.wikifile
endif
endfor
call s:create_default_CSS(path)
" reset 'subdir' state variable
call VimwikiSet('subdir', current_subdir)
call VimwikiSet('invsubdir', current_invsubdir)
call s:create_default_CSS(path_html)
echomsg 'Done!'
let &more = setting_more
endfunction "}}}
function! s:file_exists(fname) "{{{
return !empty(getftype(a:fname))
endfunction "}}}
" uses VimwikiGet('path')
function! vimwiki#html#get_wikifile_url(wikifile) "{{{
return VimwikiGet('path_html').
\ vimwiki#base#subdir(VimwikiGet('path'), a:wikifile).
\ fnamemodify(a:wikifile, ":t:r").'.html'
endfunction "}}}
function! vimwiki#html#PasteUrl(wikifile) "{{{
execute 'r !echo file://'.vimwiki#html#get_wikifile_url(a:wikifile)
endfunction "}}}
function! vimwiki#html#CatUrl(wikifile) "{{{
execute '!echo file://'.vimwiki#html#get_wikifile_url(a:wikifile)
endfunction "}}}
"}}}

View File

@ -15,24 +15,36 @@ let s:rx_li_box = '\[.\?\]'
" Script functions {{{
" Get unicode string symbol at index
function! s:str_idx(str, idx) "{{{
" Unfortunatly vimscript cannot get symbol at index in unicode string such as
" '✗○◐●✓'
return matchstr(a:str, '\%'.a:idx.'v.')
endfunction "}}}
" Get checkbox regexp
function! s:rx_li_symbol(rate) "{{{
let result = ''
if a:rate == 100
let result = g:vimwiki_listsyms[4]
let result = s:str_idx(g:vimwiki_listsyms, 5)
elseif a:rate == 0
let result = g:vimwiki_listsyms[0]
let result = s:str_idx(g:vimwiki_listsyms, 1)
elseif a:rate >= 67
let result = g:vimwiki_listsyms[3]
let result = s:str_idx(g:vimwiki_listsyms, 4)
elseif a:rate >= 34
let result = g:vimwiki_listsyms[2]
let result = s:str_idx(g:vimwiki_listsyms, 3)
else
let result = g:vimwiki_listsyms[1]
let result = s:str_idx(g:vimwiki_listsyms, 2)
endif
return '\['.result.'\]'
endfunction "}}}
" Get blank checkbox
function! s:blank_checkbox() "{{{
return '['.s:str_idx(g:vimwiki_listsyms, 1).'] '
endfunction "}}}
" Get regexp of the list item.
function! s:rx_list_item() "{{{
return '\('.g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.'\)'
@ -46,7 +58,7 @@ endfunction "}}}
" Get level of the list item.
function! s:get_level(lnum) "{{{
if VimwikiGet('syntax') == 'media'
let level = vimwiki#base#count_first_sym(getline(a:lnum))
let level = vimwiki#u#count_first_sym(getline(a:lnum))
else
let level = indent(a:lnum)
endif
@ -222,7 +234,7 @@ function! s:create_cb_list_item(lnum) "{{{
let m = matchstr(line, s:rx_list_item())
if m != ''
let li_content = substitute(strpart(line, len(m)), '^\s*', '', '')
let line = substitute(m, '\s*$', ' ', '').'[ ] '.li_content
let line = substitute(m, '\s*$', ' ', '').s:blank_checkbox().li_content
call setline(a:lnum, line)
endif
endfunction "}}}
@ -320,7 +332,7 @@ function! vimwiki#lst#kbd_cr() "{{{
" This function is heavily relies on proper 'set comments' option.
let cr = "\<CR>"
if getline('.') =~ s:rx_cb_list_item()
let cr .= '[ ] '
let cr .= s:blank_checkbox()
endif
return cr
endfunction "}}}
@ -341,11 +353,10 @@ function! vimwiki#lst#kbd_oO(cmd) "{{{
let lnum = line('.')
endif
" let line = substitute(m, '\s*$', ' ', '').'[ ] '.li_content
let m = matchstr(line, s:rx_list_item())
let res = ''
if line =~ s:rx_cb_list_item()
let res = substitute(m, '\s*$', ' ', '').'[ ] '
let res = substitute(m, '\s*$', ' ', '').s:blank_checkbox()
elseif line =~ s:rx_list_item()
let res = substitute(m, '\s*$', ' ', '')
elseif &autoindent || &smartindent
@ -367,3 +378,178 @@ function! vimwiki#lst#kbd_oO(cmd) "{{{
endfunction "}}}
function! vimwiki#lst#default_symbol() "{{{
" TODO: initialize default symbol from syntax/vimwiki_xxx.vim
if VimwikiGet('syntax') == 'default'
return '-'
else
return '*'
endif
endfunction "}}}
function vimwiki#lst#get_list_margin() "{{{
if VimwikiGet('list_margin') < 0
return &sw
else
return VimwikiGet('list_margin')
endif
endfunction "}}}
function s:get_list_sw() "{{{
if VimwikiGet('syntax') == 'media'
return 1
else
return &sw
endif
endfunction "}}}
function s:get_list_nesting_level(lnum) "{{{
if VimwikiGet('syntax') == 'media'
if getline(a:lnum) !~ s:rx_list_item()
let level = 0
else
let level = vimwiki#u#count_first_sym(getline(a:lnum)) - 1
let level = level < 0 ? 0 : level
endif
else
let level = indent(a:lnum)
endif
return level
endfunction "}}}
function s:get_list_indent(lnum) "{{{
if VimwikiGet('syntax') == 'media'
return indent(a:lnum)
else
return 0
endif
endfunction "}}}
function! s:compose_list_item(n_indent, n_nesting, sym_nest, sym_bullet, li_content, ...) "{{{
if a:0
let sep = a:1
else
let sep = ''
endif
let li_indent = repeat(' ', max([0,a:n_indent])).sep
let li_nesting = repeat(a:sym_nest, max([0,a:n_nesting])).sep
if len(a:sym_bullet) > 0
let li_bullet = a:sym_bullet.' '.sep
else
let li_bullet = ''.sep
endif
return li_indent.li_nesting.li_bullet.a:li_content
endfunction "}}}
function s:compose_cb_bullet(prev_cb_bullet, sym) "{{{
return a:sym.matchstr(a:prev_cb_bullet, '\S*\zs\s\+.*')
endfunction "}}}
function! vimwiki#lst#change_level(...) "{{{
let default_sym = vimwiki#lst#default_symbol()
let cmd = '>>'
let sym = default_sym
" parse argument
if a:0
if a:1 != '<<' && a:1 != '>>'
let cmd = '--'
let sym = a:1
else
let cmd = a:1
endif
endif
" is symbol valid
if sym.' ' !~ s:rx_cb_list_item() && sym.' ' !~ s:rx_list_item()
return
endif
" parsing setup
let lnum = line('.')
let line = getline('.')
let list_margin = vimwiki#lst#get_list_margin()
let list_sw = s:get_list_sw()
let n_nesting = s:get_list_nesting_level(lnum)
let n_indent = s:get_list_indent(lnum)
" remove indent and nesting
let li_bullet_and_content = strpart(line, n_nesting + n_indent)
" list bullet and checkbox
let cb_bullet = matchstr(li_bullet_and_content, s:rx_list_item()).
\ matchstr(li_bullet_and_content, s:rx_cb_list_item())
" XXX: it could be not unicode proof --> if checkboxes are set up with unicode syms
" content
let li_content = strpart(li_bullet_and_content, len(cb_bullet))
" trim
let cb_bullet = vimwiki#u#trim(cb_bullet)
let li_content = vimwiki#u#trim(li_content)
" nesting symbol
if VimwikiGet('syntax') == 'media'
if len(cb_bullet) > 0
let sym_nest = cb_bullet[0]
else
let sym_nest = sym
endif
else
let sym_nest = ' '
endif
if g:vimwiki_debug
echomsg "PARSE: Sw [".list_sw."]"
echomsg s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content, '|')
endif
" change level
if cmd == '--'
let cb_bullet = s:compose_cb_bullet(cb_bullet, sym)
if VimwikiGet('syntax') == 'media'
let sym_nest = sym
endif
elseif cmd == '>>'
if cb_bullet == ''
let cb_bullet = sym
else
let n_nesting = n_nesting + list_sw
endif
elseif cmd == '<<'
let n_nesting = n_nesting - list_sw
if VimwikiGet('syntax') == 'media'
if n_nesting < 0
let cb_bullet = ''
endif
else
if n_nesting < list_margin
let cb_bullet = ''
endif
endif
endif
let n_nesting = max([0, n_nesting])
if g:vimwiki_debug
echomsg "SHIFT:"
echomsg s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content, '|')
endif
" XXX: this is the code that adds the initial indent
let add_nesting = VimwikiGet('syntax') != 'media'
if n_indent + n_nesting*(add_nesting) < list_margin
let n_indent = list_margin - n_nesting*(add_nesting)
endif
if g:vimwiki_debug
echomsg "INDENT:"
echomsg s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content, '|')
endif
let line = s:compose_list_item(n_indent, n_nesting, sym_nest, cb_bullet, li_content)
" replace
call setline(lnum, line)
call cursor(lnum, match(line, '\S') + 1)
endfunction "}}}

View File

@ -0,0 +1,111 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
" Desc: Link functions for markdown syntax
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
function! s:normalize_link_syntax_n() " {{{
let lnum = line('.')
" try WikiIncl
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
if !empty(lnk)
" NO-OP !!
if g:vimwiki_debug > 1
echomsg "WikiIncl: ".lnk." Sub: ".lnk
endif
return
endif
" try WikiLink0: replace with WikiLink1
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink0)
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
\ g:vimwiki_WikiLink1Template2)
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink0, sub)
if g:vimwiki_debug > 1
echomsg "WikiLink: ".lnk." Sub: ".sub
endif
return
endif
" try WikiLink1: replace with WikiLink0
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink1)
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
\ g:vimwiki_WikiLinkTemplate2)
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink1, sub)
if g:vimwiki_debug > 1
echomsg "WikiLink: ".lnk." Sub: ".sub
endif
return
endif
" try Weblink
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink)
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWeblinkMatchUrl, g:vimwiki_rxWeblinkMatchDescr,
\ g:vimwiki_Weblink1Template)
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWeblink, sub)
if g:vimwiki_debug > 1
echomsg "WebLink: ".lnk." Sub: ".sub
endif
return
endif
" try Word (any characters except separators)
" rxWord is less permissive than rxWikiLinkUrl which is used in
" normalize_link_syntax_v
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWord)
if !empty(lnk)
let sub = vimwiki#base#normalize_link_helper(lnk,
\ g:vimwiki_rxWord, '',
\ g:vimwiki_WikiLinkTemplate1)
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
if g:vimwiki_debug > 1
echomsg "Word: ".lnk." Sub: ".sub
endif
return
endif
endfunction " }}}
function! s:normalize_link_syntax_v() " {{{
let lnum = line('.')
let sel_save = &selection
let &selection = "old"
let rv = @"
let rt = getregtype('"')
let done = 0
try
norm! gvy
let visual_selection = @"
let visual_selection = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', '\='."'".visual_selection."'", '')
call setreg('"', visual_selection, 'v')
" paste result
norm! `>pgvd
finally
call setreg('"', rv, rt)
let &selection = sel_save
endtry
endfunction " }}}
" normalize_link
function! vimwiki#markdown_base#normalize_link(is_visual_mode) "{{{
if !a:is_visual_mode
call s:normalize_link_syntax_n()
elseif visualmode() ==# 'v' && line("'<") == line("'>")
" action undefined for 'line-wise' or 'multi-line' visual mode selections
call s:normalize_link_syntax_v()
endif
endfunction "}}}

View File

@ -24,16 +24,56 @@ del {text-decoration: line-through; color: #777777;}
.justright {text-align: right;}
.justcenter {text-align: center;}
.center {margin-left: auto; margin-right: auto;}
/* classes for items of todo lists */
.done0:before {content: "\2592\2592\2592\2592"; color: SkyBlue;}
.done1:before {content: "\2588\2592\2592\2592"; color: SkyBlue;}
.done2:before {content: "\2588\2588\2592\2592"; color: SkyBlue;}
.done3:before {content: "\2588\2588\2588\2592"; color: SkyBlue;}
.done4:before {content: "\2588\2588\2588\2588"; color: SkyBlue;}
/* comment the next four or five lines out *
* if you do not want color-coded todo lists */
.done0 {color: #c00000;}
.done1 {color: #c08000;}
.done2 {color: #80a000;}
.done3 {color: #00c000;}
.done4 {color: #7f7f7f; text-decoration: line-through;}
.done0 {
/* list-style: none; */
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAA7SURBVCiR7dMxEgAgCANBI3yVRzF5KxNbW6wsuH7LQ2YKQK1mkswBVERYF5Os3UV3gwd/jF2SkXy66gAZkxS6BniubAAAAABJRU5ErkJggg==);
background-repeat: no-repeat;
background-position: 0 .2em;
margin-left: -2em;
padding-left: 1.5em;
}
.done1 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABtSURBVCiR1ZO7DYAwDER9BDmTeZQMFXmUbGYpOjrEryA0wOvO8itOslFrJYAug5BMM4BeSkmjsrv3aVTa8p48Xw1JSkSsWVUFwD05IqS1tmYzk5zzae9jnVVVzGyXb8sALjse+euRkEzu/uirFomVIdDGOLjuAAAAAElFTkSuQmCC);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}
.done2 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAB1SURBVCiRzdO5DcAgDAVQGxjAYgTvxlDIu1FTIRYAp8qlFISkSH7l5kk+ZIwxKiI2mIyqWoeILYRgZ7GINDOLjnmF3VqklKCUMgTee2DmM661Qs55iI3Zm/1u5h9sm4ig9z4ERHTFzLyd4G4+nFlVrYg8+qoF/c0kdpeMsmcAAAAASUVORK5CYII=);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}
.done3 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAxQAAAMUBHc26qAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABoSURBVCiR7dOxDcAgDATA/0DtUdiKoZC3YhLkHjkVKF3idJHiztKfvrHZWnOSE8Fx95RJzlprimJVnXktvXeY2S0SEZRSAAAbmxnGGKH2I5T+8VfxPhIReQSuuY3XyYWa3T2p6quvOgGrvSFGlewuUAAAAABJRU5ErkJggg==);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}
.done4 {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAQCAYAAAAbBi9cAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAzgAAAM4BlP6ToAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAIISURBVDiNnZQ9SFtRFMd/773kpTaGJoQk1im4VDpWQcTNODhkFBcVTCNCF0NWyeDiIIiCm82QoIMIUkHUxcFBg1SEQoZszSat6cdTn1qNue92CMbEr9Sey+XC/Z/zu+f8h6ukUil3sVg0+M+4cFxk42/jH2wAqqqKSCSiPQdwcHHAnDHH9s/tN1h8V28ETdP+eU8fT9Nt62ancYdIPvJNtsu87bmjrJlrTDVM4RROJs1JrHPrD4Bar7A6cpc54iKOaTdJXCUI2UMVrQZ0Js7YPN18ECKkYNQcJe/OE/4dZsw7VqNXQMvHy3QZXQypQ6ycrtwDjf8aJ+PNEDSCzLpn7+m2pD8ZKHlKarYhy6XjEoCYGcN95qansQeA3fNdki+SaJZGTMQIOoL3W/Z89rxv+tokubNajlvk/vm+LFpF2XnUKZHI0I+QrI7Dw0OZTqdzUkpsM7mZTyfy5OPGyw1tK7AFSvmB/Ks8w8YwbUYbe6/3QEKv0vugfxWPnMLJun+d/kI/WLdizpNjMbAIKrhMF4OuwadBALqqs+RfInwUvuNi+fBd+wjogfogAFVRmffO02q01mZZ0HHdgXIzdz0QQLPezIQygX6llxNKKgOFARYCC49CqhoHIUTlss/Vx2phlYwjw8j1CAlfAiwQiJpiy7o1VHnsG5FISkoJu7Q/2YmmaV+i0ei7v38L2CBguSi5AAAAAElFTkSuQmCC);
background-repeat: no-repeat;
background-position: 0 .15em;
margin-left: -2em;
padding-left: 1.5em;
}
code {
font-family: Monaco,"Courier New","DejaVu Sans Mono","Bitstream Vera Sans Mono",monospace;
-webkit-border-radius: 1px;
-moz-border-radius: 1px;
border-radius: 1px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
padding: 0px 3px;
display: inline-block;
color: #52595d;
border: 1px solid #ccc;
background-color: #f9f9f9;
}

View File

@ -2,7 +2,7 @@
" Vimwiki autoload plugin file
" Desc: Tables
" | Easily | manageable | text | tables | ! |
" |--------+------------+-------+--------+---------|
" |--------|------------|-------|--------|---------|
" | Have | fun! | Drink | tea | Period. |
"
" Author: Maxim Kim <habamax@gmail.com>
@ -16,6 +16,8 @@ let g:loaded_vimwiki_tbl_auto = 1
"}}}
let s:textwidth = &tw
let s:rxSep = g:vimwiki_rxTableSep
" Misc functions {{{
function! s:wide_len(str) "{{{
@ -40,21 +42,37 @@ function! s:wide_len(str) "{{{
return ret
endfunction "}}}
function! s:cell_splitter() "{{{
return '\s*'.s:rxSep.'\s*'
endfunction "}}}
function! s:sep_splitter() "{{{
return '-'.s:rxSep.'-'
endfunction "}}}
function! s:is_table(line) "{{{
return a:line =~ '^\s*\%(|[^|]\+\)\+|\s*$' || s:is_separator(a:line)
return s:is_separator(a:line) || (a:line !~ s:rxSep.s:rxSep && a:line =~ '^\s*'.s:rxSep.'.\+'.s:rxSep.'\s*$')
endfunction "}}}
function! s:is_separator(line) "{{{
return a:line =~ '^\s*[|+]\s*--[-|+]\+'
return a:line =~ '^\s*'.s:rxSep.'\(--\+'.s:rxSep.'\)\+\s*$'
endfunction "}}}
function! s:is_separator_tail(line) "{{{
return a:line =~ '^\{-1}\%(\s*\|-*\)\%('.s:rxSep.'-\+\)\+'.s:rxSep.'\s*$'
endfunction "}}}
function! s:is_last_column(lnum, cnum) "{{{
return strpart(getline(a:lnum), a:cnum - 1) =~ '^[^|]*|\s*$'
let line = strpart(getline(a:lnum), a:cnum - 1)
"echomsg "DEBUG is_last_column> ".(line =~ s:rxSep.'\s*$' && line !~ s:rxSep.'.*'.s:rxSep.'\s*$')
return line =~ s:rxSep.'\s*$' && line !~ s:rxSep.'.*'.s:rxSep.'\s*$'
endfunction "}}}
function! s:is_first_column(lnum, cnum) "{{{
let line = strpart(getline(a:lnum), 0, a:cnum - 1)
return line =~ '^\s*|[^|]*$' || line =~ '^\s*$'
"echomsg "DEBUG is_first_column> ".(line =~ '^\s*'.s:rxSep && line !~ '^\s*'.s:rxSep.'.*'.s:rxSep)
return line =~ '^\s*$' || (line =~ '^\s*'.s:rxSep && line !~ '^\s*'.s:rxSep.'.*'.s:rxSep)
endfunction "}}}
function! s:count_separators_up(lnum) "{{{
@ -82,11 +100,10 @@ function! s:count_separators_down(lnum) "{{{
endfunction "}}}
function! s:create_empty_row(cols) "{{{
let first_cell = "| |"
let cell = " |"
let row = first_cell
let row = s:rxSep
let cell = " ".s:rxSep
for c in range(a:cols - 1)
for c in range(a:cols)
let row .= cell
endfor
@ -94,36 +111,71 @@ function! s:create_empty_row(cols) "{{{
endfunction "}}}
function! s:create_row_sep(cols) "{{{
let first_cell = "|---+"
let cell = "---+"
let last_cell = "---|"
let row = s:rxSep
let cell = "---".s:rxSep
if a:cols < 2
return "|---|"
endif
let row = first_cell
for c in range(a:cols - 2)
for c in range(a:cols)
let row .= cell
endfor
let row .= last_cell
return row
endfunction "}}}
function! s:get_values(line) "{{{
return split(a:line, '\s*|\s*', 1)[1:-2]
function! vimwiki#tbl#get_cells(line) "{{{
let result = []
let cell = ''
let quote = ''
let state = 'NONE'
" 'Simple' FSM
for idx in range(strlen(a:line))
" The only way I know Vim can do Unicode...
let ch = a:line[idx]
if state == 'NONE'
if ch == '|'
let state = 'CELL'
endif
elseif state == 'CELL'
if ch == '[' || ch == '{'
let state = 'BEFORE_QUOTE_START'
let quote = ch
elseif ch == '|'
call add(result, vimwiki#u#trim(cell))
let cell = ""
else
let cell .= ch
endif
elseif state == 'BEFORE_QUOTE_START'
if ch == '[' || ch == '{'
let state = 'QUOTE'
let quote .= ch
else
let state = 'CELL'
let cell .= quote.ch
let quote = ''
endif
elseif state == 'QUOTE'
if ch == ']' || ch == '}'
let state = 'BEFORE_QUOTE_END'
endif
let quote .= ch
elseif state == 'BEFORE_QUOTE_END'
if ch == ']' || ch == '}'
let state = 'CELL'
endif
let cell .= quote.ch
let quote = ''
endif
endfor
if cell.quote != ''
call add(result, vimwiki#u#trim(cell.quote, '|'))
endif
return result
endfunction "}}}
function! s:col_count(lnum) "{{{
let line = getline(a:lnum)
if !s:is_separator(line)
return len(split(line, '\s*|\s*', 1)[1:-2])
else
return len(split(line, '-+-', 1))
endif
return len(vimwiki#tbl#get_cells(getline(a:lnum)))
endfunction "}}}
function! s:get_indent(lnum) "{{{
@ -155,7 +207,7 @@ function! s:get_rows(lnum) "{{{
let lower_rows = []
let lnum = a:lnum - 1
while lnum > 1
while lnum >= 1
let line = getline(lnum)
if s:is_table(line)
call add(upper_rows, [lnum, line])
@ -186,7 +238,7 @@ function! s:get_cell_max_lens(lnum) "{{{
if s:is_separator(row)
continue
endif
let cells = s:get_values(row)
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let value = cells[idx]
if has_key(max_lens, idx)
@ -219,17 +271,13 @@ function! s:cur_column() "{{{
if !s:is_table(line)
return -1
endif
if s:is_separator(line)
let sep = '[+|]'
else
let sep = '|'
endif
" TODO: do we need conditional: if s:is_separator(line)
let curs_pos = col('.')
let mpos = match(line, '|', 0)
let mpos = match(line, s:rxSep, 0)
let col = -1
while mpos < curs_pos && mpos != -1
let mpos = match(line, sep, mpos+1)
let mpos = match(line, s:rxSep, mpos+1)
if mpos != -1
let col += 1
endif
@ -253,8 +301,8 @@ function! s:fmt_cell(cell, max_len) "{{{
endfunction "}}}
function! s:fmt_row(line, max_lens, col1, col2) "{{{
let new_line = '|'
let cells = s:get_values(a:line)
let new_line = s:rxSep
let cells = vimwiki#tbl#get_cells(a:line)
for idx in range(len(cells))
if idx == a:col1
let idx = a:col2
@ -262,12 +310,12 @@ function! s:fmt_row(line, max_lens, col1, col2) "{{{
let idx = a:col1
endif
let value = cells[idx]
let new_line .= s:fmt_cell(value, a:max_lens[idx]).'|'
let new_line .= s:fmt_cell(value, a:max_lens[idx]).s:rxSep
endfor
let idx = len(cells)
while idx < len(a:max_lens)
let new_line .= s:fmt_cell('', a:max_lens[idx]).'|'
let new_line .= s:fmt_cell('', a:max_lens[idx]).s:rxSep
let idx += 1
endwhile
return new_line
@ -282,17 +330,16 @@ function! s:fmt_cell_sep(max_len) "{{{
endfunction "}}}
function! s:fmt_sep(max_lens, col1, col2) "{{{
let sep = '|'
let new_line = s:rxSep
for idx in range(len(a:max_lens))
if idx == a:col1
let idx = a:col2
elseif idx == a:col2
let idx = a:col1
endif
let sep .= s:fmt_cell_sep(a:max_lens[idx]).'+'
let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep
endfor
let sep = substitute(sep, '+$', '|', '')
return sep
return new_line
endfunction "}}}
"}}}
@ -300,41 +347,94 @@ endfunction "}}}
function! s:kbd_create_new_row(cols, goto_first) "{{{
let cmd = "\<ESC>o".s:create_empty_row(a:cols)
let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'))\<CR>"
let cmd .= "\<ESC>0"
if a:goto_first
let cmd .= "\<ESC>0:call search('|', 'c', line('.'))\<CR>la"
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'c', line('.'))\<CR>"
else
let cmd .= "0".(col('.')-1)."lT|a"
let cmd .= (col('.')-1)."l"
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>"
endif
let cmd .= "a"
return cmd
endfunction "}}}
function! s:kbd_goto_next_row() "{{{
let cmd = "\<ESC>jt|T|a"
let cmd = "\<ESC>j"
let cmd .= ":call search('.\\(".s:rxSep."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a"
return cmd
endfunction "}}}
function! s:kbd_goto_prev_row() "{{{
let cmd = "\<ESC>jt|T|a"
let cmd = "\<ESC>k"
let cmd .= ":call search('.\\(".s:rxSep."\\)', 'c', line('.'))\<CR>"
let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'bc', line('.'))\<CR>"
let cmd .= "a"
return cmd
endfunction "}}}
function! s:kbd_goto_next_col(last) "{{{
if a:last
" Used in s:kbd_goto_next_col
function! vimwiki#tbl#goto_next_col() "{{{
let curcol = virtcol('.')
let lnum = line('.')
let newcol = s:get_indent(lnum)
let max_lens = s:get_cell_max_lens(lnum)
for cell_len in values(max_lens)
if newcol >= curcol-1
break
endif
let newcol += cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space>
endfor
let newcol += 2 " +2 == 1 separator + 1 space |<space
call vimwiki#u#cursor(lnum, newcol)
endfunction "}}}
function! s:kbd_goto_next_col(jumpdown) "{{{
let cmd = "\<ESC>"
if a:jumpdown
let seps = s:count_separators_down(line('.'))
let cmd = "\<ESC>".seps."j0:call search('|', 'c', line('.'))\<CR>la"
else
let cmd = "\<ESC>:call search('|', 'c', line('.'))\<CR>la"
let cmd .= seps."j0"
endif
let cmd .= ":call vimwiki#tbl#goto_next_col()\<CR>a"
return cmd
endfunction "}}}
function! s:kbd_goto_prev_col(first) "{{{
if a:first
" Used in s:kbd_goto_prev_col
function! vimwiki#tbl#goto_prev_col() "{{{
let curcol = virtcol('.')
let lnum = line('.')
let newcol = s:get_indent(lnum)
let max_lens = s:get_cell_max_lens(lnum)
let prev_cell_len = 0
echom string(max_lens)
for cell_len in values(max_lens)
let delta = cell_len + 3 " +3 == 2 spaces + 1 separator |<space>...<space>
if newcol + delta > curcol-1
let newcol -= (prev_cell_len + 3) " +3 == 2 spaces + 1 separator |<space>...<space>
break
elseif newcol + delta == curcol-1
break
endif
let prev_cell_len = cell_len
let newcol += delta
endfor
let newcol += 2 " +2 == 1 separator + 1 space |<space
call vimwiki#u#cursor(lnum, newcol)
endfunction "}}}
function! s:kbd_goto_prev_col(jumpup) "{{{
let cmd = "\<ESC>"
if a:jumpup
let seps = s:count_separators_up(line('.'))
let cmd = "\<ESC>".seps."k$:call search('|', 'b', line('.'))\<CR>la"
else
let cmd = "\<ESC>2F|la"
let cmd .= seps."k"
let cmd .= "$"
endif
let cmd .= ":call vimwiki#tbl#goto_prev_col()\<CR>a"
" let cmd .= ":call search('\\(".s:rxSep."\\)\\zs', 'b', line('.'))\<CR>"
" let cmd .= "a"
"echomsg "DEBUG kbd_goto_prev_col> ".cmd
return cmd
endfunction "}}}
@ -348,7 +448,7 @@ function! vimwiki#tbl#kbd_cr() "{{{
endif
if s:is_separator(getline(lnum+1)) || !s:is_table(getline(lnum+1))
let cols = len(s:get_values(getline(lnum)))
let cols = len(vimwiki#tbl#get_cells(getline(lnum)))
return s:kbd_create_new_row(cols, 0)
else
return s:kbd_goto_next_row()
@ -362,11 +462,13 @@ function! vimwiki#tbl#kbd_tab() "{{{
endif
let last = s:is_last_column(lnum, col('.'))
if last && !s:is_table(getline(lnum+1))
let cols = len(s:get_values(getline(lnum)))
let is_sep = s:is_separator_tail(getline(lnum))
"echomsg "DEBUG kbd_tab> last=".last.", is_sep=".is_sep
if (is_sep || last) && !s:is_table(getline(lnum+1))
let cols = len(vimwiki#tbl#get_cells(getline(lnum)))
return s:kbd_create_new_row(cols, 1)
endif
return s:kbd_goto_next_col(last)
return s:kbd_goto_next_col(is_sep || last)
endfunction "}}}
function! vimwiki#tbl#kbd_shift_tab() "{{{
@ -376,10 +478,12 @@ function! vimwiki#tbl#kbd_shift_tab() "{{{
endif
let first = s:is_first_column(lnum, col('.'))
if first && !s:is_table(getline(lnum-1))
let is_sep = s:is_separator_tail(getline(lnum))
"echomsg "DEBUG kbd_tab> ".first
if (is_sep || first) && !s:is_table(getline(lnum-1))
return ""
endif
return s:kbd_goto_prev_col(first)
return s:kbd_goto_prev_col(is_sep || first)
endfunction "}}}
function! vimwiki#tbl#format(lnum, ...) "{{{
@ -462,7 +566,12 @@ endfunction "}}}
" TODO: move_column_left and move_column_right are good candidates to be
" refactored.
function! vimwiki#tbl#move_column_left() "{{{
if !s:is_table(getline('.'))
"echomsg "DEBUG move_column_left: "
let line = getline('.')
if !s:is_table(line)
return
endif
@ -474,16 +583,28 @@ function! vimwiki#tbl#move_column_left() "{{{
if cur_col > 0
call vimwiki#tbl#format(line('.'), cur_col-1, cur_col)
call cursor(line('.'), 1)
if !s:is_separator(getline('.'))
call search('\%(|[^|]\+\)\{'.(cur_col-1).'}| .', 'eW')
else
call search('|\%([^+]\++\)\{'.(cur_col-1).'}--', 'eW')
endif
let sep = '\('.s:rxSep.'\).\zs'
let mpos = -1
let col = -1
while col < cur_col-1
let mpos = match(line, sep, mpos+1)
if mpos != -1
let col += 1
else
break
endif
endwhile
endif
endfunction "}}}
function! vimwiki#tbl#move_column_right() "{{{
if !s:is_table(getline('.'))
let line = getline('.')
if !s:is_table(line)
return
endif
@ -495,16 +616,41 @@ function! vimwiki#tbl#move_column_right() "{{{
if cur_col < s:col_count(line('.'))-1
call vimwiki#tbl#format(line('.'), cur_col, cur_col+1)
call cursor(line('.'), 1)
if !s:is_separator(getline('.'))
call search('\%(|[^|]\+\)\{'.(cur_col+1).'}| .', 'eW')
else
call search('|\%([^+]\++\)\{'.(cur_col+1).'}--', 'eW')
endif
let sep = '\('.s:rxSep.'\).\zs'
let mpos = -1
let col = -1
while col < cur_col+1
let mpos = match(line, sep, mpos+1)
if mpos != -1
let col += 1
else
break
endif
endwhile
endif
endfunction "}}}
function! vimwiki#tbl#get_rows(lnum) "{{{
return s:get_rows(a:lnum)
endfunction "}}}
function! vimwiki#tbl#is_table(line) "{{{
return s:is_table(a:line)
endfunction "}}}
function! vimwiki#tbl#is_separator(line) "{{{
return s:is_separator(a:line)
endfunction "}}}
function! vimwiki#tbl#cell_splitter() "{{{
return s:cell_splitter()
endfunction "}}}
function! vimwiki#tbl#sep_splitter() "{{{
return s:sep_splitter()
endfunction "}}}
"}}}

77
autoload/vimwiki/u.vim Normal file
View File

@ -0,0 +1,77 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki autoload plugin file
" Utility functions
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
function! vimwiki#u#trim(string, ...) "{{{
let chars = ''
if a:0 > 0
let chars = a:1
endif
let res = substitute(a:string, '^[[:space:]'.chars.']\+', '', '')
let res = substitute(res, '[[:space:]'.chars.']\+$', '', '')
return res
endfunction "}}}
" Builtin cursor doesn't work right with unicode characters.
function! vimwiki#u#cursor(lnum, cnum) "{{{
exe a:lnum
exe 'normal! 0'.a:cnum.'|'
endfunction "}}}
function! vimwiki#u#is_windows() "{{{
return has("win32") || has("win64") || has("win95") || has("win16")
endfunction "}}}
function! vimwiki#u#chomp_slash(str) "{{{
return substitute(a:str, '[/\\]\+$', '', '')
endfunction "}}}
function! vimwiki#u#time(starttime) "{{{
" measure the elapsed time and cut away miliseconds and smaller
return matchstr(reltimestr(reltime(a:starttime)),'\d\+\(\.\d\d\)\=')
endfunction "}}}
function! vimwiki#u#path_norm(path) "{{{
" /-slashes
let path = substitute(a:path, '\', '/', 'g')
" treat multiple consecutive slashes as one path separator
let path = substitute(path, '/\+', '/', 'g')
" ensure that we are not fooled by a symbolic link
return resolve(path)
endfunction "}}}
function! vimwiki#u#is_link_to_dir(link) "{{{
" Check if link is to a directory.
" It should be ended with \ or /.
if a:link =~ '.\+[/\\]$'
return 1
endif
return 0
endfunction " }}}
function! vimwiki#u#count_first_sym(line) "{{{
let first_sym = matchstr(a:line, '\S')
return len(matchstr(a:line, first_sym.'\+'))
endfunction "}}}
" return longest common path prefix of 2 given paths.
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
function! vimwiki#u#path_common_pfx(path1, path2) "{{{
let p1 = split(a:path1, '[/\\]', 1)
let p2 = split(a:path2, '[/\\]', 1)
let idx = 0
let minlen = min([len(p1), len(p2)])
while (idx < minlen) && (p1[idx] ==? p2[idx])
let idx = idx + 1
endwhile
if idx == 0
return ''
else
return join(p1[: idx-1], '/')
endif
endfunction "}}}

File diff suppressed because it is too large Load Diff

View File

@ -35,13 +35,17 @@ setlocal isfname-=[,]
" Autocreate list items {{{
" for list items, and list items with checkboxes
setlocal formatoptions+=tnro
setlocal formatoptions-=cq
if VimwikiGet('syntax') == 'default'
setl comments=b:*,b:#,b:-
setl formatlistpat=^\\s*[*#-]\\s*
elseif VimwikiGet('syntax') == 'markdown'
setlocal comments=fb:*,fb:-,fb:+,nb:> commentstring=\ >\ %s
setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+j
else
setl comments=n:*,n:#
endif
setlocal formatoptions=tnro
if !empty(&langmap)
" Valid only if langmap is a comma separated pairs of chars
@ -64,23 +68,15 @@ function! VimwikiFoldLevel(lnum) "{{{
" Header folding...
if line =~ g:vimwiki_rxHeader
let n = vimwiki#base#count_first_sym(line)
let n = vimwiki#u#count_first_sym(line)
return '>'.n
endif
if g:vimwiki_fold_trailing_empty_lines == 0 && line =~ '^\s*$'
let nnline = getline(nextnonblank(a:lnum + 1))
else
let nnline = getline(a:lnum + 1)
endif
if nnline =~ g:vimwiki_rxHeader
let n = vimwiki#base#count_first_sym(nnline)
return '<'.n
endif
let base_level = s:get_base_level(a:lnum)
" List item folding...
if g:vimwiki_fold_lists
let base_level = s:get_base_level(a:lnum)
let nnline = getline(a:lnum + 1)
let rx_list_item = '\('.
\ g:vimwiki_rxListBullet.'\|'.g:vimwiki_rxListNumber.
@ -95,6 +91,10 @@ function! VimwikiFoldLevel(lnum) "{{{
if leveln > level
return ">".(base_level+leveln-adj)
" check if multilined list item
elseif (nnum-a:lnum) > 1
\ && nline =~ rx_list_item && nnline !~ '^\s*$'
return ">".(base_level+level+1-adj)
else
return (base_level+level-adj)
endif
@ -102,34 +102,23 @@ function! VimwikiFoldLevel(lnum) "{{{
" process multilined list items
let [pnum, pline] = s:find_backward(rx_list_item, a:lnum)
if pline =~ rx_list_item
if indent(a:lnum) > indent(pnum)
if indent(a:lnum) >= indent(pnum) && line !~ '^\s*$'
let level = s:get_li_level(pnum)
let adj = s:get_li_level(s:get_start_list(rx_list_item, pnum))
let [nnum, nline] = s:find_forward(rx_list_item, a:lnum)
if nline =~ rx_list_item
let leveln = s:get_li_level(nnum)
if leveln > level
return (base_level+leveln-adj)
endif
endif
return (base_level+level-adj)
return (base_level+level+1-adj)
endif
endif
endif
return base_level
endif
return -1
return base_level
endfunction "}}}
function! s:get_base_level(lnum) "{{{
let lnum = a:lnum - 1
while lnum > 0
if getline(lnum) =~ g:vimwiki_rxHeader
return vimwiki#base#count_first_sym(getline(lnum))
return vimwiki#u#count_first_sym(getline(lnum))
endif
let lnum -= 1
endwhile
@ -169,7 +158,7 @@ endfunction "}}}
function! s:get_li_level(lnum) "{{{
if VimwikiGet('syntax') == 'media'
let level = vimwiki#base#count_first_sym(getline(a:lnum))
let level = vimwiki#u#count_first_sym(getline(a:lnum))
else
let level = (indent(a:lnum) / &sw)
endif
@ -198,12 +187,16 @@ endfunction "}}}
" COMMANDS {{{
command! -buffer Vimwiki2HTML
\ w <bar> call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ silent w <bar>
\ let res = vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ expand('%'))
\<bar>
\ if res != '' | echo 'Vimwiki: HTML conversion is done.' | endif
command! -buffer Vimwiki2HTMLBrowse
\ w <bar> call VimwikiWeblinkHandler(
\ vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ expand('%')))
\ silent w <bar>
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
\ expand(VimwikiGet('path_html')),
\ expand('%')))
command! -buffer VimwikiAll2HTML
\ call vimwiki#html#WikiAll2HTML(expand(VimwikiGet('path_html')))
@ -216,12 +209,17 @@ command! -buffer VimwikiGoBackLink call vimwiki#base#go_back_link()
command! -buffer VimwikiSplitLink call vimwiki#base#follow_link('split')
command! -buffer VimwikiVSplitLink call vimwiki#base#follow_link('vsplit')
command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link(<f-args>)
command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tabnew')
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#ToggleListItem(<line1>, <line2>)
command! -buffer VimwikiGenerateLinks call vimwiki#base#generate_links()
command! -buffer -nargs=0 VimwikiBacklinks call vimwiki#base#backlinks()
command! -buffer -nargs=0 VWB call vimwiki#base#backlinks()
exe 'command! -buffer -nargs=* VimwikiSearch lvimgrep <args> '.
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
@ -230,6 +228,10 @@ exe 'command! -buffer -nargs=* VWS lvimgrep <args> '.
command! -buffer -nargs=1 VimwikiGoto call vimwiki#base#goto("<args>")
" list commands
command! -buffer -nargs=* VimwikiListChangeLevel call vimwiki#lst#change_level(<f-args>)
" table commands
command! -buffer -nargs=* VimwikiTable call vimwiki#tbl#create(<f-args>)
command! -buffer VimwikiTableAlignQ call vimwiki#tbl#align_or_cmd('gqq')
@ -247,7 +249,7 @@ command! -buffer VimwikiDiaryPrevDay call vimwiki#diary#goto_prev_day()
if g:vimwiki_use_mouse
nmap <buffer> <S-LeftMouse> <NOP>
nmap <buffer> <C-LeftMouse> <NOP>
nnoremap <silent><buffer> <2-LeftMouse> :VimwikiFollowLink<CR>
nnoremap <silent><buffer> <2-LeftMouse> :call vimwiki#base#follow_link("nosplit", "\<lt>2-LeftMouse>")<CR>
nnoremap <silent><buffer> <S-2-LeftMouse> <LeftMouse>:VimwikiSplitLink<CR>
nnoremap <silent><buffer> <C-2-LeftMouse> <LeftMouse>:VimwikiVSplitLink<CR>
nnoremap <silent><buffer> <RightMouse><LeftMouse> :VimwikiGoBackLink<CR>
@ -284,6 +286,24 @@ endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiVSplitLink :VimwikiVSplitLink<CR>
if !hasmapto('<Plug>VimwikiNormalizeLink')
nmap <silent><buffer> + <Plug>VimwikiNormalizeLink
endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiNormalizeLink :VimwikiNormalizeLink 0<CR>
if !hasmapto('<Plug>VimwikiNormalizeLinkVisual')
vmap <silent><buffer> + <Plug>VimwikiNormalizeLinkVisual
endif
vnoremap <silent><script><buffer>
\ <Plug>VimwikiNormalizeLinkVisual :<C-U>VimwikiNormalizeLink 1<CR>
if !hasmapto('<Plug>VimwikiNormalizeLinkVisualCR')
vmap <silent><buffer> <CR> <Plug>VimwikiNormalizeLinkVisualCR
endif
vnoremap <silent><script><buffer>
\ <Plug>VimwikiNormalizeLinkVisualCR :<C-U>VimwikiNormalizeLink 1<CR>
if !hasmapto('<Plug>VimwikiTabnewLink')
nmap <silent><buffer> <D-CR> <Plug>VimwikiTabnewLink
nmap <silent><buffer> <C-S-CR> <Plug>VimwikiTabnewLink
@ -345,7 +365,7 @@ nnoremap <silent><script><buffer>
function! s:CR() "{{{
let res = vimwiki#lst#kbd_cr()
if res == "\<CR>" && g:vimwiki_table_auto_fmt
if res == "\<CR>" && g:vimwiki_table_mappings
let res = vimwiki#tbl#kbd_cr()
endif
return res
@ -357,9 +377,25 @@ inoremap <buffer> <expr> <CR> <SID>CR()
" List mappings
nnoremap <buffer> o :<C-U>call vimwiki#lst#kbd_oO('o')<CR>
nnoremap <buffer> O :<C-U>call vimwiki#lst#kbd_oO('O')<CR>
nnoremap <buffer> gll :VimwikiListChangeLevel <<<CR>
nnoremap <buffer> glm :VimwikiListChangeLevel >><CR>
nnoremap <buffer> gl* :VimwikiListChangeLevel *<CR>
nnoremap <buffer> gl8 :VimwikiListChangeLevel *<CR>
if VimwikiGet('syntax') == 'default'
nnoremap <buffer> gl- :VimwikiListChangeLevel -<CR>
nnoremap <buffer> gl# :VimwikiListChangeLevel #<CR>
nnoremap <buffer> gl3 :VimwikiListChangeLevel #<CR>
elseif VimwikiGet('syntax') == 'markdown'
nnoremap <buffer> gl- :VimwikiListChangeLevel -<CR>
nnoremap <buffer> gl1 :VimwikiListChangeLevel 1.<CR>
elseif VimwikiGet('syntax') == 'media'
nnoremap <buffer> gl# :VimwikiListChangeLevel #<CR>
nnoremap <buffer> gl3 :VimwikiListChangeLevel #<CR>
endif
" Table mappings
if g:vimwiki_table_auto_fmt
if g:vimwiki_table_mappings
inoremap <expr> <buffer> <Tab> vimwiki#tbl#kbd_tab()
inoremap <expr> <buffer> <S-Tab> vimwiki#tbl#kbd_shift_tab()
endif
@ -377,8 +413,6 @@ endif
nnoremap <silent><script><buffer>
\ <Plug>VimwikiTableMoveColumnRight :VimwikiTableMoveColumnRight<CR>
" Misc mappings
inoremap <buffer> <S-CR> <br /><CR>
" Text objects {{{
@ -400,8 +434,18 @@ vnoremap <silent><buffer> ac :<C-U>call vimwiki#base#TO_table_col(0, 1)<CR>
onoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 0)<CR>
vnoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 1)<CR>
nnoremap <silent><buffer> = :call vimwiki#base#AddHeaderLevel()<CR>
nnoremap <silent><buffer> - :call vimwiki#base#RemoveHeaderLevel()<CR>
if !hasmapto('<Plug>VimwikiAddHeaderLevel')
nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel
endif
nnoremap <silent><buffer> <Plug>VimwikiAddHeaderLevel :
\<C-U>call vimwiki#base#AddHeaderLevel()<CR>
if !hasmapto('<Plug>VimwikiRemoveHeaderLevel')
nmap <silent><buffer> - <Plug>VimwikiRemoveHeaderLevel
endif
nnoremap <silent><buffer> <Plug>VimwikiRemoveHeaderLevel :
\<C-U>call vimwiki#base#RemoveHeaderLevel()<CR>
" }}}
@ -411,8 +455,21 @@ nnoremap <silent><buffer> - :call vimwiki#base#RemoveHeaderLevel()<CR>
if VimwikiGet('auto_export')
" Automatically generate HTML on page write.
augroup vimwiki
au BufWritePost <buffer> Vimwiki2HTML
au BufWritePost <buffer>
\ call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
\ expand('%'))
augroup END
endif
" AUTOCOMMANDS }}}
" PASTE, CAT URL {{{
" html commands
command! -buffer VimwikiPasteUrl call vimwiki#html#PasteUrl(expand('%:p'))
command! -buffer VimwikiCatUrl call vimwiki#html#CatUrl(expand('%:p'))
" }}}
" DEBUGGING {{{
command! VimwikiPrintWikiState call vimwiki#base#print_wiki_state()
command! VimwikiReadLocalOptions call vimwiki#base#read_wiki_options(1)
" }}}

View File

@ -12,6 +12,19 @@ let loaded_vimwiki = 1
let s:old_cpo = &cpo
set cpo&vim
" Logging and performance instrumentation "{{{
let g:VimwikiLog = {}
let g:VimwikiLog.path = 0 " # of calls to VimwikiGet with path or path_html
let g:VimwikiLog.path_html = 0 " # of calls to path_html()
let g:VimwikiLog.normalize_path = 0 " # of calls to normalize_path()
let g:VimwikiLog.subdir = 0 " # of calls to vimwiki#base#subdir()
let g:VimwikiLog.timing = [] " various timing measurements
let g:VimwikiLog.html = [] " html conversion timing
function! VimwikiLog_extend(what,...) "{{{
call extend(g:VimwikiLog[a:what],a:000)
endfunction "}}}
"}}}
" HELPER functions {{{
function! s:default(varname, value) "{{{
if !exists('g:vimwiki_'.a:varname)
@ -19,87 +32,141 @@ function! s:default(varname, value) "{{{
endif
endfunction "}}}
" return longest common path prefix of 2 given paths.
" '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki'
function! s:path_common_pfx(path1, path2) "{{{
let p1 = split(a:path1, '[/\\]', 1)
let p2 = split(a:path2, '[/\\]', 1)
let idx = 0
let minlen = min([len(p1), len(p2)])
while (idx < minlen) && (p1[idx] ==? p2[idx])
let idx = idx + 1
endwhile
if idx == 0
return ''
else
return join(p1[: idx-1], '/')
endif
endfunction "}}}
function! s:find_wiki(path) "{{{
" XXX: find_wiki() does not (yet) take into consideration the ext
let path = vimwiki#u#path_norm(vimwiki#u#chomp_slash(a:path))
let idx = 0
while idx < len(g:vimwiki_list)
let path = vimwiki#base#chomp_slash(expand(VimwikiGet('path', idx)))
let path = vimwiki#base#path_norm(path)
if s:path_common_pfx(path, a:path) == path
let idx_path = expand(VimwikiGet('path', idx))
let idx_path = vimwiki#u#path_norm(vimwiki#u#chomp_slash(idx_path))
if vimwiki#u#path_common_pfx(idx_path, path) == idx_path
return idx
endif
let idx += 1
endwhile
return -1
" an orphan page has been detected
endfunction "}}}
function! s:setup_buffer_leave()"{{{
if &filetype == 'vimwiki' && !exists("b:vimwiki_idx")
let b:vimwiki_idx = g:vimwiki_current_idx
function! s:vimwiki_idx() " {{{
if exists('b:vimwiki_idx')
return b:vimwiki_idx
else
return -1
endif
endfunction " }}}
function! s:setup_buffer_leave() "{{{
if g:vimwiki_debug ==3
echom "Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
if &filetype == 'vimwiki'
" cache global vars of current state XXX: SLOW!?
call vimwiki#base#cache_buffer_state()
endif
if g:vimwiki_debug ==3
echom " Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu disable '.g:vimwiki_menu.'.Table'
endif
endfunction"}}}
endfunction "}}}
function! s:setup_filetype() "{{{
" Find what wiki current buffer belongs to.
let path = expand('%:p:h')
if g:vimwiki_debug ==3
echom "Setup_filetype g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
let time0 = reltime() " start the clock "XXX
" Find what wiki current buffer belongs to.
let path = expand('%:p:h')
" XXX: find_wiki() does not (yet) take into consideration the ext
let idx = s:find_wiki(path)
if g:vimwiki_debug ==3
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
endif
if idx == -1 && g:vimwiki_global_ext == 0
return
endif
"XXX when idx = -1? (an orphan page has been detected)
"TODO: refactor (same code in setup_buffer_enter)
" The buffer's file is not in the path and user *does* want his wiki
" extension(s) to be global -- Add new wiki.
if idx == -1
let ext = '.'.expand('%:e')
let idx = s:find_wiki(path)
if idx == -1 && g:vimwiki_global_ext == 0
return
" lookup syntax using g:vimwiki_ext2syntax
if has_key(g:vimwiki_ext2syntax, ext)
let syn = g:vimwiki_ext2syntax[ext]
else
let syn = s:vimwiki_defaults.syntax
endif
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
let idx = len(g:vimwiki_list) - 1
endif
call vimwiki#base#validate_wiki_options(idx)
" initialize and cache global vars of current state
call vimwiki#base#setup_buffer_state(idx)
if g:vimwiki_debug ==3
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." (reset_wiki_state) b:curr_idx=".s:vimwiki_idx().""
endif
unlet! b:vimwiki_fs_rescan
set filetype=vimwiki
if g:vimwiki_debug ==3
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." (set ft=vimwiki) b:curr_idx=".s:vimwiki_idx().""
endif
let time1 = vimwiki#u#time(time0) "XXX
call VimwikiLog_extend('timing',['plugin:setup_filetype:time1',time1])
endfunction "}}}
function! s:setup_buffer_enter() "{{{
if exists("b:vimwiki_idx")
let g:vimwiki_current_idx = b:vimwiki_idx
else
if g:vimwiki_debug ==3
echom "Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
let time0 = reltime() " start the clock "XXX
if !vimwiki#base#recall_buffer_state()
" Find what wiki current buffer belongs to.
" If wiki does not exist in g:vimwiki_list -- add new wiki there with
" buffer's path and ext.
" Else set g:vimwiki_current_idx to that wiki index.
let path = expand('%:p:h')
let ext = '.'.expand('%:e')
" XXX: find_wiki() does not (yet) take into consideration the ext
let idx = s:find_wiki(path)
" The buffer's file is not in the path and user do not want his wiki
" extension to be global -- do not add new wiki.
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
endif
" The buffer's file is not in the path and user *does NOT* want his wiki
" extension to be global -- Do not add new wiki.
if idx == -1 && g:vimwiki_global_ext == 0
return
endif
"TODO: refactor (same code in setup_filetype)
" The buffer's file is not in the path and user *does* want his wiki
" extension(s) to be global -- Add new wiki.
if idx == -1
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'temp': 1})
let g:vimwiki_current_idx = len(g:vimwiki_list) - 1
else
let g:vimwiki_current_idx = idx
let ext = '.'.expand('%:e')
" lookup syntax using g:vimwiki_ext2syntax
if has_key(g:vimwiki_ext2syntax, ext)
let syn = g:vimwiki_ext2syntax[ext]
else
let syn = s:vimwiki_defaults.syntax
endif
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'syntax': syn, 'temp': 1})
let idx = len(g:vimwiki_list) - 1
endif
call vimwiki#base#validate_wiki_options(idx)
" initialize and cache global vars of current state
call vimwiki#base#setup_buffer_state(idx)
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (reset_wiki_state) b:curr_idx=".s:vimwiki_idx().""
endif
let b:vimwiki_idx = g:vimwiki_current_idx
endif
" If you have
@ -108,10 +175,22 @@ function! s:setup_buffer_enter() "{{{
" au GUIEnter * nested VimwikiIndex
if &filetype == ''
set filetype=vimwiki
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set ft vimwiki) b:curr_idx=".s:vimwiki_idx().""
endif
elseif &syntax == 'vimwiki'
" to force a rescan of the filesystem which may have changed
" and update VimwikiLinks syntax group that depends on it;
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
if exists("b:vimwiki_fs_rescan") && VimwikiGet('maxhi')
set syntax=vimwiki
if g:vimwiki_debug ==3
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set syntax=vimwiki) b:curr_idx=".s:vimwiki_idx().""
endif
endif
let b:vimwiki_fs_rescan = 1
endif
" Update existed/non-existed links highlighting.
call vimwiki#base#highlight_links()
let time1 = vimwiki#u#time(time0) "XXX
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
" new tab with the same buffer folding is reset to vim defaults. So we
@ -131,86 +210,125 @@ function! s:setup_buffer_enter() "{{{
if g:vimwiki_menu != ""
exe 'nmenu enable '.g:vimwiki_menu.'.Table'
endif
"let time2 = vimwiki#u#time(time0) "XXX
call VimwikiLog_extend('timing',['plugin:setup_buffer_enter:time1',time1])
endfunction "}}}
function! s:setup_buffer_reenter() "{{{
if g:vimwiki_debug ==3
echom "Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
if !vimwiki#base#recall_buffer_state()
" Do not repeat work of s:setup_buffer_enter() and s:setup_filetype()
" Once should be enough ...
endif
if g:vimwiki_debug ==3
echom " Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
endif
endfunction "}}}
function! s:setup_cleared_syntax() "{{{ highlight groups that get cleared
" on colorscheme change because they are not linked to Vim-predefined groups
hi def VimwikiBold term=bold cterm=bold gui=bold
hi def VimwikiItalic term=italic cterm=italic gui=italic
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic
hi def VimwikiUnderline gui=underline
if g:vimwiki_hl_headers == 1
for i in range(1,6)
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
endfor
endif
endfunction "}}}
" OPTION get/set functions {{{
" return value of option for current wiki or if second parameter exists for
" wiki with a given index.
" return complete list of options
function! VimwikiGetOptionNames() "{{{
return keys(s:vimwiki_defaults)
endfunction "}}}
function! VimwikiGetOptions(...) "{{{
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
let option_dict = {}
for kk in keys(s:vimwiki_defaults)
let option_dict[kk] = VimwikiGet(kk, idx)
endfor
return option_dict
endfunction "}}}
" Return value of option for current wiki or if second parameter exists for
" wiki with a given index.
" If the option is not found, it is assumed to have been previously cached in a
" buffer local dictionary, that acts as a cache.
" If the option is not found in the buffer local dictionary, an error is thrown
function! VimwikiGet(option, ...) "{{{
if a:0 == 0
let idx = g:vimwiki_current_idx
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if has_key(g:vimwiki_list[idx], a:option)
let val = g:vimwiki_list[idx][a:option]
elseif has_key(s:vimwiki_defaults, a:option)
let val = s:vimwiki_defaults[a:option]
let g:vimwiki_list[idx][a:option] = val
else
let idx = a:1
endif
if !has_key(g:vimwiki_list[idx], a:option) &&
\ has_key(s:vimwiki_defaults, a:option)
if a:option == 'path_html'
let g:vimwiki_list[idx][a:option] =
\VimwikiGet('path', idx)[:-2].'_html/'
else
let g:vimwiki_list[idx][a:option] =
\s:vimwiki_defaults[a:option]
endif
let val = b:vimwiki_list[a:option]
endif
" if path's ending is not a / or \
" then add it
if a:option == 'path' || a:option == 'path_html'
let p = g:vimwiki_list[idx][a:option]
" resolve doesn't work quite right with symlinks ended with / or \
let p = substitute(p, '[/\\]\+$', '', '')
let p = resolve(expand(p))
let g:vimwiki_list[idx][a:option] = p.'/'
endif
return g:vimwiki_list[idx][a:option]
" XXX no call to vimwiki#base here or else the whole autoload/base gets loaded!
return val
endfunction "}}}
" set option for current wiki or if third parameter exists for
" wiki with a given index.
" Set option for current wiki or if third parameter exists for
" wiki with a given index.
" If the option is not found or recognized (i.e. does not exist in
" s:vimwiki_defaults), it is saved in a buffer local dictionary, that acts
" as a cache.
" If the option is not found in the buffer local dictionary, an error is thrown
function! VimwikiSet(option, value, ...) "{{{
if a:0 == 0
let idx = g:vimwiki_current_idx
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
if has_key(s:vimwiki_defaults, a:option) ||
\ has_key(g:vimwiki_list[idx], a:option)
let g:vimwiki_list[idx][a:option] = a:value
elseif exists('b:vimwiki_list')
let b:vimwiki_list[a:option] = a:value
else
let idx = a:1
let b:vimwiki_list = {}
let b:vimwiki_list[a:option] = a:value
endif
let g:vimwiki_list[idx][a:option] = a:value
endfunction "}}}
" }}}
" }}}
" CALLBACK function "{{{
" CALLBACK functions "{{{
" User can redefine it.
if !exists("*VimwikiWeblinkHandler") "{{{
function VimwikiWeblinkHandler(weblink)
for browser in g:vimwiki_browsers
if executable(browser)
if has("win32")
execute '!start "'.browser.'" "' . a:weblink . '"'
else
execute '!'.browser.' "' . a:weblink . '"'
endif
return
endif
endfor
if !exists("*VimwikiLinkHandler") "{{{
function VimwikiLinkHandler(url)
return 0
endfunction
endif "}}}
if !exists("*VimwikiWikiIncludeHandler") "{{{
function! VimwikiWikiIncludeHandler(value) "{{{
" Return the empty string when unable to process link
return ''
endfunction "}}}
endif "}}}
" CALLBACK }}}
" DEFAULT wiki {{{
let s:vimwiki_defaults = {}
let s:vimwiki_defaults.path = '~/vimwiki/'
let s:vimwiki_defaults.path_html = '~/vimwiki_html/'
let s:vimwiki_defaults.path_html = '' " '' is replaced by derived path.'_html/'
let s:vimwiki_defaults.css_name = 'style.css'
let s:vimwiki_defaults.index = 'index'
let s:vimwiki_defaults.ext = '.wiki'
let s:vimwiki_defaults.maxhi = 1
let s:vimwiki_defaults.maxhi = 0
let s:vimwiki_defaults.syntax = 'default'
let s:vimwiki_defaults.template_path = '~/vimwiki/templates/'
let s:vimwiki_defaults.template_default = 'default'
let s:vimwiki_defaults.template_ext = '.html'
let s:vimwiki_defaults.template_path = ''
let s:vimwiki_defaults.template_default = ''
let s:vimwiki_defaults.template_ext = ''
let s:vimwiki_defaults.nested_syntaxes = {}
let s:vimwiki_defaults.auto_export = 0
@ -222,26 +340,20 @@ let s:vimwiki_defaults.temp = 0
let s:vimwiki_defaults.diary_rel_path = 'diary/'
let s:vimwiki_defaults.diary_index = 'diary'
let s:vimwiki_defaults.diary_header = 'Diary'
let s:vimwiki_defaults.diary_sort = 'desc'
" Do not change this! Will wait till vim become more datetime awareable.
let s:vimwiki_defaults.diary_link_fmt = '%Y-%m-%d'
let s:vimwiki_defaults.diary_link_count = 4
" NEW! in v2.0
" custom_wiki2html
let s:vimwiki_defaults.custom_wiki2html = ''
"
let s:vimwiki_defaults.list_margin = -1
"}}}
" DEFAULT options {{{
call s:default('list', [s:vimwiki_defaults])
if &encoding == 'utf-8'
call s:default('upper', 'A-Z\u0410-\u042f')
call s:default('lower', 'a-z\u0430-\u044f')
else
call s:default('upper', 'A-Z')
call s:default('lower', 'a-z')
endif
call s:default('other', '0-9')
call s:default('stripsym', '_')
call s:default('badsyms', '')
call s:default('auto_checkbox', 1)
call s:default('use_mouse', 0)
call s:default('folding', 0)
@ -249,77 +361,61 @@ call s:default('fold_trailing_empty_lines', 0)
call s:default('fold_lists', 0)
call s:default('menu', 'Vimwiki')
call s:default('global_ext', 1)
call s:default('ext2syntax', {'.md': 'markdown'}) " syntax map keyed on extension
call s:default('hl_headers', 0)
call s:default('hl_cb_checked', 0)
call s:default('camel_case', 1)
call s:default('list_ignore_newline', 1)
call s:default('listsyms', ' .oOX')
if has("win32")
call s:default('browsers',
\ [
\ expand('~').'\Local Settings\Application Data\Google\Chrome\Application\chrome.exe',
\ 'C:\Program Files\Opera\opera.exe',
\ 'C:\Program Files\Mozilla Firefox\firefox.exe',
\ 'C:\Program Files\Internet Explorer\iexplore.exe',
\ ])
else
call s:default('browsers',
\ [
\ 'chromium-browser',
\ 'opera',
\ 'firefox',
\ 'konqueror',
\ ])
endif
call s:default('use_calendar', 1)
call s:default('table_mappings', 1)
call s:default('table_auto_fmt', 1)
call s:default('w32_dir_enc', '')
call s:default('CJK_length', 0)
call s:default('dir_link', '')
call s:default('file_exts', 'pdf,txt,doc,rtf,xls,php,zip,rar,7z,html,gz')
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr,div,center,strong,em')
call s:default('user_htmls', '')
call s:default('html_header_numbering', 0)
call s:default('html_header_numbering_sym', '')
call s:default('conceallevel', 3)
call s:default('conceallevel', 2)
call s:default('url_mingain', 12)
call s:default('url_maxsave', 15)
call s:default('debug', 0)
call s:default('diary_months',
\ {
\ 1: 'January', 2: 'February', 3: 'March',
\ 4: 'April', 5: 'May', 6: 'June',
\ 7: 'July', 8: 'August', 9: 'September',
\ 10: 'October', 11: 'November', 12: 'December'
\ })
call s:default('current_idx', 0)
let upp = g:vimwiki_upper
let low = g:vimwiki_lower
let oth = g:vimwiki_other
let nup = low.oth
let nlo = upp.oth
let any = upp.nup
" Scheme regexes should be defined even if syntax file is not loaded yet
" cause users should be able to <leader>w<leader>w without opening any
" vimwiki file first
" Scheme regexes {{{
call s:default('schemes', 'wiki\d\+,diary,local')
call s:default('web_schemes1', 'http,https,file,ftp,gopher,telnet,nntp,ldap,'.
\ 'rsync,imap,pop,irc,ircs,cvs,svn,svn+ssh,git,ssh,fish,sftp')
call s:default('web_schemes2', 'mailto,news,xmpp,sip,sips,doi,urn,tel')
let wword = '\C\<['.upp.']['.nlo.']*['.low.']['.nup.']*['.upp.']['.any.']*\>'
let g:vimwiki_rxWikiWord = '!\@<!'.wword
let g:vimwiki_rxNoWikiWord = '!'.wword
let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').
\ '\)'
let g:vimwiki_rxWikiLink1 = '\[\[[^\]]\+\]\]'
let g:vimwiki_rxWikiLink2 = '\[\[[^\]]\+\]\[[^\]]\+\]\]'
if g:vimwiki_camel_case
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiWord.'\|'.
\ g:vimwiki_rxWikiLink1.'\|'.g:vimwiki_rxWikiLink2
else
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiLink1.'\|'.g:vimwiki_rxWikiLink2
endif
let g:vimwiki_rxWeblink = '\%("[^"(]\+\((\([^)]\+\))\)\?":\)\?'.
\'\%('.
\'\%('.
\'\%(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):'.
\'\%(\%(//\)\|\%(\\\\\)\)'.
\'\)'.
\'\|\%(mailto:\)'.
\'\)'.
\'\+\S\+'.
\'[().,?\]]\@<!'
call s:default('rxSchemeUrl', rxSchemes.':.*')
call s:default('rxSchemeUrlMatchScheme', '\zs'.rxSchemes.'\ze:.*')
call s:default('rxSchemeUrlMatchUrl', rxSchemes.':\zs.*\ze')
" scheme regexes }}}
"}}}
" AUTOCOMMANDS for all known wiki extensions {{{
" Getting all extensions that different wikies could have
" Getting all extensions that different wikis could have
let extensions = {}
for wiki in g:vimwiki_list
if has_key(wiki, 'ext')
@ -328,6 +424,10 @@ for wiki in g:vimwiki_list
let extensions['.wiki'] = 1
endif
endfor
" append map g:vimwiki_ext2syntax
for ext in keys(g:vimwiki_ext2syntax)
let extensions[ext] = 1
endfor
augroup filetypedetect
" clear FlexWiki's stuff
@ -337,16 +437,11 @@ augroup end
augroup vimwiki
autocmd!
for ext in keys(extensions)
exe 'autocmd BufEnter *'.ext.' call s:setup_buffer_reenter()'
exe 'autocmd BufWinEnter *'.ext.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
exe 'autocmd BufNewFile,BufRead, *'.ext.' call s:setup_filetype()'
" ColorScheme could have or could have not a
" VimwikiHeader1..VimwikiHeader6 highlight groups. We need to refresh
" syntax after colorscheme change.
exe 'autocmd ColorScheme *'.ext.' syntax enable'.
\ ' | call vimwiki#base#highlight_links()'
exe 'autocmd ColorScheme *'.ext.' call s:setup_cleared_syntax()'
" Format tables when exit from insert mode. Do not use textwidth to
" autowrap tables.
if g:vimwiki_table_auto_fmt
@ -359,17 +454,22 @@ augroup END
" COMMANDS {{{
command! VimwikiUISelect call vimwiki#base#ui_select()
command! -count VimwikiIndex
\ call vimwiki#base#goto_index(v:count1)
command! -count VimwikiTabIndex tabedit <bar>
" XXX: why not using <count> instead of v:count1?
" See Issue 324.
command! -count=1 VimwikiIndex
\ call vimwiki#base#goto_index(v:count1)
command! -count=1 VimwikiTabIndex
\ call vimwiki#base#goto_index(v:count1, 1)
command! -count VimwikiDiaryIndex
\ call vimwiki#diary#goto_index(v:count1)
command! -count VimwikiMakeDiaryNote
\ call vimwiki#diary#make_note(v:count1)
command! -count VimwikiTabMakeDiaryNote tabedit <bar>
command! -count=1 VimwikiDiaryIndex
\ call vimwiki#diary#goto_diary_index(v:count1)
command! -count=1 VimwikiMakeDiaryNote
\ call vimwiki#diary#make_note(v:count1)
command! -count=1 VimwikiTabMakeDiaryNote
\ call vimwiki#diary#make_note(v:count1, 1)
command! VimwikiDiaryGenerateLinks
\ call vimwiki#diary#generate_diary_section()
"}}}
" MAPPINGS {{{
@ -393,6 +493,11 @@ if !hasmapto('<Plug>VimwikiDiaryIndex')
endif
nnoremap <unique><script> <Plug>VimwikiDiaryIndex :VimwikiDiaryIndex<CR>
if !hasmapto('<Plug>VimwikiDiaryGenerateLinks')
nmap <silent><unique> <Leader>w<Leader>i <Plug>VimwikiDiaryGenerateLinks
endif
nnoremap <unique><script> <Plug>VimwikiDiaryGenerateLinks :VimwikiDiaryGenerateLinks<CR>
if !hasmapto('<Plug>VimwikiMakeDiaryNote')
nmap <silent><unique> <Leader>w<Leader>w <Plug>VimwikiMakeDiaryNote
endif
@ -429,6 +534,7 @@ function! s:build_table_menu(topmenu)
exe 'nmenu disable '.a:topmenu.'.Table'
endfunction
"XXX make sure anything below does not cause autoload/base to be loaded
if !empty(g:vimwiki_menu)
call s:build_menu(g:vimwiki_menu)
call s:build_table_menu(g:vimwiki_menu)
@ -442,4 +548,5 @@ if g:vimwiki_use_calendar
endif
"}}}
let &cpo = s:old_cpo

View File

@ -9,30 +9,331 @@ if version < 600
elseif exists("b:current_syntax")
finish
endif
"TODO do nothing if ...? (?)
let starttime = reltime() " start the clock
if VimwikiGet('maxhi')
let b:existing_wikifiles = vimwiki#base#get_links('*'.VimwikiGet('ext'))
let b:existing_wikidirs = vimwiki#base#get_links('*/')
endif
let timescans = vimwiki#u#time(starttime) "XXX
"let b:xxx = 1
"TODO ? update wikilink syntax group here if really needed (?) for :e and such
"if VimwikiGet('maxhi')
" ...
"endif
" Links highlighting is controlled by vimwiki#base#highlight_links() function.
" It is called from setup_buffer_enter() function in the BufEnter autocommand.
" LINKS: assume this is common to all syntaxes "{{{
" Load concrete Wiki syntax
" LINKS: WebLinks {{{
" match URL for common protocols;
" see http://en.wikipedia.org/wiki/URI_scheme http://tools.ietf.org/html/rfc3986
let g:vimwiki_rxWebProtocols = ''.
\ '\%('.
\ '\%('.
\ '\%('.join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').'\):'.
\ '\%(//\)'.
\ '\)'.
\ '\|'.
\ '\%('.join(split(g:vimwiki_web_schemes2, '\s*,\s*'), '\|').'\):'.
\ '\)'
"
let g:vimwiki_rxWeblinkUrl = g:vimwiki_rxWebProtocols .
\ '\S\{-1,}'. '\%(([^ \t()]*)\)\='
" }}}
" }}}
" -------------------------------------------------------------------------
" Load concrete Wiki syntax: sets regexes and templates for headers and links
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'.vim'
" -------------------------------------------------------------------------
let time0 = vimwiki#u#time(starttime) "XXX
" Concealed chars
" LINKS: setup of larger regexes {{{
" LINKS: setup wikilink regexps {{{
let g:vimwiki_rxWikiLinkPrefix = '[['
let g:vimwiki_rxWikiLinkSuffix = ']]'
let g:vimwiki_rxWikiLinkSeparator = '|'
" [[URL]]
let g:vimwiki_WikiLinkTemplate1 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLinkSuffix
" [[URL|DESCRIPTION]]
let g:vimwiki_WikiLinkTemplate2 = g:vimwiki_rxWikiLinkPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLinkSeparator. '__LinkDescription__'.
\ g:vimwiki_rxWikiLinkSuffix
"
let magic_chars = '.*[]\^$'
let valid_chars = '[^\\]'
let g:vimwiki_rxWikiLinkPrefix = escape(g:vimwiki_rxWikiLinkPrefix, magic_chars)
let g:vimwiki_rxWikiLinkSuffix = escape(g:vimwiki_rxWikiLinkSuffix, magic_chars)
let g:vimwiki_rxWikiLinkSeparator = escape(g:vimwiki_rxWikiLinkSeparator, magic_chars)
let g:vimwiki_rxWikiLinkUrl = valid_chars.'\{-}'
let g:vimwiki_rxWikiLinkDescr = valid_chars.'\{-}'
let g:vimwiki_rxWord = '[^[:blank:]()\\]\+'
"
" [[URL]], or [[URL|DESCRIPTION]]
" a) match [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.'\%('.g:vimwiki_rxWikiLinkSeparator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.g:vimwiki_rxWikiLinkSuffix
" b) match URL within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLinkMatchUrl = g:vimwiki_rxWikiLinkPrefix.
\ '\zs'. g:vimwiki_rxWikiLinkUrl.'\ze\%('. g:vimwiki_rxWikiLinkSeparator.
\ g:vimwiki_rxWikiLinkDescr.'\)\?'.g:vimwiki_rxWikiLinkSuffix
" c) match DESCRIPTION within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLinkMatchDescr = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.g:vimwiki_rxWikiLinkSeparator.'\%('.
\ '\zs'. g:vimwiki_rxWikiLinkDescr. '\ze\)\?'. g:vimwiki_rxWikiLinkSuffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiLinkPrefix1 = g:vimwiki_rxWikiLinkPrefix.
\ g:vimwiki_rxWikiLinkUrl.g:vimwiki_rxWikiLinkSeparator
let g:vimwiki_rxWikiLinkSuffix1 = g:vimwiki_rxWikiLinkSuffix
" }}}
" LINKS: setup of wikiincl regexps {{{
let g:vimwiki_rxWikiInclPrefix = '{{'
let g:vimwiki_rxWikiInclSuffix = '}}'
let g:vimwiki_rxWikiInclSeparator = '|'
"
" '{{__LinkUrl__}}'
let g:vimwiki_WikiInclTemplate1 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiInclSuffix
" '{{__LinkUrl____LinkDescription__}}'
let g:vimwiki_WikiInclTemplate2 = g:vimwiki_rxWikiInclPrefix . '__LinkUrl__'.
\ '__LinkDescription__'.
\ g:vimwiki_rxWikiInclSuffix
let g:vimwiki_rxWikiInclPrefix = escape(g:vimwiki_rxWikiInclPrefix, magic_chars)
let g:vimwiki_rxWikiInclSuffix = escape(g:vimwiki_rxWikiInclSuffix, magic_chars)
let g:vimwiki_rxWikiInclSeparator = escape(g:vimwiki_rxWikiInclSeparator, magic_chars)
let g:vimwiki_rxWikiInclUrl = valid_chars.'\{-}'
let g:vimwiki_rxWikiInclArg = valid_chars.'\{-}'
let g:vimwiki_rxWikiInclArgs = '\%('. g:vimwiki_rxWikiInclSeparator. g:vimwiki_rxWikiInclArg. '\)'.'\{-}'
"
"
" *. {{URL}[{...}]} - i.e. {{URL}}, {{URL|ARG1}}, {{URL|ARG1|ARG2}}, etc.
" *a) match {{URL}[{...}]}
let g:vimwiki_rxWikiIncl = g:vimwiki_rxWikiInclPrefix.
\ g:vimwiki_rxWikiInclUrl.
\ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
" *b) match URL within {{URL}[{...}]}
let g:vimwiki_rxWikiInclMatchUrl = g:vimwiki_rxWikiInclPrefix.
\ '\zs'. g:vimwiki_rxWikiInclUrl. '\ze'.
\ g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiInclPrefix1 = g:vimwiki_rxWikiInclPrefix.
\ g:vimwiki_rxWikiInclUrl.g:vimwiki_rxWikiInclSeparator
let g:vimwiki_rxWikiInclSuffix1 = g:vimwiki_rxWikiInclArgs.
\ g:vimwiki_rxWikiInclSuffix
" }}}
" LINKS: Setup weblink regexps {{{
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
" let g:vimwiki_rxWeblink = '[\["(|]\@<!'. g:vimwiki_rxWeblinkUrl .
" \ '\%([),:;.!?]\=\%([ \t]\|$\)\)\@='
" Maxim:
" Simplify free-standing links: URL starts with non(letter|digit)scheme till
" the whitespace.
" Stuart, could you check it with markdown templated links? [](http://...), as
" the last bracket is the part of URL now?
let g:vimwiki_rxWeblink = '[[:alnum:]]\@<!'. g:vimwiki_rxWeblinkUrl . '\S*'
" 0a) match URL within URL
let g:vimwiki_rxWeblinkMatchUrl = g:vimwiki_rxWeblink
" 0b) match DESCRIPTION within URL
let g:vimwiki_rxWeblinkMatchDescr = ''
" }}}
" LINKS: Setup anylink regexps {{{
let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
\ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink
" }}}
" }}} end of Links
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
function! s:add_target_syntax_ON(target, type) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
let prefix0 = 'syntax match '.a:type.' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match '.a:type.'T `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
function! s:add_target_syntax_OFF(target) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,VimwikiLinkChar'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
function! s:highlight_existing_links() "{{{
" Wikilink
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
" Wikilink Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
" match [[URL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[URL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
\ safe_links, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate1,
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match {{URL|...}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate2,
\ safe_links, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" match [[DIRURL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
\ safe_dirs, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
endfunction "}}}
" use max highlighting - could be quite slow if there are too many wikifiles
if VimwikiGet('maxhi')
" WikiLink
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink)
" WikiIncl
call s:add_target_syntax_OFF(g:vimwiki_rxWikiIncl)
" Subsequently, links verified on vimwiki's path are highlighted as existing
let time01 = vimwiki#u#time(starttime) "XXX
call s:highlight_existing_links()
let time02 = vimwiki#u#time(starttime) "XXX
else
let time01 = vimwiki#u#time(starttime) "XXX
" Wikilink
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink, 'VimwikiLink')
" WikiIncl
call s:add_target_syntax_ON(g:vimwiki_rxWikiIncl, 'VimwikiLink')
let time02 = vimwiki#u#time(starttime) "XXX
endif
" Weblink
call s:add_target_syntax_ON(g:vimwiki_rxWeblink, 'VimwikiLink')
" WikiLink
" All remaining schemes are highlighted automatically
let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
\ '\):'
" a) match [[nonwiki-scheme-URL]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate1,
\ rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" b) match [[nonwiki-scheme-URL|DESCRIPTION]]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLinkTemplate2,
\ rxSchemes.g:vimwiki_rxWikiLinkUrl, g:vimwiki_rxWikiLinkDescr, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" a) match {{nonwiki-scheme-URL}}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate1,
\ rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" b) match {{nonwiki-scheme-URL}[{...}]}
let target = vimwiki#base#apply_template(g:vimwiki_WikiInclTemplate2,
\ rxSchemes.g:vimwiki_rxWikiInclUrl, g:vimwiki_rxWikiInclArgs, '')
call s:add_target_syntax_ON(target, 'VimwikiLink')
" }}}
" generic headers "{{{
if g:vimwiki_symH
"" symmetric
for i in range(1,6)
let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__ '.repeat(g:vimwiki_rxH, i)
let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']'.g:vimwiki_rxH.'\{'.i.'}\s*$'
endfor
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*[^'.g:vimwiki_rxH.']\ze\1\s*$'
else
" asymmetric
for i in range(1,6)
let g:vimwiki_rxH{i}_Template = repeat(g:vimwiki_rxH, i).' __Header__'
let g:vimwiki_rxH{i} = '^\s*'.g:vimwiki_rxH.'\{'.i.'}[^'.g:vimwiki_rxH.'].*$'
endfor
let g:vimwiki_rxHeader = '^\s*\('.g:vimwiki_rxH.'\{1,6}\)\zs[^'.g:vimwiki_rxH.'].*\ze$'
endif
" Header levels, 1-6
for i in range(1,6)
execute 'syntax match VimwikiHeader'.i.' /'.g:vimwiki_rxH{i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,@Spell'
endfor
" }}}
" concealed chars " {{{
if exists("+conceallevel")
syntax conceal on
endif
syntax spell toplevel
syn match VimwikiLinkChar contained /\[\[/
syn match VimwikiLinkChar contained /\]\]/
syn match VimwikiLinkChar contained /\[\[[^\[\]\|]\{-}|\ze.\{-}]]/
syn match VimwikiLinkChar contained /\[\[[^\[\]\|]\{-}]\[\ze.\{-}]]/
if g:vimwiki_debug > 1
echom 'WikiLink Prefix: '.g:vimwiki_rxWikiLinkPrefix1
echom 'WikiLink Suffix: '.g:vimwiki_rxWikiLinkSuffix1
echom 'WikiIncl Prefix: '.g:vimwiki_rxWikiInclPrefix1
echom 'WikiIncl Suffix: '.g:vimwiki_rxWikiInclSuffix1
endif
syn match VimwikiNoLinkChar contained /\[\[/
syn match VimwikiNoLinkChar contained /\]\]/
syn match VimwikiNoLinkChar contained /\[\[[^\[\]\|]\{-}|\ze.*]]/
syn match VimwikiNoLinkChar contained /\[\[[^\[\]\|]\{-}]\[\ze.*]]/
" VimwikiLinkChar is for syntax markers (and also URL when a description
" is present) and may be concealed
let options = ' contained transparent contains=NONE'
" conceal wikilinks
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkPrefix1.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiLinkSuffix1.'/'.options
" conceal wikiincls
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix1.'/'.options
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix1.'/'.options
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
execute 'syn match VimwikiLinkRest contained `\%(///\=[^/ \t]\+/\)\zs\S\{'
\.g:vimwiki_url_mingain.',}\ze\%([/#?]\w\|\S\{'
\.g:vimwiki_url_maxsave.'}\)` cchar=~ '.options
execute 'syn match VimwikiEqInChar contained /'.g:vimwiki_char_eqin.'/'
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'
execute 'syn match VimwikiItalicChar contained /'.g:vimwiki_char_italic.'/'
execute 'syn match VimwikiBoldItalicChar contained /'.g:vimwiki_char_bolditalic.'/'
@ -44,9 +345,11 @@ execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'
if exists("+conceallevel")
syntax conceal off
endif
" }}}
" Non concealed chars
syn match VimwikiHeaderChar contained /\%(^\s*=\+\)\|\%(=\+\s*$\)/
" non concealed chars " {{{
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.g:vimwiki_rxH.'\+\)\|\%('.g:vimwiki_rxH.'\+\s*$\)/'
execute 'syn match VimwikiEqInCharT contained /'.g:vimwiki_char_eqin.'/'
execute 'syn match VimwikiBoldCharT contained /'.g:vimwiki_char_bold.'/'
execute 'syn match VimwikiItalicCharT contained /'.g:vimwiki_char_italic.'/'
execute 'syn match VimwikiBoldItalicCharT contained /'.g:vimwiki_char_bolditalic.'/'
@ -56,21 +359,32 @@ execute 'syn match VimwikiDelTextCharT contained /'.g:vimwiki_char_deltext.'/'
execute 'syn match VimwikiSuperScriptT contained /'.g:vimwiki_char_superscript.'/'
execute 'syn match VimwikiSubScriptT contained /'.g:vimwiki_char_subscript.'/'
" Emoticons
syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
"syntax match VimwikiEmoticons /\%((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
let g:vimwiki_rxTodo = '\C\%(TODO:\|DONE:\|STARTED:\|FIXME:\|FIXED:\|XXX:\)'
execute 'syntax match VimwikiTodo /'. g:vimwiki_rxTodo .'/'
" }}}
" main syntax groups {{{
" Tables
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ transparent contains=VimwikiCellSeparator,VimwikiLinkT,
\ VimwikiNoExistsLinkT,VimwikiEmoticons,VimwikiTodo,
\ VimwikiBoldT,VimwikiItalicT,VimwikiBoldItalicT,VimwikiItalicBoldT,
\ VimwikiDelTextT,VimwikiSuperScriptT,VimwikiSubScriptT,VimwikiCodeT,
\ @Spell
\ transparent contains=VimwikiCellSeparator,
\ VimwikiLinkT,
\ VimwikiNoExistsLinkT,
\ VimwikiEmoticons,
\ VimwikiTodo,
\ VimwikiBoldT,
\ VimwikiItalicT,
\ VimwikiBoldItalicT,
\ VimwikiItalicBoldT,
\ VimwikiDelTextT,
\ VimwikiSuperScriptT,
\ VimwikiSubScriptT,
\ VimwikiCodeT,
\ VimwikiEqInT,
\ @Spell
syntax match VimwikiCellSeparator
\ /\%(|\)\|\%(-\@<=+\-\@=\)\|\%([|+]\@<=-\+\)/ contained
@ -78,6 +392,23 @@ syntax match VimwikiCellSeparator
execute 'syntax match VimwikiList /'.g:vimwiki_rxListBullet.'/'
execute 'syntax match VimwikiList /'.g:vimwiki_rxListNumber.'/'
execute 'syntax match VimwikiList /'.g:vimwiki_rxListDefine.'/'
" List item checkbox
"syntax match VimwikiCheckBox /\[.\?\]/
let g:vimwiki_rxCheckBox = '\s*\[['.g:vimwiki_listsyms.']\?\]\s'
" Todo lists have a checkbox
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListBullet.g:vimwiki_rxCheckBox.'/'
execute 'syntax match VimwikiListTodo /'.g:vimwiki_rxListNumber.g:vimwiki_rxCheckBox.'/'
if g:vimwiki_hl_cb_checked
execute 'syntax match VimwikiCheckBoxDone /'.
\ g:vimwiki_rxListBullet.'\s*\['.g:vimwiki_listsyms[4].'\]\s.*$/'.
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
execute 'syntax match VimwikiCheckBoxDone /'.
\ g:vimwiki_rxListNumber.'\s*\['.g:vimwiki_listsyms[4].'\]\s.*$/'.
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
endif
execute 'syntax match VimwikiEqIn /'.g:vimwiki_rxEqIn.'/ contains=VimwikiEqInChar'
execute 'syntax match VimwikiEqInT /'.g:vimwiki_rxEqIn.'/ contained contains=VimwikiEqInCharT'
execute 'syntax match VimwikiBold /'.g:vimwiki_rxBold.'/ contains=VimwikiBoldChar,@Spell'
execute 'syntax match VimwikiBoldT /'.g:vimwiki_rxBold.'/ contained contains=VimwikiBoldCharT,@Spell'
@ -103,23 +434,15 @@ execute 'syntax match VimwikiSubScriptT /'.g:vimwiki_rxSubScript.'/ contained co
execute 'syntax match VimwikiCode /'.g:vimwiki_rxCode.'/ contains=VimwikiCodeChar'
execute 'syntax match VimwikiCodeT /'.g:vimwiki_rxCode.'/ contained contains=VimwikiCodeCharT'
" <hr> horizontal rule
execute 'syntax match VimwikiHR /'.g:vimwiki_rxHR.'/'
execute 'syntax region VimwikiPre start=/^\s*'.g:vimwiki_rxPreStart.
\ '/ end=/^\s*'.g:vimwiki_rxPreEnd.'\s*$/ contains=@Spell'
" List item checkbox
syntax match VimwikiCheckBox /\[.\?\]/
if g:vimwiki_hl_cb_checked
execute 'syntax match VimwikiCheckBoxDone /'.
\ g:vimwiki_rxListBullet.'\s*\['.g:vimwiki_listsyms[4].'\].*$/'.
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
execute 'syntax match VimwikiCheckBoxDone /'.
\ g:vimwiki_rxListNumber.'\s*\['.g:vimwiki_listsyms[4].'\].*$/'.
\ ' contains=VimwikiNoExistsLink,VimwikiLink'
endif
execute 'syntax region VimwikiMath start=/^\s*'.g:vimwiki_rxMathStart.
\ '/ end=/^\s*'.g:vimwiki_rxMathEnd.'\s*$/ contains=@Spell'
" placeholders
syntax match VimwikiPlaceholder /^\s*%toc\%(\s.*\)\?$/ contains=VimwikiPlaceholderParam
@ -129,51 +452,48 @@ syntax match VimwikiPlaceholder /^\s*%template\%(\s.*\)\?$/ contains=VimwikiPlac
syntax match VimwikiPlaceholderParam /\s.*/ contained
" html tags
let html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
if g:vimwiki_valid_html_tags != ''
let html_tags = join(split(g:vimwiki_valid_html_tags, '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiItalic #\c<i>.\{-}</i># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiUnderline #\c<u>.\{-}</u># contains=VimwikiHTMLTag'
execute 'syntax match VimwikiComment /'.g:vimwiki_rxComment.'/ contains=@Spell'
execute 'syntax match VimwikiComment /'.g:vimwiki_rxComment.'/ contains=@Spell'
endif
" }}}
" Header levels, 1-6
execute 'syntax match VimwikiHeader1 /'.g:vimwiki_rxH1.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
execute 'syntax match VimwikiHeader2 /'.g:vimwiki_rxH2.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
execute 'syntax match VimwikiHeader3 /'.g:vimwiki_rxH3.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
execute 'syntax match VimwikiHeader4 /'.g:vimwiki_rxH4.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
execute 'syntax match VimwikiHeader5 /'.g:vimwiki_rxH5.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
execute 'syntax match VimwikiHeader6 /'.g:vimwiki_rxH6.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiLink,@Spell'
" group names "{{{
" header groups highlighting "{{{
if g:vimwiki_hl_headers == 0
hi link VimwikiHeader1 Title
hi link VimwikiHeader2 Title
hi link VimwikiHeader3 Title
hi link VimwikiHeader4 Title
hi link VimwikiHeader5 Title
hi link VimwikiHeader6 Title
else
if &background == 'light'
hi def VimwikiHeader1 guibg=bg guifg=#aa5858 gui=bold ctermfg=DarkRed term=bold cterm=bold
hi def VimwikiHeader2 guibg=bg guifg=#507030 gui=bold ctermfg=DarkGreen term=bold cterm=bold
hi def VimwikiHeader3 guibg=bg guifg=#1030a0 gui=bold ctermfg=DarkBlue term=bold cterm=bold
hi def VimwikiHeader4 guibg=bg guifg=#103040 gui=bold ctermfg=Black term=bold cterm=bold
hi def VimwikiHeader5 guibg=bg guifg=#505050 gui=bold ctermfg=Black term=bold cterm=bold
hi def VimwikiHeader6 guibg=bg guifg=#636363 gui=bold ctermfg=Black term=bold cterm=bold
else
hi def VimwikiHeader1 guibg=bg guifg=#e08090 gui=bold ctermfg=Red term=bold cterm=bold
hi def VimwikiHeader2 guibg=bg guifg=#80e090 gui=bold ctermfg=Green term=bold cterm=bold
hi def VimwikiHeader3 guibg=bg guifg=#6090e0 gui=bold ctermfg=Blue term=bold cterm=bold
hi def VimwikiHeader4 guibg=bg guifg=#c0c0f0 gui=bold ctermfg=White term=bold cterm=bold
hi def VimwikiHeader5 guibg=bg guifg=#e0e0f0 gui=bold ctermfg=White term=bold cterm=bold
hi def VimwikiHeader6 guibg=bg guifg=#f0f0f0 gui=bold ctermfg=White term=bold cterm=bold
" Strangely in default colorscheme Title group is not set to bold for cterm...
if !exists("g:colors_name")
hi Title cterm=bold
endif
for i in range(1,6)
execute 'hi def link VimwikiHeader'.i.' Title'
endfor
else
" default colors when headers of different levels are highlighted differently
" not making it yet another option; needed by ColorScheme autocommand
let g:vimwiki_hcolor_guifg_light = ['#aa5858','#507030','#1030a0','#103040','#505050','#636363']
let g:vimwiki_hcolor_ctermfg_light = ['DarkRed','DarkGreen','DarkBlue','Black','Black','Black']
let g:vimwiki_hcolor_guifg_dark = ['#e08090','#80e090','#6090e0','#c0c0f0','#e0e0f0','#f0f0f0']
let g:vimwiki_hcolor_ctermfg_dark = ['Red','Green','Blue','White','White','White']
for i in range(1,6)
execute 'hi def VimwikiHeader'.i.' guibg=bg guifg='.g:vimwiki_hcolor_guifg_{&bg}[i-1].' gui=bold ctermfg='.g:vimwiki_hcolor_ctermfg_{&bg}[i-1].' term=bold cterm=bold'
endfor
endif
"}}}
" syntax group highlighting "{{{
hi def link VimwikiMarkers Normal
hi def link VimwikiEqIn Number
hi def link VimwikiEqInT VimwikiEqIn
hi def VimwikiBold term=bold cterm=bold gui=bold
hi def link VimwikiBoldT VimwikiBold
@ -193,6 +513,9 @@ hi def link VimwikiCodeT VimwikiCode
hi def link VimwikiPre PreProc
hi def link VimwikiPreT VimwikiPre
hi def link VimwikiMath Number
hi def link VimwikiMathT VimwikiMath
hi def link VimwikiNoExistsLink SpellBad
hi def link VimwikiNoExistsLinkT VimwikiNoExistsLink
@ -200,9 +523,11 @@ hi def link VimwikiLink Underlined
hi def link VimwikiLinkT VimwikiLink
hi def link VimwikiList Identifier
hi def link VimwikiCheckBox VimwikiList
hi def link VimwikiListTodo VimwikiList
"hi def link VimwikiCheckBox VimwikiList
hi def link VimwikiCheckBoxDone Comment
hi def link VimwikiEmoticons Character
hi def link VimwikiHR Identifier
hi def link VimwikiDelText Constant
hi def link VimwikiDelTextT VimwikiDelText
@ -220,6 +545,7 @@ hi def link VimwikiPlaceholder SpecialKey
hi def link VimwikiPlaceholderParam String
hi def link VimwikiHTMLtag SpecialKey
hi def link VimwikiEqInChar VimwikiMarkers
hi def link VimwikiCellSeparator VimwikiMarkers
hi def link VimwikiBoldChar VimwikiMarkers
hi def link VimwikiItalicChar VimwikiMarkers
@ -230,9 +556,8 @@ hi def link VimwikiSuperScriptChar VimwikiMarkers
hi def link VimwikiSubScriptChar VimwikiMarkers
hi def link VimwikiCodeChar VimwikiMarkers
hi def link VimwikiHeaderChar VimwikiMarkers
hi def link VimwikiLinkChar VimwikiLink
hi def link VimwikiNoLinkChar VimwikiNoExistsLink
hi def link VimwikiEqInCharT VimwikiMarkers
hi def link VimwikiBoldCharT VimwikiMarkers
hi def link VimwikiItalicCharT VimwikiMarkers
hi def link VimwikiBoldItalicCharT VimwikiMarkers
@ -243,9 +568,14 @@ hi def link VimwikiSubScriptCharT VimwikiMarkers
hi def link VimwikiCodeCharT VimwikiMarkers
hi def link VimwikiHeaderCharT VimwikiMarkers
hi def link VimwikiLinkCharT VimwikiLinkT
hi def link VimwikiNoLinkCharT VimwikiNoExistsLinkT
hi def link VimwikiNoExistsLinkCharT VimwikiNoExistsLinkT
"}}}
" -------------------------------------------------------------------------
" Load syntax-specific functionality
execute 'runtime! syntax/vimwiki_'.VimwikiGet('syntax').'_custom.vim'
" -------------------------------------------------------------------------
let b:current_syntax="vimwiki"
" EMBEDDED syntax setup "{{{
@ -253,9 +583,16 @@ let nested = VimwikiGet('nested_syntaxes')
if !empty(nested)
for [hl_syntax, vim_syntax] in items(nested)
call vimwiki#base#nested_syntax(vim_syntax,
\ '^\s*{{{\%(.*[[:blank:][:punct:]]\)\?'.
\ '^\s*'.g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
\ '^\s*}}}', 'VimwikiPre')
\ '^\s*'.g:vimwiki_rxPreEnd, 'VimwikiPre')
" call vimwiki#base#nested_syntax(vim_syntax,
" \ '^\s*{{\$\%(.*[[:blank:][:punct:]]\)\?'.
" \ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
" \ '^\s*}}\$', 'VimwikiMath')
endfor
endif
"}}}
let timeend = vimwiki#u#time(starttime) "XXX
call VimwikiLog_extend('timing',['syntax:scans',timescans],['syntax:regexloaded',time0],['syntax:beforeHLexisting',time01],['syntax:afterHLexisting',time02],['syntax:end',timeend])

View File

@ -4,6 +4,13 @@
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
let g:vimwiki_char_eqin = '\$'
" text: *strong*
" let g:vimwiki_rxBold = '\*[^*]\+\*'
let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
@ -53,27 +60,20 @@ let g:vimwiki_char_superscript = '^'
let g:vimwiki_rxSubScript = ',,[^,`]\+,,'
let g:vimwiki_char_subscript = ',,'
" Header levels, 1-6
let g:vimwiki_rxH1 = '^\s*=\{1}[^=]\+.*[^=]\+=\{1}\s*$'
let g:vimwiki_rxH2 = '^\s*=\{2}[^=]\+.*[^=]\+=\{2}\s*$'
let g:vimwiki_rxH3 = '^\s*=\{3}[^=]\+.*[^=]\+=\{3}\s*$'
let g:vimwiki_rxH4 = '^\s*=\{4}[^=]\+.*[^=]\+=\{4}\s*$'
let g:vimwiki_rxH5 = '^\s*=\{5}[^=]\+.*[^=]\+=\{5}\s*$'
let g:vimwiki_rxH6 = '^\s*=\{6}[^=]\+.*[^=]\+=\{6}\s*$'
let g:vimwiki_rxHeader = '\%('.g:vimwiki_rxH1.'\)\|'.
\ '\%('.g:vimwiki_rxH2.'\)\|'.
\ '\%('.g:vimwiki_rxH3.'\)\|'.
\ '\%('.g:vimwiki_rxH4.'\)\|'.
\ '\%('.g:vimwiki_rxH5.'\)\|'.
\ '\%('.g:vimwiki_rxH6.'\)'
" generic headers
let g:vimwiki_rxH = '='
let g:vimwiki_symH = 1
let g:vimwiki_char_header = '\%(^\s*=\+\)\|\%(=\+\s*$\)'
" <hr>, horizontal rule
let g:vimwiki_rxHR = '^----.*$'
let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
" List items start with optional whitespace(s) then '* ' or '# '
let g:vimwiki_rxListBullet = '^\s*\%(\*\|-\)\s'
let g:vimwiki_rxListBullet = '^\s*[*-]\s'
let g:vimwiki_rxListNumber = '^\s*#\s'
let g:vimwiki_rxListDefine = '::\(\s\|$\)'
@ -82,4 +82,8 @@ let g:vimwiki_rxListDefine = '::\(\s\|$\)'
let g:vimwiki_rxPreStart = '{{{'
let g:vimwiki_rxPreEnd = '}}}'
" Math block
let g:vimwiki_rxMathStart = '{{\$'
let g:vimwiki_rxMathEnd = '}}\$'
let g:vimwiki_rxComment = '^\s*%%.*$'

View File

@ -0,0 +1,89 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" Default syntax
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
let g:vimwiki_char_eqin = '\$'
" text: *strong*
" let g:vimwiki_rxBold = '\*[^*]\+\*'
let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*'.
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
\'\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bold = '*'
" text: _emphasis_
" let g:vimwiki_rxItalic = '_[^_]\+_'
let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_'.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italic = '_'
" text: *_bold italic_* or _*italic bold*_
let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*_'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'_\*'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_bolditalic = '\*_'
let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_\*'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\*_'.
\'\%([[:punct:]]\|\s\|$\)\@='
let g:vimwiki_char_italicbold = '_\*'
" text: `code`
let g:vimwiki_rxCode = '`[^`]\+`'
let g:vimwiki_char_code = '`'
" text: ~~deleted text~~
let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~'
let g:vimwiki_char_deltext = '\~\~'
" text: ^superscript^
let g:vimwiki_rxSuperScript = '\^[^^`]\+\^'
let g:vimwiki_char_superscript = '^'
" text: ,,subscript,,
let g:vimwiki_rxSubScript = ',,[^,`]\+,,'
let g:vimwiki_char_subscript = ',,'
" generic headers
let g:vimwiki_rxH = '#'
let g:vimwiki_symH = 0
" <hr>, horizontal rule
let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
" List items start with optional whitespace(s) then '* ' or '1. ', '2. ', etc.
let g:vimwiki_rxListBullet = '^\s*[*+-]\s'
let g:vimwiki_rxListNumber = '^\s*[0-9]\+\.\s'
let g:vimwiki_rxListDefine = '::\%(\s\|$\)'
" Preformatted text
let g:vimwiki_rxPreStart = '```'
let g:vimwiki_rxPreEnd = '```'
" Math block
let g:vimwiki_rxMathStart = '{{\$'
let g:vimwiki_rxMathEnd = '}}\$'
let g:vimwiki_rxComment = '^\s*%%.*$'

View File

@ -0,0 +1,367 @@
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
" Vimwiki syntax file
" Author: Stuart Andrews <stu.andrews@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" LINKS: assume this is common to all syntaxes "{{{
" }}}
" -------------------------------------------------------------------------
" Load concrete Wiki syntax: sets regexes and templates for headers and links
" -------------------------------------------------------------------------
" LINKS: setup of larger regexes {{{
" LINKS: setup wikilink0 regexps {{{
" 0. [[URL]], or [[URL|DESCRIPTION]]
" 0a) match [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink0 = g:vimwiki_rxWikiLink
" 0b) match URL within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink0MatchUrl = g:vimwiki_rxWikiLinkMatchUrl
" 0c) match DESCRIPTION within [[URL|DESCRIPTION]]
let g:vimwiki_rxWikiLink0MatchDescr = g:vimwiki_rxWikiLinkMatchDescr
" }}}
" LINKS: setup wikilink1 regexps {{{
" 1. [URL][], or [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1Prefix = '['
let g:vimwiki_rxWikiLink1Suffix = ']'
let g:vimwiki_rxWikiLink1Separator = ']['
" [URL][]
let g:vimwiki_WikiLink1Template1 = g:vimwiki_rxWikiLink1Prefix . '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Separator. g:vimwiki_rxWikiLink1Suffix
" [DESCRIPTION][URL]
let g:vimwiki_WikiLink1Template2 = g:vimwiki_rxWikiLink1Prefix . '__LinkDescription__'.
\ g:vimwiki_rxWikiLink1Separator. '__LinkUrl__'.
\ g:vimwiki_rxWikiLink1Suffix
"
let magic_chars = '.*[]\^$'
let valid_chars = '[^\\\[\]]'
let g:vimwiki_rxWikiLink1Prefix = escape(g:vimwiki_rxWikiLink1Prefix, magic_chars)
let g:vimwiki_rxWikiLink1Suffix = escape(g:vimwiki_rxWikiLink1Suffix, magic_chars)
let g:vimwiki_rxWikiLink1Separator = escape(g:vimwiki_rxWikiLink1Separator, magic_chars)
let g:vimwiki_rxWikiLink1Url = valid_chars.'\{-}'
let g:vimwiki_rxWikiLink1Descr = valid_chars.'\{-}'
let g:vimwiki_rxWikiLink1InvalidPrefix = '[\]\[]\@<!'
let g:vimwiki_rxWikiLink1InvalidSuffix = '[\]\[]\@!'
let g:vimwiki_rxWikiLink1Prefix = g:vimwiki_rxWikiLink1InvalidPrefix.
\ g:vimwiki_rxWikiLink1Prefix
let g:vimwiki_rxWikiLink1Suffix = g:vimwiki_rxWikiLink1Suffix.
\ g:vimwiki_rxWikiLink1InvalidSuffix
"
" 1. [URL][], [DESCRIPTION][URL]
" 1a) match [URL][], [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1 = g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Url. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Suffix.
\ '\|'. g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Descr.g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
" 1b) match URL within [URL][], [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1MatchUrl = g:vimwiki_rxWikiLink1Prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Suffix.
\ '\|'. g:vimwiki_rxWikiLink1Prefix.
\ g:vimwiki_rxWikiLink1Descr. g:vimwiki_rxWikiLink1Separator.
\ '\zs'. g:vimwiki_rxWikiLink1Url. '\ze'. g:vimwiki_rxWikiLink1Suffix
" 1c) match DESCRIPTION within [DESCRIPTION][URL]
let g:vimwiki_rxWikiLink1MatchDescr = g:vimwiki_rxWikiLink1Prefix.
\ '\zs'. g:vimwiki_rxWikiLink1Descr.'\ze'. g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
" }}}
" LINKS: Syntax helper {{{
let g:vimwiki_rxWikiLink1Prefix1 = g:vimwiki_rxWikiLink1Prefix
let g:vimwiki_rxWikiLink1Suffix1 = g:vimwiki_rxWikiLink1Separator.
\ g:vimwiki_rxWikiLink1Url.g:vimwiki_rxWikiLink1Suffix
" }}}
" *. ANY wikilink {{{
" *a) match ANY wikilink
let g:vimwiki_rxWikiLink = ''.
\ g:vimwiki_rxWikiLink0.'\|'.
\ g:vimwiki_rxWikiLink1
" *b) match URL within ANY wikilink
let g:vimwiki_rxWikiLinkMatchUrl = ''.
\ g:vimwiki_rxWikiLink0MatchUrl.'\|'.
\ g:vimwiki_rxWikiLink1MatchUrl
" *c) match DESCRIPTION within ANY wikilink
let g:vimwiki_rxWikiLinkMatchDescr = ''.
\ g:vimwiki_rxWikiLink0MatchDescr.'\|'.
\ g:vimwiki_rxWikiLink1MatchDescr
" }}}
" LINKS: setup of wikiincl regexps {{{
" }}}
" LINKS: Syntax helper {{{
" }}}
" LINKS: Setup weblink0 regexps {{{
" 0. URL : free-standing links: keep URL UR(L) strip trailing punct: URL; URL) UR(L))
let g:vimwiki_rxWeblink0 = g:vimwiki_rxWeblink
" 0a) match URL within URL
let g:vimwiki_rxWeblinkMatchUrl0 = g:vimwiki_rxWeblinkMatchUrl
" 0b) match DESCRIPTION within URL
let g:vimwiki_rxWeblinkMatchDescr0 = g:vimwiki_rxWeblinkMatchDescr
" }}}
" LINKS: Setup weblink1 regexps {{{
let g:vimwiki_rxWeblink1Prefix = '['
let g:vimwiki_rxWeblink1Suffix = ')'
let g:vimwiki_rxWeblink1Separator = ']('
" [DESCRIPTION](URL)
let g:vimwiki_Weblink1Template = g:vimwiki_rxWeblink1Prefix . '__LinkDescription__'.
\ g:vimwiki_rxWeblink1Separator. '__LinkUrl__'.
\ g:vimwiki_rxWeblink1Suffix
let magic_chars = '.*[]\^$'
let valid_chars = '[^\\]'
let g:vimwiki_rxWeblink1Prefix = escape(g:vimwiki_rxWeblink1Prefix, magic_chars)
let g:vimwiki_rxWeblink1Suffix = escape(g:vimwiki_rxWeblink1Suffix, magic_chars)
let g:vimwiki_rxWeblink1Separator = escape(g:vimwiki_rxWeblink1Separator, magic_chars)
let g:vimwiki_rxWeblink1Url = valid_chars.'\{-}'
let g:vimwiki_rxWeblink1Descr = valid_chars.'\{-}'
"
" " 2012-02-04 TODO not starting with [[ or ][ ? ... prefix = '[\[\]]\@<!\['
" 1. [DESCRIPTION](URL)
" 1a) match [DESCRIPTION](URL)
let g:vimwiki_rxWeblink1 = g:vimwiki_rxWeblink1Prefix.
\ g:vimwiki_rxWeblink1Url.g:vimwiki_rxWeblink1Separator.
\ g:vimwiki_rxWeblink1Descr.g:vimwiki_rxWeblink1Suffix
" 1b) match URL within [DESCRIPTION](URL)
let g:vimwiki_rxWeblink1MatchUrl = g:vimwiki_rxWeblink1Prefix.
\ g:vimwiki_rxWeblink1Descr. g:vimwiki_rxWeblink1Separator.
\ '\zs'.g:vimwiki_rxWeblink1Url.'\ze'. g:vimwiki_rxWeblink1Suffix
" 1c) match DESCRIPTION within [DESCRIPTION](URL)
let g:vimwiki_rxWeblink1MatchDescr = g:vimwiki_rxWeblink1Prefix.
\ '\zs'.g:vimwiki_rxWeblink1Descr.'\ze'. g:vimwiki_rxWeblink1Separator.
\ g:vimwiki_rxWeblink1Url. g:vimwiki_rxWeblink1Suffix
" }}}
" Syntax helper {{{
" TODO: image links too !!
" let g:vimwiki_rxWeblink1Prefix1 = '!\?'. g:vimwiki_rxWeblink1Prefix
let g:vimwiki_rxWeblink1Prefix1 = g:vimwiki_rxWeblink1Prefix
let g:vimwiki_rxWeblink1Suffix1 = g:vimwiki_rxWeblink1Separator.
\ g:vimwiki_rxWeblink1Url.g:vimwiki_rxWeblink1Suffix
" }}}
" *. ANY weblink {{{
" *a) match ANY weblink
let g:vimwiki_rxWeblink = ''.
\ g:vimwiki_rxWeblink1.'\|'.
\ g:vimwiki_rxWeblink0
" *b) match URL within ANY weblink
let g:vimwiki_rxWeblinkMatchUrl = ''.
\ g:vimwiki_rxWeblink1MatchUrl.'\|'.
\ g:vimwiki_rxWeblinkMatchUrl0
" *c) match DESCRIPTION within ANY weblink
let g:vimwiki_rxWeblinkMatchDescr = ''.
\ g:vimwiki_rxWeblink1MatchDescr.'\|'.
\ g:vimwiki_rxWeblinkMatchDescr0
" }}}
" LINKS: Setup anylink regexps {{{
let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
\ g:vimwiki_rxWikiIncl.'\|'.g:vimwiki_rxWeblink
" }}}
" }}} end of Links
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
function! s:add_target_syntax_ON(target, type) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
let prefix0 = 'syntax match '.a:type.' `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match '.a:type.'T `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
function! s:add_target_syntax_OFF(target, type) " {{{
if g:vimwiki_debug > 1
echom '[vimwiki_debug] syntax target > '.a:target
endif
let prefix0 = 'syntax match VimwikiNoExistsLink `'
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
let suffix1 = '` display contained'
execute prefix0. a:target. suffix0
execute prefix1. a:target. suffix1
endfunction "}}}
function! s:wrap_wikilink1_rx(target) "{{{
return g:vimwiki_rxWikiLink1InvalidPrefix.a:target.
\ g:vimwiki_rxWikiLink1InvalidSuffix
endfunction "}}}
function! s:highlight_existing_links() "{{{
" Wikilink1
" Conditional highlighting that depends on the existence of a wiki file or
" directory is only available for *schemeless* wiki links
" Links are set up upon BufEnter (see plugin/...)
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
" Wikilink1 Dirs set up upon BufEnter (see plugin/...)
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
" match [URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DIRURL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" match [DESCRIPTION][DIRURL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
endfunction "}}}
" use max highlighting - could be quite slow if there are too many wikifiles
if VimwikiGet('maxhi')
" WikiLink
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
" Subsequently, links verified on vimwiki's path are highlighted as existing
let time01 = vimwiki#u#time(starttime) "XXX
call s:highlight_existing_links()
let time02 = vimwiki#u#time(starttime) "XXX
else
let time01 = vimwiki#u#time(starttime) "XXX
" Wikilink
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
let time02 = vimwiki#u#time(starttime) "XXX
endif
" Weblink
call s:add_target_syntax_ON(g:vimwiki_rxWeblink1, 'VimwikiWeblink1')
" WikiLink
" All remaining schemes are highlighted automatically
let rxSchemes = '\%('.
\ join(split(g:vimwiki_schemes, '\s*,\s*'), '\|').'\|'.
\ join(split(g:vimwiki_web_schemes1, '\s*,\s*'), '\|').
\ '\):'
" a) match [nonwiki-scheme-URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
\ rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" b) match [DESCRIPTION][nonwiki-scheme-URL]
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
\ rxSchemes.g:vimwiki_rxWikiLink1Url, g:vimwiki_rxWikiLink1Descr, '')
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
" }}}
" generic headers "{{{
" Header levels, 1-6
for i in range(1,6)
execute 'syntax match VimwikiHeader'.i.' /'.g:vimwiki_rxH{i}.'/ contains=VimwikiTodo,VimwikiHeaderChar,VimwikiNoExistsLink,VimwikiCode,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
endfor
" }}}
" concealed chars " {{{
if exists("+conceallevel")
syntax conceal on
endif
syntax spell toplevel
if g:vimwiki_debug > 1
echom 'WikiLink1 Prefix: '.g:vimwiki_rxWikiLink1Prefix1
echom 'WikiLink1 Suffix: '.g:vimwiki_rxWikiLink1Suffix1
echom 'Weblink1 Prefix: '.g:vimwiki_rxWeblink1Prefix1
echom 'Weblink1 Suffix: '.g:vimwiki_rxWeblink1Suffix1
endif
" VimwikiWikiLink1Char is for syntax markers (and also URL when a description
" is present) and may be concealed
let options = ' contained transparent contains=NONE'
" conceal wikilink1
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Prefix.'/'.options
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Suffix.'/'.options
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Prefix1.'/'.options
execute 'syn match VimwikiWikiLink1Char /'.g:vimwiki_rxWikiLink1Suffix1.'/'.options
" conceal weblink1
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Prefix1.'"'.options
execute 'syn match VimwikiWeblink1Char "'.g:vimwiki_rxWeblink1Suffix1.'"'.options
if exists("+conceallevel")
syntax conceal off
endif
" }}}
" non concealed chars " {{{
" }}}
" main syntax groups {{{
" Tables
syntax match VimwikiTableRow /^\s*|.\+|\s*$/
\ transparent contains=VimwikiCellSeparator,
\ VimwikiLinkT,
\ VimwikiWeblink1T,
\ VimwikiWikiLink1T,
\ VimwikiNoExistsLinkT,
\ VimwikiEmoticons,
\ VimwikiTodo,
\ VimwikiBoldT,
\ VimwikiItalicT,
\ VimwikiBoldItalicT,
\ VimwikiItalicBoldT,
\ VimwikiDelTextT,
\ VimwikiSuperScriptT,
\ VimwikiSubScriptT,
\ VimwikiCodeT,
\ VimwikiEqInT,
\ @Spell
" }}}
" header groups highlighting "{{{
"}}}
" syntax group highlighting "{{{
hi def link VimwikiWeblink1 VimwikiLink
hi def link VimwikiWeblink1T VimwikiLink
hi def link VimwikiWikiLink1 VimwikiLink
hi def link VimwikiWikiLink1T VimwikiLink
"}}}
" EMBEDDED syntax setup "{{{
"}}}
"

View File

@ -4,6 +4,13 @@
" Author: Maxim Kim <habamax@gmail.com>
" Home: http://code.google.com/p/vimwiki/
" placeholder for math environments
let b:vimwiki_mathEnv = ""
" text: $ equation_inline $
let g:vimwiki_rxEqIn = '\$[^$`]\+\$'
let g:vimwiki_char_eqin = '\$'
" text: '''strong'''
let g:vimwiki_rxBold = "'''[^']\\+'''"
let g:vimwiki_char_bold = "'''"
@ -34,31 +41,22 @@ let g:vimwiki_char_superscript = '^'
let g:vimwiki_rxSubScript = ',,[^,]\+,,'
let g:vimwiki_char_subscript = ',,'
" Header levels, 1-6
let g:vimwiki_rxH1 = '^\s*=\{1}[^=]\+.*[^=]\+=\{1}\s*$'
let g:vimwiki_rxH2 = '^\s*=\{2}[^=]\+.*[^=]\+=\{2}\s*$'
let g:vimwiki_rxH3 = '^\s*=\{3}[^=]\+.*[^=]\+=\{3}\s*$'
let g:vimwiki_rxH4 = '^\s*=\{4}[^=]\+.*[^=]\+=\{4}\s*$'
let g:vimwiki_rxH5 = '^\s*=\{5}[^=]\+.*[^=]\+=\{5}\s*$'
let g:vimwiki_rxH6 = '^\s*=\{6}[^=]\+.*[^=]\+=\{6}\s*$'
let g:vimwiki_rxHeader = '\%('.g:vimwiki_rxH1.'\)\|'.
\ '\%('.g:vimwiki_rxH2.'\)\|'.
\ '\%('.g:vimwiki_rxH3.'\)\|'.
\ '\%('.g:vimwiki_rxH4.'\)\|'.
\ '\%('.g:vimwiki_rxH5.'\)\|'.
\ '\%('.g:vimwiki_rxH6.'\)'
let g:vimwiki_char_header = '\%(^\s*=\+\)\|\%(=\+\s*$\)'
" generic headers
let g:vimwiki_rxH = '='
let g:vimwiki_symH = 1
" <hr>, horizontal rule
let g:vimwiki_rxHR = '^----.*$'
let g:vimwiki_rxHR = '^-----*$'
" Tables. Each line starts and ends with '||'; each cell is separated by '||'
let g:vimwiki_rxTable = '||'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let g:vimwiki_rxTableSep = '|'
" Bulleted list items start with whitespace(s), then '*'
" highlight only bullets and digits.
let g:vimwiki_rxListBullet = '^\s*\*\+\([^*]*$\)\@='
let g:vimwiki_rxListNumber = '^\s*#\+'
let g:vimwiki_rxListBullet = '^\s*\*\+\s\%([^*]*$\)\@='
let g:vimwiki_rxListNumber = '^\s*#\+\s'
let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
@ -66,4 +64,8 @@ let g:vimwiki_rxListDefine = '^\%(;\|:\)\s'
let g:vimwiki_rxPreStart = '<pre>'
let g:vimwiki_rxPreEnd = '<\/pre>'
" Math block
let g:vimwiki_rxMathStart = '{{\$'
let g:vimwiki_rxMathEnd = '}}\$'
let g:vimwiki_rxComment = '^\s*%%.*$'