Commits

Marlo Simon Noval committed d0a97f4

Added vimwiki and update css.vim

  • Participants
  • Parent commits 0c4f50c

Comments (0)

Files changed (14)

 
 # Ignore Align plugin
 Align*.*
-cecutil.vim
+cecutil.vim
+
+# Ignore vimwiki files
+vimwiki/*

autoload/vimwiki.vim

+" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
+" Vimwiki autoload plugin file
+" Author: Maxim Kim <habamax@gmail.com>
+" Home: http://code.google.com/p/vimwiki/
+
+if exists("g:loaded_vimwiki_auto") || &cp
+  finish
+endif
+let g:loaded_vimwiki_auto = 1
+
+if has("win32")
+  let s:os_sep = '\'
+else
+  let s:os_sep = '/'
+endif
+
+let s:badsymbols = '['.g:vimwiki_badsyms.g:vimwiki_stripsym.'<>|?*:"]'
+
+" MISC helper functions {{{
+
+function! vimwiki#chomp_slash(str) "{{{
+  return substitute(a:str, '[/\\]\+$', '', '')
+endfunction "}}}
+
+function! vimwiki#mkdir(path) "{{{
+  let path = expand(a:path)
+  if !isdirectory(path) && exists("*mkdir")
+    let path = vimwiki#chomp_slash(path)
+    if s:is_windows() && !empty(g:vimwiki_w32_dir_enc)
+      let path = iconv(path, &enc, g:vimwiki_w32_dir_enc)
+    endif
+    call mkdir(path, "p")
+  endif
+endfunction
+" }}}
+
+function! vimwiki#safe_link(string) "{{{
+  return substitute(a:string, s:badsymbols, g:vimwiki_stripsym, 'g')
+endfunction
+"}}}
+
+function! vimwiki#unsafe_link(string) "{{{
+  return substitute(a:string, g:vimwiki_stripsym, s:badsymbols, 'g')
+endfunction
+"}}}
+
+function! vimwiki#subdir(path, filename)"{{{
+  let path = expand(a:path)
+  let filename = expand(a:filename)
+  let idx = 0
+  while path[idx] ==? filename[idx]
+    let idx = idx + 1
+  endwhile
+
+  let p = split(strpart(filename, idx), '[/\\]')
+  let res = join(p[:-2], s:os_sep)
+  if len(res) > 0
+    let res = res.s:os_sep
+  endif
+  return res
+endfunction"}}}
+
+function! vimwiki#current_subdir()"{{{
+  return vimwiki#subdir(VimwikiGet('path'), expand('%:p'))
+endfunction"}}}
+
+function! vimwiki#open_link(cmd, link, ...) "{{{
+  if vimwiki#is_non_wiki_link(a:link)
+    call s:edit_file(a:cmd, a:link)
+  else
+    if a:0
+      let vimwiki_prev_link = [a:1, []]
+    elseif &ft == 'vimwiki'
+      let vimwiki_prev_link = [expand('%:p'), getpos('.')]
+    endif
+
+    if vimwiki#is_link_to_dir(a:link)
+      if g:vimwiki_dir_link == ''
+        call s:edit_file(a:cmd, VimwikiGet('path').a:link)
+      else
+        call s:edit_file(a:cmd,
+              \ VimwikiGet('path').a:link.
+              \ g:vimwiki_dir_link.
+              \ VimwikiGet('ext'))
+      endif
+    else
+      call s:edit_file(a:cmd, VimwikiGet('path').a:link.VimwikiGet('ext'))
+    endif
+
+    if exists('vimwiki_prev_link')
+      let b:vimwiki_prev_link = vimwiki_prev_link
+    endif
+  endif
+endfunction
+" }}}
+
+function! vimwiki#select(wnum)"{{{
+  if a:wnum < 1 || a:wnum > len(g:vimwiki_list)
+    return
+  endif
+  if &ft == 'vimwiki'
+    let b:vimwiki_idx = g:vimwiki_current_idx
+  endif
+  let g:vimwiki_current_idx = a:wnum - 1
+endfunction
+" }}}
+
+function! vimwiki#generate_links()"{{{
+  let links = s:get_links('*'.VimwikiGet('ext'))
+
+  " We don't want link to itself.
+  let cur_link = expand('%:t:r')
+  call filter(links, 'v:val != cur_link')
+
+  if len(links)
+    call append(line('$'), '= Generated Links =')
+  endif
+
+  call sort(links)
+
+  for link in links
+    if s:is_wiki_word(link)
+      call append(line('$'), '- '.link)
+    else
+      call append(line('$'), '- [['.link.']]')
+    endif
+  endfor
+endfunction " }}}
+
+function! vimwiki#goto(key) "{{{
+    call s:edit_file(':e',
+          \ VimwikiGet('path').
+          \ a:key.
+          \ VimwikiGet('ext'))
+endfunction "}}}
+
+function! s:is_windows() "{{{
+  return has("win32") || has("win64") || has("win95") || has("win16")
+endfunction "}}}
+
+function! s:get_links(pat) "{{{
+  " search all wiki files in 'path' and its subdirs.
+  let subdir = vimwiki#current_subdir()
+
+  " if current wiki is temporary -- was added by an arbitrary wiki file then do
+  " not search wiki files in subdirectories. Or it would hang the system if
+  " wiki file was created in $HOME or C:/ dirs.
+  if VimwikiGet('temp')
+    let search_dirs = ''
+  else
+    let search_dirs = '**/'
+  endif
+  let globlinks = glob(VimwikiGet('path').subdir.search_dirs.a:pat)
+
+  " remove extensions (and backup extensions too: .wiki~)
+  let globlinks = substitute(globlinks, '\'.VimwikiGet('ext').'\~\?', "", "g")
+  let links = split(globlinks, '\n')
+
+  " remove paths
+  let rem_path = escape(expand(VimwikiGet('path')).subdir, '\')
+  call map(links, 'substitute(v:val, rem_path, "", "g")')
+
+  " Remove trailing slashes.
+  call map(links, 'substitute(v:val, "[/\\\\]*$", "", "g")')
+
+  return links
+endfunction "}}}
+
+" Builtin cursor doesn't work right with unicode characters.
+function! s:cursor(lnum, cnum) "{{{
+    exe a:lnum
+    exe 'normal! 0'.a:cnum.'|'
+endfunction "}}}
+
+function! s:filename(link) "{{{
+  let result = vimwiki#safe_link(a:link)
+  if a:link =~ '|'
+    let result = vimwiki#safe_link(split(a:link, '|')[0])
+  elseif a:link =~ ']['
+    let result = vimwiki#safe_link(split(a:link, '][')[0])
+  endif
+  return result
+endfunction
+" }}}
+
+function! s:is_wiki_word(str) "{{{
+  if a:str =~ g:vimwiki_rxWikiWord && a:str !~ '[[:space:]\\/]'
+    return 1
+  endif
+  return 0
+endfunction
+" }}}
+
+function! s:edit_file(command, filename) "{{{
+  let fname = escape(a:filename, '% ')
+  call vimwiki#mkdir(fnamemodify(a:filename, ":p:h"))
+  execute a:command.' '.fname
+endfunction
+" }}}
+
+function! s:search_word(wikiRx, cmd) "{{{
+  let match_line = search(a:wikiRx, 's'.a:cmd)
+  if match_line == 0
+    echomsg "vimwiki: Wiki link not found."
+  endif
+endfunction
+" }}}
+
+function! s:get_word_at_cursor(wikiRX) "{{{
+  let col = col('.') - 1
+  let line = getline('.')
+  let ebeg = -1
+  let cont = match(line, a:wikiRX, 0)
+  while (ebeg >= 0 || (0 <= cont) && (cont <= col))
+    let contn = matchend(line, a:wikiRX, cont)
+    if (cont <= col) && (col < contn)
+      let ebeg = match(line, a:wikiRX, cont)
+      let elen = contn - ebeg
+      break
+    else
+      let cont = match(line, a:wikiRX, contn)
+    endif
+  endwh
+  if ebeg >= 0
+    return strpart(line, ebeg, elen)
+  else
+    return ""
+  endif
+endf "}}}
+
+function! s:strip_word(word) "{{{
+  let result = a:word
+  if strpart(a:word, 0, 2) == "[["
+    " get rid of [[ and ]]
+    let w = strpart(a:word, 2, strlen(a:word)-4)
+
+    if w =~ '|'
+      " we want "link" from [[link|link desc]]
+      let w = split(w, "|")[0]
+    elseif w =~ ']['
+      " we want "link" from [[link][link desc]]
+      let w = split(w, "][")[0]
+    endif
+
+    let result = vimwiki#safe_link(w)
+  endif
+  return result
+endfunction
+" }}}
+
+function! vimwiki#is_non_wiki_link(lnk) "{{{
+  let exts = '.\+\.\%('.
+          \ join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
+          \ '\)$'
+  if a:lnk =~ exts
+    return 1
+  endif
+  return 0
+endfunction "}}}
+
+function! vimwiki#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! s:print_wiki_list() "{{{
+  let idx = 0
+  while idx < len(g:vimwiki_list)
+    if idx == g:vimwiki_current_idx
+      let sep = ' * '
+      echohl PmenuSel
+    else
+      let sep = '   '
+      echohl None
+    endif
+    echo (idx + 1).sep.VimwikiGet('path', idx)
+    let idx += 1
+  endwhile
+  echohl None
+endfunction
+" }}}
+
+function! s:update_wiki_link(fname, old, new) " {{{
+  echo "Updating links in ".a:fname
+  let has_updates = 0
+  let dest = []
+  for line in readfile(a:fname)
+    if !has_updates && match(line, a:old) != -1
+      let has_updates = 1
+    endif
+    call add(dest, substitute(line, a:old, escape(a:new, "&"), "g"))
+  endfor
+  " add exception handling...
+  if has_updates
+    call rename(a:fname, a:fname.'#vimwiki_upd#')
+    call writefile(dest, a:fname)
+    call delete(a:fname.'#vimwiki_upd#')
+  endif
+endfunction
+" }}}
+
+function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{
+  let old_fname = substitute(a:old_fname, '[/\\]', '[/\\\\]', 'g')
+  let new_fname = a:new_fname
+  let old_fname_r = old_fname
+  let new_fname_r = new_fname
+
+  if !s:is_wiki_word(new_fname) && s:is_wiki_word(old_fname)
+    let new_fname_r = '[['.new_fname.']]'
+  endif
+
+  if !s:is_wiki_word(old_fname)
+    let old_fname_r = '\[\[\zs'.vimwiki#unsafe_link(old_fname).
+          \ '\ze\%(|.*\)\?\%(\]\[.*\)\?\]\]'
+  else
+    let old_fname_r = '\<'.old_fname.'\>'
+  endif
+
+  let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n')
+  for fname in files
+    call s:update_wiki_link(fname, old_fname_r, new_fname_r)
+  endfor
+endfunction
+" }}}
+
+function! s:tail_name(fname) "{{{
+  let result = substitute(a:fname, ":", "__colon__", "g")
+  let result = fnamemodify(result, ":t:r")
+  let result = substitute(result, "__colon__", ":", "g")
+  return result
+endfunction "}}}
+
+function! s:update_wiki_links(old_fname, new_fname) " {{{
+  let old_fname = s:tail_name(a:old_fname)
+  let new_fname = s:tail_name(a:new_fname)
+
+  let subdirs = split(a:old_fname, '[/\\]')[: -2]
+
+  " TODO: Use Dictionary here...
+  let dirs_keys = ['']
+  let dirs_vals = ['']
+  if len(subdirs) > 0
+    let dirs_keys = ['']
+    let dirs_vals = [join(subdirs, '/').'/']
+    let idx = 0
+    while idx < len(subdirs) - 1
+      call add(dirs_keys, join(subdirs[: idx], '/').'/')
+      call add(dirs_vals, join(subdirs[idx+1 :], '/').'/')
+      let idx = idx + 1
+    endwhile
+    call add(dirs_keys,join(subdirs, '/').'/')
+    call add(dirs_vals, '')
+  endif
+
+  let idx = 0
+  while idx < len(dirs_keys)
+    let dir = dirs_keys[idx]
+    let new_dir = dirs_vals[idx]
+    call s:update_wiki_links_dir(dir,
+          \ new_dir.old_fname, new_dir.new_fname)
+    let idx = idx + 1
+  endwhile
+endfunction " }}}
+
+function! s:get_wiki_buffers() "{{{
+  let blist = []
+  let bcount = 1
+  while bcount<=bufnr("$")
+    if bufexists(bcount)
+      let bname = fnamemodify(bufname(bcount), ":p")
+      if bname =~ VimwikiGet('ext')."$"
+        let bitem = [bname, getbufvar(bname, "vimwiki_prev_link")]
+        call add(blist, bitem)
+      endif
+    endif
+    let bcount = bcount + 1
+  endwhile
+  return blist
+endfunction " }}}
+
+function! s:open_wiki_buffer(item) "{{{
+  call s:edit_file('e', a:item[0])
+  if !empty(a:item[1])
+    call setbufvar(a:item[0], "vimwiki_prev_link", a:item[1])
+  endif
+endfunction " }}}
+
+" }}}
+
+" SYNTAX highlight {{{
+function! vimwiki#highlight_links() "{{{
+  try
+    syntax clear VimwikiNoExistsLink
+    syntax clear VimwikiNoExistsLinkT
+    syntax clear VimwikiLink
+    syntax clear VimwikiLinkT
+  catch
+  endtry
+
+  "" use max highlighting - could be quite slow if there are too many wikifiles
+  if VimwikiGet('maxhi')
+    " Every WikiWord is nonexistent
+    if g:vimwiki_camel_case
+      execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiWord.'/ display'
+      execute 'syntax match VimwikiNoExistsLinkT /'.g:vimwiki_rxWikiWord.'/ display contained'
+    endif
+    execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiLink1.'/ display contains=VimwikiNoLinkChar'
+    execute 'syntax match VimwikiNoExistsLink /'.g:vimwiki_rxWikiLink2.'/ display contains=VimwikiNoLinkChar'
+
+    execute 'syntax match VimwikiNoExistsLinkT /'.g:vimwiki_rxWikiLink1.'/ display contained'
+    execute 'syntax match VimwikiNoExistsLinkT /'.g:vimwiki_rxWikiLink2.'/ display contained'
+
+    " till we find them in vimwiki's path
+    call s:highlight_existed_links()
+  else
+    " A WikiWord (unqualifiedWikiName)
+    execute 'syntax match VimwikiLink /\<'.g:vimwiki_rxWikiWord.'\>/'
+    " A [[bracketed wiki word]]
+    execute 'syntax match VimwikiLink /'.g:vimwiki_rxWikiLink1.'/ display contains=VimwikiLinkChar'
+    execute 'syntax match VimwikiLink /'.g:vimwiki_rxWikiLink2.'/ display contains=VimwikiLinkChar'
+
+    execute 'syntax match VimwikiLinkT /\<'.g:vimwiki_rxWikiWord.'\>/ display contained'
+    execute 'syntax match VimwikiLinkT /'.g:vimwiki_rxWikiLink1.'/ display contained'
+    execute 'syntax match VimwikiLinkT /'.g:vimwiki_rxWikiLink2.'/ display contained'
+  endif
+
+  execute 'syntax match VimwikiLink `'.g:vimwiki_rxWeblink.'` display contains=@NoSpell'
+endfunction "}}}
+
+function! s:highlight_existed_links() "{{{
+  let links = s:get_links('*'.VimwikiGet('ext'))
+
+  " Links with subdirs should be highlighted for linux and windows separators
+  " Change \ or / to [/\\]
+  let os_p = '[/\\]'
+  let os_p2 = escape(os_p, '\')
+  call map(links, 'substitute(v:val, os_p, os_p2, "g")')
+
+  for link in links
+    if g:vimwiki_camel_case &&
+          \ link =~ g:vimwiki_rxWikiWord && !vimwiki#is_non_wiki_link(link)
+      execute 'syntax match VimwikiLink /!\@<!\<'.link.'\>/ display'
+    endif
+    execute 'syntax match VimwikiLink /\[\['.
+          \ escape(vimwiki#unsafe_link(link), '~&$.*').
+          \ '\%(|\+.\{-}\)\{-}\]\]/ display contains=VimwikiLinkChar'
+    execute 'syntax match VimwikiLink /\[\['.
+          \ escape(vimwiki#unsafe_link(link), '~&$.*').
+          \ '\]\[.\{-1,}\]\]/ display contains=VimwikiLinkChar'
+
+    execute 'syntax match VimwikiLinkT /\[\['.
+          \ escape(vimwiki#unsafe_link(link), '~&$.*').
+          \ '\%(|\+.\{-}\)\{-}\]\]/ display contained'
+    execute 'syntax match VimwikiLinkT /\[\['.
+          \ escape(vimwiki#unsafe_link(link), '~&$.*').
+          \ '\]\[.\{-1,}\]\]/ display contained'
+  endfor
+  execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
+  execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\]\[.\+\]\]/ display contains=VimwikiLinkChar'
+
+  execute 'syntax match VimwikiLinkT /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/ display contained'
+  execute 'syntax match VimwikiLinkT /\[\[.\+\.\%(jpg\|png\|gif\)\]\[.\+\]\]/ display contained'
+
+  " Issue 103: Always highlight links to non-wiki files as existed.
+  execute 'syntax match VimwikiLink /\[\[.\+\.\%('.
+        \join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
+        \'\)\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
+  execute 'syntax match VimwikiLink /\[\[.\+\.\%('.
+        \join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
+        \'\)\]\[.\+\]\]/ display contains=VimwikiLinkChar'
+
+  execute 'syntax match VimwikiLinkT /\[\[.\+\.\%('.
+        \join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
+        \'\)\%(|\+.*\)*\]\]/ display contained'
+  execute 'syntax match VimwikiLinkT /\[\[.\+\.\%('.
+        \join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
+        \'\)\]\[.\+\]\]/ display contained'
+
+  " highlight dirs
+  let dirs = s:get_links('*/')
+  call map(dirs, 'substitute(v:val, os_p, os_p2, "g")')
+  for dir in dirs
+    execute 'syntax match VimwikiLink /\[\['.
+          \ escape(vimwiki#unsafe_link(dir), '~&$.*').
+          \ '[/\\]*\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
+    execute 'syntax match VimwikiLink /\[\['.
+          \ escape(vimwiki#unsafe_link(dir), '~&$.*').
+          \ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contains=VimwikiLinkChar'
+
+    execute 'syntax match VimwikiLinkT /\[\['.
+          \ escape(vimwiki#unsafe_link(dir), '~&$.*').
+          \ '[/\\]*\%(|\+.*\)*\]\]/ display contained'
+    execute 'syntax match VimwikiLinkT /\[\['.
+          \ escape(vimwiki#unsafe_link(dir), '~&$.*').
+          \ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contained'
+  endfor
+endfunction "}}}
+
+function! vimwiki#setup_colors() "{{{
+
+  function! s:set_visible_ignore_color() "{{{
+    if !exists("g:colors_name") || g:colors_name == 'default'
+      if &background == 'light'
+        hi VimwikiIgnore guifg=#d0d0d0
+      else
+        hi VimwikiIgnore guifg=#505050
+      endif
+    else
+      hi link VimwikiIgnore Normal
+    endif
+  endfunction "}}}
+
+  let hlfg_ignore = vimwiki#get_hl_param('Ignore', 'guifg')
+  let hlbg_normal = vimwiki#get_hl_param('Normal', 'guibg')
+  if hlfg_ignore == 'bg' || hlfg_ignore == hlbg_normal
+    call s:set_visible_ignore_color()
+  else
+    hi link VimwikiIgnore Ignore
+  endif
+
+  if g:vimwiki_hl_headers == 0
+    hi def link VimwikiHeader Title
+    return
+  endif
+
+  if &background == 'light'
+    hi def VimwikiHeader1 guibg=bg guifg=#aa5858 gui=bold ctermfg=DarkRed
+    hi def VimwikiHeader2 guibg=bg guifg=#507030 gui=bold ctermfg=DarkGreen
+    hi def VimwikiHeader3 guibg=bg guifg=#1030a0 gui=bold ctermfg=DarkBlue
+    hi def VimwikiHeader4 guibg=bg guifg=#103040 gui=bold ctermfg=Black
+    hi def VimwikiHeader5 guibg=bg guifg=#505050 gui=bold ctermfg=Black
+    hi def VimwikiHeader6 guibg=bg guifg=#636363 gui=bold ctermfg=Black
+  else
+    hi def VimwikiHeader1 guibg=bg guifg=#e08090 gui=bold ctermfg=Red
+    hi def VimwikiHeader2 guibg=bg guifg=#80e090 gui=bold ctermfg=Green
+    hi def VimwikiHeader3 guibg=bg guifg=#6090e0 gui=bold ctermfg=Blue
+    hi def VimwikiHeader4 guibg=bg guifg=#c0c0f0 gui=bold ctermfg=White
+    hi def VimwikiHeader5 guibg=bg guifg=#e0e0f0 gui=bold ctermfg=White
+    hi def VimwikiHeader6 guibg=bg guifg=#f0f0f0 gui=bold ctermfg=White
+  endif
+endfunction "}}}
+
+function vimwiki#get_hl_param(hgroup, hparam) "{{{
+  redir => hlstatus
+  try
+    exe "silent hi ".a:hgroup
+  catch /E411/
+  endtry
+  redir END
+  return matchstr(hlstatus, a:hparam.'\s*=\s*\zs\S\+')
+endfunction "}}}
+
+function! vimwiki#hl_exists(hl) "{{{
+  if !hlexists(a:hl)
+    return 0
+  endif
+  redir => hlstatus
+  exe "silent hi" a:hl
+  redir END
+  return (hlstatus !~ "cleared")
+endfunction
+"}}}
+
+function! vimwiki#nested_syntax(filetype, start, end, textSnipHl) abort "{{{
+" From http://vim.wikia.com/wiki/VimTip857
+  let ft=toupper(a:filetype)
+  let group='textGroup'.ft
+  if exists('b:current_syntax')
+    let s:current_syntax=b:current_syntax
+    " Remove current syntax definition, as some syntax files (e.g. cpp.vim)
+    " do nothing if b:current_syntax is defined.
+    unlet b:current_syntax
+  endif
+
+  " Some syntax files set up iskeyword which might scratch vimwiki a bit.
+  " Let us save and restore it later.
+  " let b:skip_set_iskeyword = 1
+  let is_keyword = &iskeyword
+
+  execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim'
+  try
+    execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim'
+  catch
+  endtry
+
+  let &iskeyword = is_keyword
+
+  if exists('s:current_syntax')
+    let b:current_syntax=s:current_syntax
+  else
+    unlet b:current_syntax
+  endif
+  execute 'syntax region textSnip'.ft.
+        \ ' matchgroup='.a:textSnipHl.
+        \ ' start="'.a:start.'" end="'.a:end.'"'.
+        \ ' contains=@'.group.' keepend'
+
+  " A workaround to Issue 115: Nested Perl syntax highlighting differs from
+  " regular one.
+  " Perl syntax file has perlFunctionName which is usually has no effect due to
+  " 'contained' flag. Now we have 'syntax include' that makes all the groups
+  " included as 'contained' into specific group.
+  " Here perlFunctionName (with quite an angry regexp "\h\w*[^:]") clashes with
+  " the rest syntax rules as now it has effect being really 'contained'.
+  " Clear it!
+  if ft =~ 'perl'
+    syntax clear perlFunctionName
+  endif
+endfunction "}}}
+
+"}}}
+
+" WIKI functions {{{
+function! vimwiki#find_next_link() "{{{
+  call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, '')
+endfunction
+" }}}
+
+function! vimwiki#find_prev_link() "{{{
+  call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, 'b')
+endfunction
+" }}}
+
+function! vimwiki#follow_link(split) "{{{
+  if a:split == "split"
+    let cmd = ":split "
+  elseif a:split == "vsplit"
+    let cmd = ":vsplit "
+  else
+    let cmd = ":e "
+  endif
+
+  let link = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWikiLink))
+  if link == ""
+    let weblink = s:strip_word(s:get_word_at_cursor(g:vimwiki_rxWeblink))
+    if weblink != ""
+      call VimwikiWeblinkHandler(escape(weblink, '#'))
+    else
+      execute "normal! \n"
+    endif
+    return
+  endif
+
+  let subdir = vimwiki#current_subdir()
+  call vimwiki#open_link(cmd, subdir.link)
+
+endfunction " }}}
+
+function! vimwiki#go_back_link() "{{{
+  if exists("b:vimwiki_prev_link")
+    " go back to saved WikiWord
+    let prev_word = b:vimwiki_prev_link
+    execute ":e ".substitute(prev_word[0], '\s', '\\\0', 'g')
+    call setpos('.', prev_word[1])
+  endif
+endfunction " }}}
+
+function! vimwiki#goto_index(index) "{{{
+  call vimwiki#select(a:index)
+  call vimwiki#mkdir(VimwikiGet('path'))
+
+  try
+    execute ':e '.fnameescape(
+          \ VimwikiGet('path').VimwikiGet('index').VimwikiGet('ext'))
+  catch /E37/ " catch 'No write since last change' error
+    execute ':split '.
+          \ VimwikiGet('path').
+          \ VimwikiGet('index').
+          \ VimwikiGet('ext')
+  catch /E325/ " catch 'ATTENTION' error (:h E325)
+  endtry
+endfunction "}}}
+
+function! vimwiki#delete_link() "{{{
+  "" file system funcs
+  "" Delete WikiWord you are in from filesystem
+  let val = input('Delete ['.expand('%').'] (y/n)? ', "")
+  if val != 'y'
+    return
+  endif
+  let fname = expand('%:p')
+  try
+    call delete(fname)
+  catch /.*/
+    echomsg 'vimwiki: Cannot delete "'.expand('%:t:r').'"!'
+    return
+  endtry
+  execute "bdelete! ".escape(fname, " ")
+
+  " reread buffer => deleted WikiWord should appear as non-existent
+  if expand('%:p') != ""
+    execute "e"
+  endif
+endfunction "}}}
+
+function! vimwiki#rename_link() "{{{
+  "" Rename WikiWord, update all links to renamed WikiWord
+  let subdir = vimwiki#current_subdir()
+  let old_fname = subdir.expand('%:t')
+
+  " there is no file (new one maybe)
+  if glob(expand('%:p')) == ''
+    echomsg 'vimwiki: Cannot rename "'.expand('%:p').
+          \'". It does not exist! (New file? Save it before renaming.)'
+    return
+  endif
+
+  let val = input('Rename "'.expand('%:t:r').'" (y/n)? ', "")
+  if val!='y'
+    return
+  endif
+
+  let new_link = input('Enter new name: ', "")
+
+  if new_link =~ '[/\\]'
+    " It is actually doable but I do not have free time to do it.
+    echomsg 'vimwiki: Cannot rename to a filename with path!'
+    return
+  endif
+
+  " check new_fname - it should be 'good', not empty
+  if substitute(new_link, '\s', '', 'g') == ''
+    echomsg 'vimwiki: Cannot rename to an empty filename!'
+    return
+  endif
+  if vimwiki#is_non_wiki_link(new_link)
+    echomsg 'vimwiki: Cannot rename to a filename with extension (ie .txt .html)!'
+    return
+  endif
+
+  let new_link = subdir.new_link
+  let new_link = s:strip_word(new_link)
+  let new_fname = VimwikiGet('path').s:filename(new_link).VimwikiGet('ext')
+
+  " do not rename if word with such name exists
+  let fname = glob(new_fname)
+  if fname != ''
+    echomsg 'vimwiki: Cannot rename to "'.new_fname.
+          \ '". File with that name exist!'
+    return
+  endif
+  " rename WikiWord file
+  try
+    echomsg "Renaming ".VimwikiGet('path').old_fname." to ".new_fname
+    let res = rename(expand('%:p'), expand(new_fname))
+    if res != 0
+      throw "Cannot rename!"
+    end
+  catch /.*/
+    echomsg 'vimwiki: Cannot rename "'.expand('%:t:r').'" to "'.new_fname.'"'
+    return
+  endtry
+
+  let &buftype="nofile"
+
+  let cur_buffer = [expand('%:p'),
+        \getbufvar(expand('%:p'), "vimwiki_prev_link")]
+
+  let blist = s:get_wiki_buffers()
+
+  " save wiki buffers
+  for bitem in blist
+    execute ':b '.escape(bitem[0], ' ')
+    execute ':update'
+  endfor
+
+  execute ':b '.escape(cur_buffer[0], ' ')
+
+  " remove wiki buffers
+  for bitem in blist
+    execute 'bwipeout '.escape(bitem[0], ' ')
+  endfor
+
+  let setting_more = &more
+  setlocal nomore
+
+  " update links
+  call s:update_wiki_links(old_fname, new_link)
+
+  " restore wiki buffers
+  for bitem in blist
+    if bitem[0] != cur_buffer[0]
+      call s:open_wiki_buffer(bitem)
+    endif
+  endfor
+
+  call s:open_wiki_buffer([new_fname,
+        \ cur_buffer[1]])
+  " execute 'bwipeout '.escape(cur_buffer[0], ' ')
+
+  echomsg old_fname." is renamed to ".new_fname
+
+  let &more = setting_more
+endfunction " }}}
+
+function! vimwiki#ui_select()"{{{
+  call s:print_wiki_list()
+  let idx = input("Select Wiki (specify number): ")
+  if idx == ""
+    return
+  endif
+  call vimwiki#goto_index(idx)
+endfunction
+"}}}
+
+" }}}
+
+" TEXT OBJECTS functions {{{
+
+function! vimwiki#TO_header(inner, visual) "{{{
+  if !search('^\(=\+\).\+\1\s*$', 'bcW')
+    return
+  endif
+
+  let sel_start = line("'<")
+  let sel_end = line("'>")
+  let block_start = line(".")
+  let advance = 0
+
+  let level = vimwiki#count_first_sym(getline('.'))
+
+  let is_header_selected = sel_start == block_start
+        \ && sel_start != sel_end
+
+  if a:visual && is_header_selected
+    if level > 1
+      let level -= 1
+      call search('^\(=\{'.level.'\}\).\+\1\s*$', 'bcW')
+    else
+      let advance = 1
+    endif
+  endif
+
+  normal! V
+
+  if a:visual && is_header_selected
+    call cursor(sel_end + advance, 0)
+  endif
+
+  if search('^\(=\{1,'.level.'}\).\+\1\s*$', 'W')
+    call cursor(line('.') - 1, 0)
+  else
+    call cursor(line('$'), 0)
+  endif
+
+  if a:inner && getline(line('.')) =~ '^\s*$'
+    let lnum = prevnonblank(line('.') - 1)
+    call cursor(lnum, 0)
+  endif
+endfunction
+"}}}
+
+function! vimwiki#TO_table_cell(inner, visual) "{{{
+  if col('.') == col('$')-1
+    return
+  endif
+
+  if a:visual
+    normal! `>
+    let sel_end = getpos('.')
+    normal! `<
+    let sel_start = getpos('.')
+
+    let firsttime = sel_start == sel_end
+
+    if firsttime
+      if !search('|\|\(-+-\)', 'cb', line('.'))
+        return
+      endif
+      if getline('.')[virtcol('.')] == '+'
+        normal! l
+      endif
+      if a:inner
+        normal! 2l
+      endif
+      let sel_start = getpos('.')
+    endif
+
+    normal! `>
+    call search('|\|\(-+-\)', '', line('.'))
+    if getline('.')[virtcol('.')] == '+'
+      normal! l
+    endif
+    if a:inner
+      if firsttime || abs(sel_end[2] - getpos('.')[2]) != 2
+        normal! 2h
+      endif
+    endif
+    let sel_end = getpos('.')
+
+    call setpos('.', sel_start)
+    exe "normal! \<C-v>"
+    call setpos('.', sel_end)
+
+    " XXX: WORKAROUND.
+    " if blockwise selection is ended at | character then pressing j to extend
+    " selection furhter fails. But if we shake the cursor left and right then
+    " it works.
+    normal! hl
+  else
+    if !search('|\|\(-+-\)', 'cb', line('.'))
+      return
+    endif
+    if a:inner
+      normal! 2l
+    endif
+    normal! v
+    call search('|\|\(-+-\)', '', line('.'))
+    if !a:inner && getline('.')[virtcol('.')-1] == '|'
+      normal! h
+    elseif a:inner
+      normal! 2h
+    endif
+  endif
+endfunction "}}}
+
+function! vimwiki#TO_table_col(inner, visual) "{{{
+  let t_rows = vimwiki_tbl#get_rows(line('.'))
+  if empty(t_rows)
+    return
+  endif
+
+  " TODO: refactor it!
+  if a:visual
+    normal! `>
+    let sel_end = getpos('.')
+    normal! `<
+    let sel_start = getpos('.')
+
+    let firsttime = sel_start == sel_end
+
+    if firsttime
+      " place cursor to the top row of the table
+      call s:cursor(t_rows[0][0], virtcol('.'))
+      " do not accept the match at cursor position if cursor is next to column
+      " separator of the table separator (^ is a cursor):
+      " |-----^-+-------|
+      " | bla   | bla   |
+      " |-------+-------|
+      " or it will select wrong column.
+      if strpart(getline('.'), virtcol('.')-1) =~ '^-+'
+        let s_flag = 'b'
+      else
+        let s_flag = 'cb'
+      endif
+      " search the column separator backwards
+      if !search('|\|\(-+-\)', s_flag, line('.'))
+        return
+      endif
+      " -+- column separator is matched --> move cursor to the + sign
+      if getline('.')[virtcol('.')] == '+'
+        normal! l
+      endif
+      " inner selection --> reduce selection
+      if a:inner
+        normal! 2l
+      endif
+      let sel_start = getpos('.')
+    endif
+
+    normal! `>
+    if !firsttime && getline('.')[virtcol('.')] == '|'
+      normal! l
+    elseif a:inner && getline('.')[virtcol('.')+1] =~ '[|+]'
+      normal! 2l
+    endif
+    " search for the next column separator
+    call search('|\|\(-+-\)', '', line('.'))
+    " Outer selection selects a column without border on the right. So we move
+    " our cursor left if the previous search finds | border, not -+-.
+    if getline('.')[virtcol('.')] != '+'
+      normal! h
+    endif
+    if a:inner
+      " reduce selection a bit more if inner.
+      normal! h
+    endif
+    " expand selection to the bottom line of the table
+    call s:cursor(t_rows[-1][0], virtcol('.'))
+    let sel_end = getpos('.')
+
+    call setpos('.', sel_start)
+    exe "normal! \<C-v>"
+    call setpos('.', sel_end)
+
+  else
+    " place cursor to the top row of the table
+    call s:cursor(t_rows[0][0], virtcol('.'))
+    " do not accept the match at cursor position if cursor is next to column
+    " separator of the table separator (^ is a cursor):
+    " |-----^-+-------|
+    " | bla   | bla   |
+    " |-------+-------|
+    " or it will select wrong column.
+    if strpart(getline('.'), virtcol('.')-1) =~ '^-+'
+      let s_flag = 'b'
+    else
+      let s_flag = 'cb'
+    endif
+    " search the column separator backwards
+    if !search('|\|\(-+-\)', s_flag, line('.'))
+      return
+    endif
+    " -+- column separator is matched --> move cursor to the + sign
+    if getline('.')[virtcol('.')] == '+'
+      normal! l
+    endif
+    " inner selection --> reduce selection
+    if a:inner
+      normal! 2l
+    endif
+
+    exe "normal! \<C-V>"
+
+    " search for the next column separator
+    call search('|\|\(-+-\)', '', line('.'))
+    " Outer selection selects a column without border on the right. So we move
+    " our cursor left if the previous search finds | border, not -+-.
+    if getline('.')[virtcol('.')] != '+'
+      normal! h
+    endif
+    " reduce selection a bit more if inner.
+    if a:inner
+      normal! h
+    endif
+    " expand selection to the bottom line of the table
+    call s:cursor(t_rows[-1][0], virtcol('.'))
+  endif
+endfunction "}}}
+
+function! vimwiki#count_first_sym(line) "{{{
+  let first_sym = matchstr(a:line, '\S')
+  return len(matchstr(a:line, first_sym.'\+'))
+endfunction "}}}
+
+function! vimwiki#AddHeaderLevel() "{{{
+  let lnum = line('.')
+  let line = getline(lnum)
+
+  if line =~ '^\s*$'
+    return
+  endif
+
+  if line =~ '^\s*\(=\+\).\+\1\s*$'
+    let level = vimwiki#count_first_sym(line)
+    if level < 6
+      let line = substitute(line, '\(=\+\).\+\1', '=&=', '')
+      call setline(lnum, line)
+    endif
+  else
+      let line = substitute(line, '^\s*', '&= ', '')
+      let line = substitute(line, '\s*$', ' =&', '')
+      call setline(lnum, line)
+  endif
+endfunction
+"}}}
+
+function! vimwiki#RemoveHeaderLevel() "{{{
+  let lnum = line('.')
+  let line = getline(lnum)
+
+  if line =~ '^\s*$'
+    return
+  endif
+
+  if line =~ '^\s*\(=\+\).\+\1\s*$'
+    let level = vimwiki#count_first_sym(line)
+    let old = repeat('=', level)
+    let new = repeat('=', level - 1)
+
+    let chomp = line =~ '=\s'
+
+    let line = substitute(line, old, new, 'g')
+
+    if level == 1 && chomp
+      let line = substitute(line, '^\s', '', 'g')
+      let line = substitute(line, '\s$', '', 'g')
+    endif
+    call setline(lnum, line)
+  endif
+endfunction
+" }}}
+
+" }}}

autoload/vimwiki_diary.vim

+" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
+" Vimwiki autoload plugin file
+" Desc: Handle diary notes
+" Author: Maxim Kim <habamax@gmail.com>
+" Home: http://code.google.com/p/vimwiki/
+
+" Load only once {{{
+if exists("g:loaded_vimwiki_diary_auto") || &cp
+  finish
+endif
+let g:loaded_vimwiki_diary_auto = 1
+"}}}
+
+function! s:prefix_zero(num) "{{{
+  if a:num < 10
+    return '0'.a:num
+  endif
+  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 "}}}
+
+function! s:link_exists(lines, link) "{{{
+  let link_exists = 0
+  for line in a:lines
+    if line =~ escape(a:link, '[]\')
+      let link_exists = 1
+      break
+    endif
+  endfor
+  return link_exists
+endfunction "}}}
+
+function! s:diary_path() "{{{
+  return VimwikiGet('path').VimwikiGet('diary_rel_path')
+endfunction "}}}
+
+function! s:diary_index() "{{{
+  return s:diary_path().VimwikiGet('diary_index').VimwikiGet('ext')
+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
+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()
+    " include 'today' into links
+    if index(links, s:diary_date_link()) == -1
+      call add(links, s:diary_date_link())
+    endif
+    call sort(links)
+    let idx = index(links, a:link)
+  endif
+  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, [''])
+
+  return lines
+endfunction "}}}
+
+function! s:add_link(page, header, link) "{{{
+  let [lines, bufnr] = s:get_file_contents(a:page)
+
+  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
+    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)
+    endif
+
+    let links = sort(links, 's:desc')
+    call extend(lines, s:format_links(links), ln_start)
+
+    if bufnr != -1
+      exe 'buffer '.bufnr
+      if !&readonly
+        1,$delete _
+        call append(1, lines)
+        1,1delete _
+      endif
+    else
+      call writefile(lines, expand(a:page))
+    endif
+  endif
+endfunction "}}}
+
+function! s:make_date_link(...) "{{{
+  if a:0
+    let link = a:1
+  else
+    let link = s:diary_date_link()
+  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#select(a:index)
+  call vimwiki#mkdir(VimwikiGet('path').VimwikiGet('diary_rel_path'))
+  if a:0
+    let link = s:make_date_link(a:1)
+  else
+    let link = s:make_date_link()
+  endif
+  call vimwiki#open_link(':e ', link, s:diary_index())
+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)
+
+  let link = a:year.'-'.month.'-'.day
+  if winnr('#') == 0
+    if a:dir == 'V'
+      vsplit
+    else
+      split
+    endif
+  else
+    wincmd p
+    if !&hidden && &modified
+      new
+    endif
+  endif
+
+  " Create diary note for a selected date in default wiki.
+  call vimwiki_diary#make_note(1, link)
+endfunction "}}}
+
+" Calendar.vim sign function.
+function vimwiki_diary#calendar_sign(day, month, year) "{{{
+  let day = s:prefix_zero(a:day)
+  let month = s:prefix_zero(a:month)
+  let sfile = VimwikiGet('path').VimwikiGet('diary_rel_path').
+        \ a:year.'-'.month.'-'.day.VimwikiGet('ext')
+  return filereadable(expand(sfile))
+endfunction "}}}
+
+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 = 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#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#open_link(':e ', link)
+  endif
+endfunction "}}}

autoload/vimwiki_html.vim

+" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
+" Vimwiki autoload plugin file
+" Export to HTML
+" Author: Maxim Kim <habamax@gmail.com>
+" Home: http://code.google.com/p/vimwiki/
+
+" XXX: This file should be refactored!
+
+" Load only once {{{
+if exists("g:loaded_vimwiki_html_auto") || &cp
+  finish
+endif
+let g:loaded_vimwiki_html_auto = 1
+"}}}
+
+" SCRIPT VARS "{{{
+" Warn if html header or html footer do not exist only once.
+let s:warn_html_header = 0
+let s:warn_html_footer = 0
+"}}}
+
+" UTILITY "{{{
+function! s:root_path(subdir) "{{{
+  return repeat('../', len(split(a:subdir, '[/\\]')))
+endfunction "}}}
+
+function! s:syntax_supported() " {{{
+  return VimwikiGet('syntax') == "default"
+endfunction " }}}
+
+function! s:remove_blank_lines(lines) " {{{
+  while !empty(a:lines) && a:lines[-1] =~ '^\s*$'
+    call remove(a:lines, -1)
+  endwhile
+endfunction "}}}
+
+function! s:is_web_link(lnk) "{{{
+  if a:lnk =~ '^\%(https://\|http://\|www.\|ftp://\|file://\)'
+    return 1
+  endif
+  return 0
+endfunction "}}}
+
+function! s:is_img_link(lnk) "{{{
+  if a:lnk =~ '\.\%(png\|jpg\|gif\|jpeg\)$'
+    return 1
+  endif
+  return 0
+endfunction "}}}
+
+function! s:has_abs_path(fname) "{{{
+  if a:fname =~ '\(^.:\)\|\(^/\)'
+    return 1
+  endif
+  return 0
+endfunction "}}}
+
+function! s:create_default_CSS(path) " {{{
+  let path = expand(a:path)
+  let css_full_name = path.VimwikiGet('css_name')
+  if glob(css_full_name) == ""
+    call vimwiki#mkdir(fnamemodify(css_full_name, ':p:h'))
+    let lines = []
+
+    call add(lines, 'body {font-family: Tahoma, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}')
+    call add(lines, 'h1, h2, h3, h4, h5, h6 {font-family: Trebuchet MS, serif; margin-top: 1.5em; margin-bottom: 0.5em;}')
+    call add(lines, 'h1 {font-size: 2.0em; color: #a77070;}')
+    call add(lines, 'h2 {font-size: 1.6em; color: #779977;}')
+    call add(lines, 'h3 {font-size: 1.3em; color: #555577;}')
+    call add(lines, 'h4 {font-size: 1.2em; color: #222244;}')
+    call add(lines, 'h5 {font-size: 1.1em; color: #222244;}')
+    call add(lines, 'h6 {font-size: 1.0em; color: #222244;}')
+    call add(lines, 'p, pre, blockquote, table, ul, ol, dl {margin-top: 1em; margin-bottom: 1em;}')
+    call add(lines, 'ul ul, ul ol, ol ol, ol ul {margin-top: 0.5em; margin-bottom: 0.5em;}')
+    call add(lines, 'li {margin: 0.3em auto;}')
+    call add(lines, 'ul {margin-left: 2em; padding-left: 0.5em;}')
+    call add(lines, 'dt {font-weight: bold;}')
+    call add(lines, 'img {border: none;}')
+    call add(lines, 'pre {border-left: 1px solid #ccc; margin-left: 2em; padding-left: 0.5em;}')
+    call add(lines, 'blockquote {padding: 0.4em; background-color: #f6f5eb;}')
+    call add(lines, 'th, td {border: 1px solid #ccc; padding: 0.3em;}')
+    call add(lines, 'th {background-color: #f0f0f0;}')
+    call add(lines, 'hr {border: none; border-top: 1px solid #ccc; width: 100%;}')
+    call add(lines, 'del {text-decoration: line-through; color: #777777;}')
+    call add(lines, '.toc li {list-style-type: none;}')
+    call add(lines, '.todo {font-weight: bold; background-color: #f0ece8; color: #a03020;}')
+    call add(lines, '.justleft {text-align: left;}')
+    call add(lines, '.justright {text-align: right;}')
+    call add(lines, '.justcenter {text-align: center;}')
+    call add(lines, '.center {margin-left: auto; margin-right: auto;}')
+
+    call writefile(lines, css_full_name)
+    echomsg "Default style.css is created."
+  endif
+endfunction "}}}
+
+function! s:get_html_header(title, subdir, charset) "{{{
+  let lines=[]
+
+  if VimwikiGet('html_header') != "" && !s:warn_html_header
+    try
+      let lines = readfile(expand(VimwikiGet('html_header')))
+      call map(lines, 'substitute(v:val, "%title%", "'. a:title .'", "g")')
+      call map(lines, 'substitute(v:val, "%root_path%", "'.
+            \ s:root_path(a:subdir) .'", "g")')
+      return lines
+    catch /E484/
+      let s:warn_html_header = 1
+      echomsg 'vimwiki: Header template '.VimwikiGet('html_header').
+            \ ' does not exist!'
+    endtry
+  endif
+
+  let css_name = expand(VimwikiGet('css_name'))
+  let css_name = substitute(css_name, '\', '/', 'g')
+  if !s:has_abs_path(css_name)
+    " Relative css file for deep links: [[dir1/dir2/dir3/filename]]
+    let css_name = s:root_path(a:subdir).css_name
+  endif
+
+  " if no VimwikiGet('html_header') set up or error while reading template
+  " file -- use default header.
+  call add(lines, '<html>')
+  call add(lines, '<head>')
+  call add(lines, '<link rel="Stylesheet" type="text/css" href="'.
+        \ css_name.'" />')
+  call add(lines, '<title>'.a:title.'</title>')
+  call add(lines, '<meta http-equiv="Content-Type" content="text/html;'.
+        \ ' charset='.a:charset.'" />')
+  call add(lines, '</head>')
+  call add(lines, '<body>')
+
+  return lines
+endfunction "}}}
+
+function! s:get_html_footer() "{{{
+  let lines=[]
+
+  if VimwikiGet('html_footer') != "" && !s:warn_html_footer
+    try
+      let lines = readfile(expand(VimwikiGet('html_footer')))
+      return lines
+    catch /E484/
+      let s:warn_html_footer = 1
+      echomsg 'vimwiki: Footer template '.VimwikiGet('html_footer').
+            \ ' does not exist!'
+    endtry
+  endif
+
+  " if no VimwikiGet('html_footer') set up or error while reading template
+  " file -- use default footer.
+  call add(lines, "")
+  call add(lines, '</body>')
+  call add(lines, '</html>')
+
+  return lines
+endfunction "}}}
+
+function! s:safe_html(line) "{{{
+  "" htmlize symbols: < > &
+
+  let line = substitute(a:line, '&', '\&amp;', '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 "}}}
+
+function! s:delete_html_files(path) "{{{
+  let htmlfiles = split(glob(a:path.'**/*.html'), '\n')
+  for fname in htmlfiles
+    try
+      call delete(fname)
+    catch
+      echomsg 'vimwiki: Cannot delete '.fname
+    endtry
+  endfor
+endfunction "}}}
+
+function! s:remove_comments(lines) "{{{
+  let res = []
+  let multiline_comment = 0
+
+  let idx = 0
+  while idx < len(a:lines)
+    let line = a:lines[idx]
+    let idx += 1
+
+    if multiline_comment
+      let col = matchend(line, '-->',)
+      if col != -1
+        let multiline_comment = 0
+        let line = strpart(line, col)
+      else
+        continue
+      endif
+    endif
+
+    if !multiline_comment && line =~ '<!--.*-->'
+      let line = substitute(line, '<!--.*-->', '', 'g')
+      if line =~ '^\s*$'
+        continue
+      endif
+    endif
+
+    if !multiline_comment
+      let col = match(line, '<!--',)
+      if col != -1
+        let multiline_comment = 1
+        let line = strpart(line, 1, col - 1)
+      endif
+    endif
+
+    call add(res, line)
+  endwhile
+  return res
+endfunction "}}}
+
+function! s:mid(value, cnt) "{{{
+  return strpart(a:value, a:cnt, len(a:value) - 2 * a:cnt)
+endfunction "}}}
+
+function! s:subst_func(line, regexp, func) " {{{
+  " Substitute text found by regexp with result of
+  " func(matched) function.
+
+  let pos = 0
+  let lines = split(a:line, a:regexp, 1)
+  let res_line = ""
+  for line in lines
+    let res_line = res_line.line
+    let matched = matchstr(a:line, a:regexp, pos)
+    if matched != ""
+      let res_line = res_line.{a:func}(matched)
+    endif
+    let pos = matchend(a:line, a:regexp, pos)
+  endfor
+  return res_line
+endfunction " }}}
+
+function! s:save_vimwiki_buffer() "{{{
+  if &filetype == 'vimwiki'
+    silent update
+  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"], ...]
+  function! s:close_list(toc, plevel, level) "{{{
+    let plevel = a:plevel
+    while plevel > a:level
+      call add(a:toc, '</ul>')
+      let plevel -= 1
+    endwhile
+    return plevel
+  endfunction "}}}
+
+  if empty(a:toc_list)
+    return []
+  endif
+
+  let toc = ['<div class="toc">']
+  let level = 0
+  let plevel = 0
+  for [level, text, id] in a:toc_list
+    if level > plevel
+      call add(toc, '<ul>')
+    elseif level < plevel
+      let plevel = s:close_list(toc, plevel, level)
+    endif
+
+    let toc_text = s:process_tags_remove_links(text)
+    let toc_text = s:process_tags_typefaces(toc_text)
+    call add(toc, '<li><a href="#'.id.'">'.toc_text.'</a></li>')
+    let plevel = level
+  endfor
+  call s:close_list(toc, level, 0)
+  call add(toc, '</div>')
+  return toc
+endfunction "}}}
+
+" insert toc into dest.
+function! s:process_toc(dest, placeholders, toc) "{{{
+  if !empty(a:placeholders)
+    for [placeholder, row, idx] in a:placeholders
+      let [type, param] = placeholder
+      if type == 'toc'
+        let toc = a:toc[:]
+        if !empty(param)
+          call insert(toc, '<h1>'.param.'</h1>')
+        endif
+        let shift = idx * len(toc)
+        call extend(a:dest, toc, row + shift)
+      endif
+    endfor
+  endif
+endfunction "}}}
+
+" get title.
+function! s:process_title(placeholders, default_title) "{{{
+  if !empty(a:placeholders)
+    for [placeholder, row, idx] in a:placeholders
+      let [type, param] = placeholder
+      if type == 'title' && !empty(param)
+        return param
+      endif
+    endfor
+  endif
+  return a:default_title
+endfunction "}}}
+
+"}}}
+
+" INLINE TAGS "{{{
+function! s:tag_em(value) "{{{
+  return '<em>'.s:mid(a:value, 1).'</em>'
+endfunction "}}}
+
+function! s:tag_strong(value) "{{{
+  return '<strong>'.s:mid(a:value, 1).'</strong>'
+endfunction "}}}
+
+function! s:tag_todo(value) "{{{
+  return '<span class="todo">'.a:value.'</span>'
+endfunction "}}}
+
+function! s:tag_strike(value) "{{{
+  return '<del>'.s:mid(a:value, 2).'</del>'
+endfunction "}}}
+
+function! s:tag_super(value) "{{{
+  return '<sup><small>'.s:mid(a:value, 1).'</small></sup>'
+endfunction "}}}
+
+function! s:tag_sub(value) "{{{
+  return '<sub><small>'.s:mid(a:value, 2).'</small></sub>'
+endfunction "}}}
+
+function! s:tag_code(value) "{{{
+  return '<code>'.s:mid(a:value, 1).'</code>'
+endfunction "}}}
+
+function! s:tag_pre(value) "{{{
+  return '<code>'.s:mid(a:value, 3).'</code>'
+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! 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#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#is_link_to_dir(a:src)
+      if g:vimwiki_dir_link == ''
+        let link = '<a href="'.vimwiki#safe_link(a:src).'">'.a:caption.'</a>'
+      else
+        let link = '<a href="'.vimwiki#safe_link(a:src).
+              \ g:vimwiki_dir_link.'.html">'.a:caption.'</a>'
+      endif
+    else
+      let link = '<a href="'.vimwiki#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
+  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
+    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>'
+    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
+  endif
+endfunction "}}}
+
+function! s:tag_remove_internal_link(value) "{{{
+  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 = link_parts[1]
+  else
+    let line = value
+  endif
+  return line
+endfunction "}}}
+
+function! s:tag_remove_external_link(value) "{{{
+  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
+    endif
+    let line = rest
+  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:make_tag(line, regexp, func) "{{{
+  " Make tags for a given matched regexp.
+  " Exclude preformatted text and href links.
+
+  let patt_splitter = '\(`[^`]\+`\)\|\({{{.\+}}}\)\|'.
+        \ '\(<a href.\{-}</a>\)\|\(<img src.\{-}/>\)'
+  if '`[^`]\+`' == a:regexp || '{{{.\+}}}' == a:regexp
+    let res_line = s:subst_func(a:line, a:regexp, a:func)
+  else
+    let pos = 0
+    " split line with patt_splitter to have parts of line before and after
+    " href links, preformatted text
+    " ie:
+    " hello world `is just a` simple <a href="link.html">type of</a> prg.
+    " result:
+    " ['hello world ', ' simple ', 'type of', ' prg']
+    let lines = split(a:line, patt_splitter, 1)
+    let res_line = ""
+    for line in lines
+      let res_line = res_line.s:subst_func(line, a:regexp, a:func)
+      let res_line = res_line.matchstr(a:line, patt_splitter, pos)
+      let pos = matchend(a:line, patt_splitter, pos)
+    endfor
+  endif
+  return res_line
+endfunction "}}}
+
+function! s:process_tags_remove_links(line) " {{{
+  let line = a:line
+  let line = s:make_tag(line, '\[\[.\{-}\]\]', 's:tag_remove_internal_link')
+  let line = s:make_tag(line, '\[.\{-}\]', 's:tag_remove_external_link')
+  return line
+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')
+  let line = s:make_tag(line, g:vimwiki_rxDelText, 's:tag_strike')
+  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_rxPreStart.'.\+'.g:vimwiki_rxPreEnd,
+        \ 's:tag_pre')
+  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')
+  return line
+endfunction " }}}
+
+function! s:process_inline_tags(line) "{{{
+  let line = s:process_tags_links(a:line)
+  let line = s:process_tags_typefaces(line)
+  return line
+endfunction " }}}
+"}}}
+
+" BLOCK TAGS {{{
+function! s:close_tag_pre(pre, ldest) "{{{
+  if a:pre[0]
+    call insert(a:ldest, "</pre>")
+    return 0
+  endif
+  return a:pre
+endfunction "}}}
+
+function! s:close_tag_quote(quote, ldest) "{{{
+  if a:quote
+    call insert(a:ldest, "</blockquote>")
+    return 0
+  endif
+  return a:quote
+endfunction "}}}
+
+function! s:close_tag_para(para, ldest) "{{{
+  if a:para
+    call insert(a:ldest, "</p>")
+    return 0
+  endif
+  return a:para
+endfunction "}}}
+
+function! s:close_tag_table(table, ldest) "{{{
+  " The first element of table list is a string which tells us if table should be centered.
+  " The rest elements are rows which are lists of columns:
+  " ['center',
+  "   ['col1', 'col2', 'col3'],
+  "   ['col1', 'col2', 'col3'],
+  "   ['col1', 'col2', 'col3']
+  " ]
+  let table = a:table
+  let ldest = a:ldest
+  if len(table)
+    if table[0] == 'center'
+      call add(ldest, "<table class='center'>")
+    else
+      call add(ldest, "<table>")
+    endif
+
+    " Empty lists are table separators.
+    " Search for the last empty list. All the above rows would be a table header.
+    " We should exclude the first element of the table list as it is a text tag
+    " that shows if table should be centered or not.
+    let head = 0
+    for idx in range(len(table)-1, 1, -1)
+      if empty(table[idx])
+        let head = idx
+        break
+      endif
+    endfor
+    if head > 0
+      for row in table[1 : head-1]
+        if !empty(filter(row, '!empty(v:val)'))
+          call add(ldest, '<tr>')
+          call extend(ldest, map(row, '"<th>".s:process_inline_tags(v:val)."</th>"'))
+          call add(ldest, '</tr>')
+        endif
+      endfor
+      for row in table[head+1 :]
+        call add(ldest, '<tr>')
+        call extend(ldest, map(row, '"<td>".s:process_inline_tags(v:val)."</td>"'))
+        call add(ldest, '</tr>')
+      endfor
+    else
+      for row in table[1 :]
+        call add(ldest, '<tr>')
+        call extend(ldest, map(row, '"<td>".s:process_inline_tags(v:val)."</td>"'))
+        call add(ldest, '</tr>')
+      endfor
+    endif
+    call add(ldest, "</table>")
+    let table = []
+  endif
+  return table
+endfunction "}}}
+
+function! s:close_tag_list(lists, ldest) "{{{
+  while len(a:lists)
+    let item = remove(a:lists, 0)
+    call insert(a:ldest, item[0])
+  endwhile
+endfunction! "}}}
+
+function! s:close_tag_def_list(deflist, ldest) "{{{
+  if a:deflist
+    call insert(a:ldest, "</dl>")
+    return 0
+  endif
+  return a:deflist
+endfunction! "}}}
+
+function! s:process_tag_pre(line, pre) "{{{
+  " pre is the list of [is_in_pre, indent_of_pre]
+  let lines = []
+  let pre = a:pre
+  let processed = 0
+  if !pre[0] && a:line =~ '^\s*{{{[^\(}}}\)]*\s*$'
+    let class = matchstr(a:line, '{{{\zs.*$')
+    let class = substitute(class, '\s\+$', '', 'g')
+    if class != ""
+      call add(lines, "<pre ".class.">")
+    else
+      call add(lines, "<pre>")
+    endif
+    let pre = [1, len(matchstr(a:line, '^\s*\ze{{{'))]
+    let processed = 1
+  elseif pre[0] && a:line =~ '^\s*}}}\s*$'
+    let pre = [0, 0]
+    call add(lines, "</pre>")
+    let processed = 1
+  elseif pre[0]
+    let processed = 1
+    call add(lines, substitute(a:line, '^\s\{'.pre[1].'}', '', ''))
+  endif
+  return [processed, lines, pre]
+endfunction "}}}
+
+function! s:process_tag_quote(line, quote) "{{{
+  let lines = []
+  let quote = a:quote
+  let processed = 0
+  if a:line =~ '^\s\{4,}\S'
+    if !quote
+      call add(lines, "<blockquote>")
+      let quote = 1
+    endif
+    let processed = 1
+    call add(lines, substitute(a:line, '^\s*', '', ''))
+  elseif quote
+    call add(lines, "</blockquote>")
+    let quote = 0
+  endif
+  return [processed, lines, quote]
+endfunction "}}}
+
+function! s:process_tag_list(line, lists) "{{{
+
+  function! s:add_checkbox(line, rx_list, st_tag, en_tag) "{{{
+    let st_tag = a:st_tag
+    let en_tag = a:en_tag
+
+    let chk = matchlist(a:line, a:rx_list)
+    if len(chk) > 0
+      if chk[1] == g:vimwiki_listsyms[4]
+        let st_tag .= '<del><input type="checkbox" checked />'
+        let en_tag = '</del>'.a:en_tag
+      else
+        let st_tag .= '<input type="checkbox" />'
+      endif
+    endif
+    return [st_tag, en_tag]
+  endfunction "}}}
+
+  let in_list = (len(a:lists) > 0)
+
+  " If it is not list yet then do not process line that starts from *bold*