Version 1.2
= Note = Remove previous version of vimwiki before install - files in autoload dir is moved/renamed to autoload/vimwiki dir. = Changelog = * Issue 70: Table spanning cell support. * Issue 72: Do not convert again for unchanged file. |:VimwikiAll2HTML| converts only changed wiki files. * Issue 117: |VimwikiDiaryIndex| command that opens diary index wiki page. * Issue 120: Links in headers are not highlighted in vimwiki but are highlighted in HTML. * Issue 138: Added possibility to remap table-column move bindings. See |:VimwikiTableMoveColumnLeft| and |:VimwikiTableMoveColumnRight| commands. For remap instructions see |vimwiki_<A-Left>| and |vimwiki_<A-Right>|. * Issue 125: Problem with 'o' command given while at the of the file. * Issue 131: FileType is not set up when GUIEnter autocommand is used in vimrc. Use 'nested' in 'au GUIEnter * nested VimwikiIndex' * Issue 132: Link to perl (or any non-wiki) file in vimwiki subdirectory doesn't work as intended. * Issue 135: %title and %toc used together cause TOC to appear in an unexpected place in HTML. * Issue 139: |:VimwikiTabnewLink| command is added. * Fix of g:vimwiki_stripsym = '' (i.e. an empty string) -- it removes bad symbols from filenames. * Issue 145: With modeline 'set ft=vimwiki' links are not correctly highlighted when open wiki files. * Issue 146: Filetype difficulty with ".txt" as a vimwiki extension. * Issue 148: There are no mailto links. * Issue 151: Use location list instead of quickfix list for :VimwikiSearch command result. Use :lopen instead of :copen, :lnext instead of :cnext etc. * Issue 152: Add the list of HTML files that would not be deleted after |:VimwikiAll2HTML|. * Issue 153: Delete HTML files that has no corresponding wiki ones with |:VimwikiAll2HTML|. * Issue 156: Add multiple HTML templates. See |vimwiki-option-template_path|. Options html_header and html_footer are no longer exist. * Issue 173: When virtualedit=all option is enabled the 'o' command behave strange. * Issue 178: Problem with alike wikie's paths. * Issue 182: Browser command does not quote url. * Issue 183: Spelling error highlighting is not possible with nested syntaxes. * Issue 184: Wrong foldlevel in some cases. * Issue 195: Page renaming issue. * Issue 196: vim: modeline bug -- syn=vim doesn't work. * Issue 199: Generated HTML for sublists is invalid. * Issue 200: Generated HTML for todo lists does not show completion status the fix relies on CSS, thus your old stylesheets need to be updated!; may not work in obsolete browsers or font-deficient systems. * Issue 205: Block code: highlighting differs from processing. Inline code block {{{ ... }}} is removed. Use `...` instead. * Issue 208: Default highlight colors are problematic in many colorschemes. Headers are highlighted as |hl-Title| by default, use |g:vimwiki_hl_headers| to restore previous default Red, Green, Blue or custom header colors. Some other changes in highlighting. * Issue 209: Wild comments slow down html generation. Comments are changed, use %% to comment out entire line. * Issue 210: HTML: para enclose header. * Issue 214: External links containing Chinese characters get trimmed. * Issue 218: Command to generate HTML file and open it in webbrowser. See |:Vimwiki2HTMLBrowse|(bind to <leader>whh) * NEW: Added <Leader>wh mapping to call |:Vimwiki2HTML|
This commit is contained in:
@ -18,14 +18,18 @@ let s:badsymbols = '['.g:vimwiki_badsyms.g:vimwiki_stripsym.'<>|?*:"]'
|
||||
|
||||
" MISC helper functions {{{
|
||||
|
||||
function! vimwiki#chomp_slash(str) "{{{
|
||||
function! vimwiki#base#chomp_slash(str) "{{{
|
||||
return substitute(a:str, '[/\\]\+$', '', '')
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#mkdir(path) "{{{
|
||||
function! vimwiki#base#path_norm(path) "{{{
|
||||
return substitute(a:path, '\', '/', 'g')
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#base#mkdir(path) "{{{
|
||||
let path = expand(a:path)
|
||||
if !isdirectory(path) && exists("*mkdir")
|
||||
let path = vimwiki#chomp_slash(path)
|
||||
let path = vimwiki#base#chomp_slash(path)
|
||||
if s:is_windows() && !empty(g:vimwiki_w32_dir_enc)
|
||||
let path = iconv(path, &enc, g:vimwiki_w32_dir_enc)
|
||||
endif
|
||||
@ -34,17 +38,30 @@ function! vimwiki#mkdir(path) "{{{
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
function! vimwiki#safe_link(string) "{{{
|
||||
return substitute(a:string, s:badsymbols, g:vimwiki_stripsym, 'g')
|
||||
function! vimwiki#base#safe_link(link) "{{{
|
||||
" handling Windows absolute paths
|
||||
if a:link =~ '^[[:alpha:]]:[/\\].*'
|
||||
let link_start = a:link[0 : 2]
|
||||
let link = a:link[3 : ]
|
||||
else
|
||||
let link_start = ''
|
||||
let link = a:link
|
||||
endif
|
||||
let link = substitute(link, s:badsymbols, g:vimwiki_stripsym, 'g')
|
||||
return link_start.link
|
||||
endfunction
|
||||
"}}}
|
||||
|
||||
function! vimwiki#unsafe_link(string) "{{{
|
||||
return substitute(a:string, g:vimwiki_stripsym, s:badsymbols, 'g')
|
||||
function! vimwiki#base#unsafe_link(string) "{{{
|
||||
if len(g:vimwiki_stripsym) > 0
|
||||
return substitute(a:string, g:vimwiki_stripsym, s:badsymbols, 'g')
|
||||
else
|
||||
return a:string
|
||||
endif
|
||||
endfunction
|
||||
"}}}
|
||||
|
||||
function! vimwiki#subdir(path, filename)"{{{
|
||||
function! vimwiki#base#subdir(path, filename)"{{{
|
||||
let path = expand(a:path)
|
||||
let filename = expand(a:filename)
|
||||
let idx = 0
|
||||
@ -60,13 +77,17 @@ function! vimwiki#subdir(path, filename)"{{{
|
||||
return res
|
||||
endfunction"}}}
|
||||
|
||||
function! vimwiki#current_subdir()"{{{
|
||||
return vimwiki#subdir(VimwikiGet('path'), expand('%:p'))
|
||||
function! vimwiki#base#current_subdir()"{{{
|
||||
return vimwiki#base#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)
|
||||
function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
if vimwiki#base#is_non_wiki_link(a:link)
|
||||
if s:is_path_absolute(a:link)
|
||||
call vimwiki#base#edit_file(a:cmd, a:link)
|
||||
else
|
||||
call vimwiki#base#edit_file(a:cmd, VimwikiGet('path').a:link)
|
||||
endif
|
||||
else
|
||||
if a:0
|
||||
let vimwiki_prev_link = [a:1, []]
|
||||
@ -74,17 +95,17 @@ function! vimwiki#open_link(cmd, link, ...) "{{{
|
||||
let vimwiki_prev_link = [expand('%:p'), getpos('.')]
|
||||
endif
|
||||
|
||||
if vimwiki#is_link_to_dir(a:link)
|
||||
if vimwiki#base#is_link_to_dir(a:link)
|
||||
if g:vimwiki_dir_link == ''
|
||||
call s:edit_file(a:cmd, VimwikiGet('path').a:link)
|
||||
call vimwiki#base#edit_file(a:cmd, VimwikiGet('path').a:link)
|
||||
else
|
||||
call s:edit_file(a:cmd,
|
||||
call vimwiki#base#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'))
|
||||
call vimwiki#base#edit_file(a:cmd, VimwikiGet('path').a:link.VimwikiGet('ext'))
|
||||
endif
|
||||
|
||||
if exists('vimwiki_prev_link')
|
||||
@ -94,7 +115,7 @@ function! vimwiki#open_link(cmd, link, ...) "{{{
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
function! vimwiki#select(wnum)"{{{
|
||||
function! vimwiki#base#select(wnum)"{{{
|
||||
if a:wnum < 1 || a:wnum > len(g:vimwiki_list)
|
||||
return
|
||||
endif
|
||||
@ -105,7 +126,7 @@ function! vimwiki#select(wnum)"{{{
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
function! vimwiki#generate_links()"{{{
|
||||
function! vimwiki#base#generate_links()"{{{
|
||||
let links = s:get_links('*'.VimwikiGet('ext'))
|
||||
|
||||
" We don't want link to itself.
|
||||
@ -127,8 +148,8 @@ function! vimwiki#generate_links()"{{{
|
||||
endfor
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki#goto(key) "{{{
|
||||
call s:edit_file(':e',
|
||||
function! vimwiki#base#goto(key) "{{{
|
||||
call vimwiki#base#edit_file(':e',
|
||||
\ VimwikiGet('path').
|
||||
\ a:key.
|
||||
\ VimwikiGet('ext'))
|
||||
@ -138,9 +159,13 @@ function! s:is_windows() "{{{
|
||||
return has("win32") || has("win64") || has("win95") || has("win16")
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_path_absolute(path) "{{{
|
||||
return a:path =~ '^/.*' || a:path =~ '^[[:alpha:]]:[/\\].*'
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_links(pat) "{{{
|
||||
" search all wiki files in 'path' and its subdirs.
|
||||
let subdir = vimwiki#current_subdir()
|
||||
let subdir = vimwiki#base#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
|
||||
@ -173,11 +198,11 @@ function! s:cursor(lnum, cnum) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:filename(link) "{{{
|
||||
let result = vimwiki#safe_link(a:link)
|
||||
let result = vimwiki#base#safe_link(a:link)
|
||||
if a:link =~ '|'
|
||||
let result = vimwiki#safe_link(split(a:link, '|')[0])
|
||||
let result = vimwiki#base#safe_link(split(a:link, '|')[0])
|
||||
elseif a:link =~ ']['
|
||||
let result = vimwiki#safe_link(split(a:link, '][')[0])
|
||||
let result = vimwiki#base#safe_link(split(a:link, '][')[0])
|
||||
endif
|
||||
return result
|
||||
endfunction
|
||||
@ -191,10 +216,15 @@ function! s:is_wiki_word(str) "{{{
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
function! s:edit_file(command, filename) "{{{
|
||||
function! vimwiki#base#edit_file(command, filename) "{{{
|
||||
let fname = escape(a:filename, '% ')
|
||||
call vimwiki#mkdir(fnamemodify(a:filename, ":p:h"))
|
||||
execute a:command.' '.fname
|
||||
call vimwiki#base#mkdir(fnamemodify(a:filename, ":p:h"))
|
||||
try
|
||||
execute a:command.' '.fname
|
||||
catch /E37/ " catch 'No write since last change' error
|
||||
execute ':split '.fname
|
||||
catch /E325/ " catch 'ATTENTION' error (:h E325)
|
||||
endtry
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
@ -242,13 +272,13 @@ function! s:strip_word(word) "{{{
|
||||
let w = split(w, "][")[0]
|
||||
endif
|
||||
|
||||
let result = vimwiki#safe_link(w)
|
||||
let result = vimwiki#base#safe_link(w)
|
||||
endif
|
||||
return result
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
function! vimwiki#is_non_wiki_link(lnk) "{{{
|
||||
function! vimwiki#base#is_non_wiki_link(lnk) "{{{
|
||||
let exts = '.\+\.\%('.
|
||||
\ join(split(g:vimwiki_file_exts, '\s*,\s*'), '\|').
|
||||
\ '\)$'
|
||||
@ -258,7 +288,7 @@ function! vimwiki#is_non_wiki_link(lnk) "{{{
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#is_link_to_dir(link) "{{{
|
||||
function! vimwiki#base#is_link_to_dir(link) "{{{
|
||||
" Check if link is to a directory.
|
||||
" It should be ended with \ or /.
|
||||
if a:link =~ '.\+[/\\]$'
|
||||
@ -314,10 +344,10 @@ function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{
|
||||
endif
|
||||
|
||||
if !s:is_wiki_word(old_fname)
|
||||
let old_fname_r = '\[\[\zs'.vimwiki#unsafe_link(old_fname).
|
||||
let old_fname_r = '\[\[\zs'.vimwiki#base#unsafe_link(old_fname).
|
||||
\ '\ze\%(|.*\)\?\%(\]\[.*\)\?\]\]'
|
||||
else
|
||||
let old_fname_r = '\<'.old_fname.'\>'
|
||||
let old_fname_r = '!\@<!\<'.old_fname.'\>'
|
||||
endif
|
||||
|
||||
let files = split(glob(VimwikiGet('path').a:dir.'*'.VimwikiGet('ext')), '\n')
|
||||
@ -383,7 +413,7 @@ function! s:get_wiki_buffers() "{{{
|
||||
endfunction " }}}
|
||||
|
||||
function! s:open_wiki_buffer(item) "{{{
|
||||
call s:edit_file('e', a:item[0])
|
||||
call vimwiki#base#edit_file(':e', a:item[0])
|
||||
if !empty(a:item[1])
|
||||
call setbufvar(a:item[0], "vimwiki_prev_link", a:item[1])
|
||||
endif
|
||||
@ -392,7 +422,7 @@ endfunction " }}}
|
||||
" }}}
|
||||
|
||||
" SYNTAX highlight {{{
|
||||
function! vimwiki#highlight_links() "{{{
|
||||
function! vimwiki#base#highlight_links() "{{{
|
||||
try
|
||||
syntax clear VimwikiNoExistsLink
|
||||
syntax clear VimwikiNoExistsLinkT
|
||||
@ -442,21 +472,21 @@ function! s:highlight_existed_links() "{{{
|
||||
|
||||
for link in links
|
||||
if g:vimwiki_camel_case &&
|
||||
\ link =~ g:vimwiki_rxWikiWord && !vimwiki#is_non_wiki_link(link)
|
||||
\ link =~ g:vimwiki_rxWikiWord && !vimwiki#base#is_non_wiki_link(link)
|
||||
execute 'syntax match VimwikiLink /!\@<!\<'.link.'\>/ display'
|
||||
endif
|
||||
execute 'syntax match VimwikiLink /\[\['.
|
||||
\ escape(vimwiki#unsafe_link(link), '~&$.*').
|
||||
\ escape(vimwiki#base#unsafe_link(link), '~&$.*').
|
||||
\ '\%(|\+.\{-}\)\{-}\]\]/ display contains=VimwikiLinkChar'
|
||||
execute 'syntax match VimwikiLink /\[\['.
|
||||
\ escape(vimwiki#unsafe_link(link), '~&$.*').
|
||||
\ escape(vimwiki#base#unsafe_link(link), '~&$.*').
|
||||
\ '\]\[.\{-1,}\]\]/ display contains=VimwikiLinkChar'
|
||||
|
||||
execute 'syntax match VimwikiLinkT /\[\['.
|
||||
\ escape(vimwiki#unsafe_link(link), '~&$.*').
|
||||
\ escape(vimwiki#base#unsafe_link(link), '~&$.*').
|
||||
\ '\%(|\+.\{-}\)\{-}\]\]/ display contained'
|
||||
execute 'syntax match VimwikiLinkT /\[\['.
|
||||
\ escape(vimwiki#unsafe_link(link), '~&$.*').
|
||||
\ escape(vimwiki#base#unsafe_link(link), '~&$.*').
|
||||
\ '\]\[.\{-1,}\]\]/ display contained'
|
||||
endfor
|
||||
execute 'syntax match VimwikiLink /\[\[.\+\.\%(jpg\|png\|gif\)\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
|
||||
@ -485,76 +515,22 @@ function! s:highlight_existed_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), '~&$.*').
|
||||
\ escape(vimwiki#base#unsafe_link(dir), '~&$.*').
|
||||
\ '[/\\]*\%(|\+.*\)*\]\]/ display contains=VimwikiLinkChar'
|
||||
execute 'syntax match VimwikiLink /\[\['.
|
||||
\ escape(vimwiki#unsafe_link(dir), '~&$.*').
|
||||
\ escape(vimwiki#base#unsafe_link(dir), '~&$.*').
|
||||
\ '[/\\]*\%(\]\[\+.*\)*\]\]/ display contains=VimwikiLinkChar'
|
||||
|
||||
execute 'syntax match VimwikiLinkT /\[\['.
|
||||
\ escape(vimwiki#unsafe_link(dir), '~&$.*').
|
||||
\ escape(vimwiki#base#unsafe_link(dir), '~&$.*').
|
||||
\ '[/\\]*\%(|\+.*\)*\]\]/ display contained'
|
||||
execute 'syntax match VimwikiLinkT /\[\['.
|
||||
\ escape(vimwiki#unsafe_link(dir), '~&$.*').
|
||||
\ escape(vimwiki#base#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) "{{{
|
||||
function! vimwiki#base#hl_exists(hl) "{{{
|
||||
if !hlexists(a:hl)
|
||||
return 0
|
||||
endif
|
||||
@ -565,7 +541,7 @@ function! vimwiki#hl_exists(hl) "{{{
|
||||
endfunction
|
||||
"}}}
|
||||
|
||||
function! vimwiki#nested_syntax(filetype, start, end, textSnipHl) abort "{{{
|
||||
function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{{
|
||||
" From http://vim.wikia.com/wiki/VimTip857
|
||||
let ft=toupper(a:filetype)
|
||||
let group='textGroup'.ft
|
||||
@ -615,21 +591,23 @@ endfunction "}}}
|
||||
"}}}
|
||||
|
||||
" WIKI functions {{{
|
||||
function! vimwiki#find_next_link() "{{{
|
||||
function! vimwiki#base#find_next_link() "{{{
|
||||
call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, '')
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
function! vimwiki#find_prev_link() "{{{
|
||||
function! vimwiki#base#find_prev_link() "{{{
|
||||
call s:search_word(g:vimwiki_rxWikiLink.'\|'.g:vimwiki_rxWeblink, 'b')
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
function! vimwiki#follow_link(split) "{{{
|
||||
function! vimwiki#base#follow_link(split) "{{{
|
||||
if a:split == "split"
|
||||
let cmd = ":split "
|
||||
elseif a:split == "vsplit"
|
||||
let cmd = ":vsplit "
|
||||
elseif a:split == "tabnew"
|
||||
let cmd = ":tabnew "
|
||||
else
|
||||
let cmd = ":e "
|
||||
endif
|
||||
@ -645,12 +623,12 @@ function! vimwiki#follow_link(split) "{{{
|
||||
return
|
||||
endif
|
||||
|
||||
let subdir = vimwiki#current_subdir()
|
||||
call vimwiki#open_link(cmd, subdir.link)
|
||||
let subdir = vimwiki#base#current_subdir()
|
||||
call vimwiki#base#open_link(cmd, subdir.link)
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki#go_back_link() "{{{
|
||||
function! vimwiki#base#go_back_link() "{{{
|
||||
if exists("b:vimwiki_prev_link")
|
||||
" go back to saved WikiWord
|
||||
let prev_word = b:vimwiki_prev_link
|
||||
@ -659,23 +637,13 @@ function! vimwiki#go_back_link() "{{{
|
||||
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
|
||||
function! vimwiki#base#goto_index(index) "{{{
|
||||
call vimwiki#base#select(a:index)
|
||||
call vimwiki#base#edit_file('e',
|
||||
\ VimwikiGet('path').VimwikiGet('index').VimwikiGet('ext'))
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#delete_link() "{{{
|
||||
function! vimwiki#base#delete_link() "{{{
|
||||
"" file system funcs
|
||||
"" Delete WikiWord you are in from filesystem
|
||||
let val = input('Delete ['.expand('%').'] (y/n)? ', "")
|
||||
@ -697,9 +665,9 @@ function! vimwiki#delete_link() "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#rename_link() "{{{
|
||||
function! vimwiki#base#rename_link() "{{{
|
||||
"" Rename WikiWord, update all links to renamed WikiWord
|
||||
let subdir = vimwiki#current_subdir()
|
||||
let subdir = vimwiki#base#current_subdir()
|
||||
let old_fname = subdir.expand('%:t')
|
||||
|
||||
" there is no file (new one maybe)
|
||||
@ -727,7 +695,7 @@ function! vimwiki#rename_link() "{{{
|
||||
echomsg 'vimwiki: Cannot rename to an empty filename!'
|
||||
return
|
||||
endif
|
||||
if vimwiki#is_non_wiki_link(new_link)
|
||||
if vimwiki#base#is_non_wiki_link(new_link)
|
||||
echomsg 'vimwiki: Cannot rename to a filename with extension (ie .txt .html)!'
|
||||
return
|
||||
endif
|
||||
@ -797,13 +765,13 @@ function! vimwiki#rename_link() "{{{
|
||||
let &more = setting_more
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki#ui_select()"{{{
|
||||
function! vimwiki#base#ui_select()"{{{
|
||||
call s:print_wiki_list()
|
||||
let idx = input("Select Wiki (specify number): ")
|
||||
if idx == ""
|
||||
return
|
||||
endif
|
||||
call vimwiki#goto_index(idx)
|
||||
call vimwiki#base#goto_index(idx)
|
||||
endfunction
|
||||
"}}}
|
||||
|
||||
@ -811,7 +779,7 @@ endfunction
|
||||
|
||||
" TEXT OBJECTS functions {{{
|
||||
|
||||
function! vimwiki#TO_header(inner, visual) "{{{
|
||||
function! vimwiki#base#TO_header(inner, visual) "{{{
|
||||
if !search('^\(=\+\).\+\1\s*$', 'bcW')
|
||||
return
|
||||
endif
|
||||
@ -821,7 +789,7 @@ function! vimwiki#TO_header(inner, visual) "{{{
|
||||
let block_start = line(".")
|
||||
let advance = 0
|
||||
|
||||
let level = vimwiki#count_first_sym(getline('.'))
|
||||
let level = vimwiki#base#count_first_sym(getline('.'))
|
||||
|
||||
let is_header_selected = sel_start == block_start
|
||||
\ && sel_start != sel_end
|
||||
@ -854,7 +822,7 @@ function! vimwiki#TO_header(inner, visual) "{{{
|
||||
endfunction
|
||||
"}}}
|
||||
|
||||
function! vimwiki#TO_table_cell(inner, visual) "{{{
|
||||
function! vimwiki#base#TO_table_cell(inner, visual) "{{{
|
||||
if col('.') == col('$')-1
|
||||
return
|
||||
endif
|
||||
@ -918,7 +886,7 @@ function! vimwiki#TO_table_cell(inner, visual) "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#TO_table_col(inner, visual) "{{{
|
||||
function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
||||
let t_rows = vimwiki_tbl#get_rows(line('.'))
|
||||
if empty(t_rows)
|
||||
return
|
||||
@ -1032,12 +1000,12 @@ function! vimwiki#TO_table_col(inner, visual) "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#count_first_sym(line) "{{{
|
||||
function! vimwiki#base#count_first_sym(line) "{{{
|
||||
let first_sym = matchstr(a:line, '\S')
|
||||
return len(matchstr(a:line, first_sym.'\+'))
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#AddHeaderLevel() "{{{
|
||||
function! vimwiki#base#AddHeaderLevel() "{{{
|
||||
let lnum = line('.')
|
||||
let line = getline(lnum)
|
||||
|
||||
@ -1046,7 +1014,7 @@ function! vimwiki#AddHeaderLevel() "{{{
|
||||
endif
|
||||
|
||||
if line =~ '^\s*\(=\+\).\+\1\s*$'
|
||||
let level = vimwiki#count_first_sym(line)
|
||||
let level = vimwiki#base#count_first_sym(line)
|
||||
if level < 6
|
||||
let line = substitute(line, '\(=\+\).\+\1', '=&=', '')
|
||||
call setline(lnum, line)
|
||||
@ -1059,7 +1027,7 @@ function! vimwiki#AddHeaderLevel() "{{{
|
||||
endfunction
|
||||
"}}}
|
||||
|
||||
function! vimwiki#RemoveHeaderLevel() "{{{
|
||||
function! vimwiki#base#RemoveHeaderLevel() "{{{
|
||||
let lnum = line('.')
|
||||
let line = getline(lnum)
|
||||
|
||||
@ -1068,7 +1036,7 @@ function! vimwiki#RemoveHeaderLevel() "{{{
|
||||
endif
|
||||
|
||||
if line =~ '^\s*\(=\+\).\+\1\s*$'
|
||||
let level = vimwiki#count_first_sym(line)
|
||||
let level = vimwiki#base#count_first_sym(line)
|
||||
let old = repeat('=', level)
|
||||
let new = repeat('=', level - 1)
|
||||
|
11
autoload/vimwiki/default.tpl
Normal file
11
autoload/vimwiki/default.tpl
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<link rel="Stylesheet" type="text/css" href="%root_path%%css%">
|
||||
<title>%title%</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=%encoding%">
|
||||
</head>
|
||||
<body>
|
||||
%content%
|
||||
</body>
|
||||
</html>
|
@ -197,19 +197,24 @@ function! s:make_date_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'))
|
||||
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)
|
||||
else
|
||||
let link = s:make_date_link()
|
||||
endif
|
||||
call vimwiki#open_link(':e ', link, s:diary_index())
|
||||
call vimwiki#base#open_link(':e ', link, s:diary_index())
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#diary#goto_index(index) "{{{
|
||||
call vimwiki#base#select(a:index)
|
||||
call vimwiki#base#edit_file(':e', s:diary_index())
|
||||
endfunction "}}}
|
||||
|
||||
" Calendar.vim callback function.
|
||||
function! vimwiki_diary#calendar_action(day, month, year, week, dir) "{{{
|
||||
function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{
|
||||
let day = s:prefix_zero(a:day)
|
||||
let month = s:prefix_zero(a:month)
|
||||
|
||||
@ -228,11 +233,11 @@ 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, link)
|
||||
endfunction "}}}
|
||||
|
||||
" Calendar.vim sign function.
|
||||
function vimwiki_diary#calendar_sign(day, month, year) "{{{
|
||||
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').
|
||||
@ -240,7 +245,7 @@ function vimwiki_diary#calendar_sign(day, month, year) "{{{
|
||||
return filereadable(expand(sfile))
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_diary#goto_next_day() "{{{
|
||||
function! vimwiki#diary#goto_next_day() "{{{
|
||||
let link = ''
|
||||
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
||||
|
||||
@ -256,11 +261,11 @@ function! vimwiki_diary#goto_next_day() "{{{
|
||||
endif
|
||||
|
||||
if len(link)
|
||||
call vimwiki#open_link(':e ', link)
|
||||
call vimwiki#base#open_link(':e ', link)
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_diary#goto_prev_day() "{{{
|
||||
function! vimwiki#diary#goto_prev_day() "{{{
|
||||
let link = ''
|
||||
let [idx, links] = s:get_position_links(expand('%:t:r'))
|
||||
|
||||
@ -276,6 +281,6 @@ function! vimwiki_diary#goto_prev_day() "{{{
|
||||
endif
|
||||
|
||||
if len(link)
|
||||
call vimwiki#open_link(':e ', link)
|
||||
call vimwiki#base#open_link(':e ', link)
|
||||
endif
|
||||
endfunction "}}}
|
@ -13,12 +13,6 @@ 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, '[/\\]')))
|
||||
@ -35,7 +29,7 @@ function! s:remove_blank_lines(lines) " {{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_web_link(lnk) "{{{
|
||||
if a:lnk =~ '^\%(https://\|http://\|www.\|ftp://\|file://\)'
|
||||
if a:lnk =~ '^\%(https://\|http://\|www.\|ftp://\|file://\|mailto:\)'
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
@ -55,104 +49,69 @@ function! s:has_abs_path(fname) "{{{
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:find_autoload_file(name) " {{{
|
||||
for path in split(&runtimepath, ',')
|
||||
let fname = path.'/autoload/vimwiki/'.a:name
|
||||
if glob(fname) != ''
|
||||
return fname
|
||||
endif
|
||||
endfor
|
||||
return ''
|
||||
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."
|
||||
call vimwiki#base#mkdir(fnamemodify(css_full_name, ':p:h'))
|
||||
let default_css = s:find_autoload_file('style.css')
|
||||
if default_css != ''
|
||||
let lines = readfile(default_css)
|
||||
call writefile(lines, css_full_name)
|
||||
echomsg "Default style.css has been created."
|
||||
endif
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_html_header(title, subdir, charset) "{{{
|
||||
function! s:template_full_name(name) "{{{
|
||||
if a:name == ''
|
||||
let name = VimwikiGet('template_default')
|
||||
else
|
||||
let name = a:name
|
||||
endif
|
||||
|
||||
let fname = expand(VimwikiGet('template_path').
|
||||
\name.
|
||||
\VimwikiGet('template_ext'))
|
||||
|
||||
if filereadable(fname)
|
||||
return fname
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_html_template(wikifile, template) "{{{
|
||||
" TODO: refactor it!!!
|
||||
let lines=[]
|
||||
|
||||
if VimwikiGet('html_header') != "" && !s:warn_html_header
|
||||
let template_name = s:template_full_name(a:template)
|
||||
if template_name != ''
|
||||
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")')
|
||||
let lines = readfile(template_name)
|
||||
return lines
|
||||
catch /E484/
|
||||
let s:warn_html_header = 1
|
||||
echomsg 'vimwiki: Header template '.VimwikiGet('html_header').
|
||||
echomsg 'vimwiki: html template '.template_name.
|
||||
\ ' 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
|
||||
" 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)
|
||||
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 "}}}
|
||||
|
||||
@ -174,6 +133,19 @@ endfunction "}}}
|
||||
function! s:delete_html_files(path) "{{{
|
||||
let htmlfiles = split(glob(a:path.'**/*.html'), '\n')
|
||||
for fname in htmlfiles
|
||||
" ignore user html files, e.g. search.html,404.html
|
||||
if stridx(g:vimwiki_user_htmls, fnamemodify(fname, ":t")) >= 0
|
||||
continue
|
||||
endif
|
||||
|
||||
" 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")
|
||||
if filereadable(wikifile)
|
||||
continue
|
||||
endif
|
||||
|
||||
try
|
||||
call delete(fname)
|
||||
catch
|
||||
@ -182,45 +154,6 @@ function! s:delete_html_files(path) "{{{
|
||||
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 "}}}
|
||||
@ -283,7 +216,7 @@ function! s:get_html_toc(toc_list) "{{{
|
||||
|
||||
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>')
|
||||
call add(toc, '<li><a href="#'.id.'">'.toc_text.'</a>')
|
||||
let plevel = level
|
||||
endfor
|
||||
call s:close_list(toc, level, 0)
|
||||
@ -293,6 +226,7 @@ endfunction "}}}
|
||||
|
||||
" insert toc into dest.
|
||||
function! s:process_toc(dest, placeholders, toc) "{{{
|
||||
let toc_idx = 0
|
||||
if !empty(a:placeholders)
|
||||
for [placeholder, row, idx] in a:placeholders
|
||||
let [type, param] = placeholder
|
||||
@ -301,8 +235,9 @@ function! s:process_toc(dest, placeholders, toc) "{{{
|
||||
if !empty(param)
|
||||
call insert(toc, '<h1>'.param.'</h1>')
|
||||
endif
|
||||
let shift = idx * len(toc)
|
||||
let shift = toc_idx * len(toc)
|
||||
call extend(a:dest, toc, row + shift)
|
||||
let toc_idx += 1
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
@ -321,6 +256,46 @@ function! s:process_title(placeholders, default_title) "{{{
|
||||
return a:default_title
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_html_uptodate(wikifile) "{{{
|
||||
let tpl_time = -1
|
||||
|
||||
let tpl_file = s:template_full_name('')
|
||||
if tpl_file != ''
|
||||
let tpl_time = getftime(tpl_file)
|
||||
endif
|
||||
|
||||
let wikifile = fnamemodify(a:wikifile, ":p")
|
||||
let subdir = vimwiki#base#subdir(VimwikiGet('path'), wikifile)
|
||||
let htmlfile = expand(VimwikiGet('path_html').subdir.
|
||||
\fnamemodify(wikifile, ":t:r").".html")
|
||||
|
||||
if getftime(wikifile) <= getftime(htmlfile) && tpl_time <= getftime(htmlfile)
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:html_insert_contents(html_lines, content) "{{{
|
||||
let lines = []
|
||||
for line in a:html_lines
|
||||
if line =~ '%content%'
|
||||
let parts = split(line, '%content%', 1)
|
||||
if empty(parts)
|
||||
call extend(lines, a:content)
|
||||
else
|
||||
for idx in range(len(parts))
|
||||
call add(lines, parts[idx])
|
||||
if idx < len(parts) - 1
|
||||
call extend(lines, a:content)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
else
|
||||
call add(lines, line)
|
||||
endif
|
||||
endfor
|
||||
return lines
|
||||
endfunction "}}}
|
||||
"}}}
|
||||
|
||||
" INLINE TAGS "{{{
|
||||
@ -376,19 +351,19 @@ function! s:tag_internal_link(value) "{{{
|
||||
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)
|
||||
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#is_link_to_dir(a:src)
|
||||
elseif vimwiki#base#is_link_to_dir(a:src)
|
||||
if g:vimwiki_dir_link == ''
|
||||
let link = '<a href="'.vimwiki#safe_link(a:src).'">'.a:caption.'</a>'
|
||||
let link = '<a href="'.vimwiki#base#safe_link(a:src).'">'.a:caption.'</a>'
|
||||
else
|
||||
let link = '<a href="'.vimwiki#safe_link(a:src).
|
||||
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#safe_link(a:src).
|
||||
let link = '<a href="'.vimwiki#base#safe_link(a:src).
|
||||
\ '.html">'.a:caption.'</a>'
|
||||
endif
|
||||
|
||||
@ -574,8 +549,6 @@ 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_rxPreStart.'.\+'.g:vimwiki_rxPreEnd,
|
||||
\ 's:tag_pre')
|
||||
return line
|
||||
endfunction " }}}
|
||||
|
||||
@ -624,13 +597,100 @@ 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']
|
||||
" [ CELL1, CELL2, CELL3 ],
|
||||
" [ CELL1, CELL2, CELL3 ],
|
||||
" [ CELL1, CELL2, CELL3 ],
|
||||
" ]
|
||||
" And CELLx is: { 'body': 'col_x', 'rowspan': r, 'colspan': c }
|
||||
|
||||
function! s:sum_rowspan(table) "{{{
|
||||
let table = a:table
|
||||
|
||||
" Get max cells
|
||||
let max_cells = 0
|
||||
for row in table[1:]
|
||||
let n_cells = len(row)
|
||||
if n_cells > max_cells
|
||||
let max_cells = n_cells
|
||||
end
|
||||
endfor
|
||||
|
||||
" Sum rowspan
|
||||
for cell_idx in range(max_cells)
|
||||
let rows = 1
|
||||
|
||||
for row_idx in range(len(table)-1, 1, -1)
|
||||
if cell_idx >= len(table[row_idx])
|
||||
let rows = 1
|
||||
continue
|
||||
endif
|
||||
|
||||
if table[row_idx][cell_idx].rowspan == 0
|
||||
let rows += 1
|
||||
else " table[row_idx][cell_idx].rowspan == 1
|
||||
let table[row_idx][cell_idx].rowspan = rows
|
||||
let rows = 1
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:sum_colspan(table) "{{{
|
||||
for row in a:table[1:]
|
||||
let cols = 1
|
||||
|
||||
for cell_idx in range(len(row)-1, 0, -1)
|
||||
if row[cell_idx].colspan == 0
|
||||
let cols += 1
|
||||
else "row[cell_idx].colspan == 1
|
||||
let row[cell_idx].colspan = cols
|
||||
let cols = 1
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
function! s:close_tag_row(row, header, ldest) "{{{
|
||||
call add(a:ldest, '<tr>')
|
||||
|
||||
" Set tag element of columns
|
||||
if a:header
|
||||
let tag_name = 'th'
|
||||
else
|
||||
let tag_name = 'td'
|
||||
end
|
||||
|
||||
" Close tag of columns
|
||||
for cell in a:row
|
||||
if cell.rowspan == 0 || cell.colspan == 0
|
||||
continue
|
||||
endif
|
||||
|
||||
if cell.rowspan > 1
|
||||
let rowspan_attr = ' rowspan="' . cell.rowspan . '"'
|
||||
else "cell.rowspan == 1
|
||||
let rowspan_attr = ''
|
||||
endif
|
||||
if cell.colspan > 1
|
||||
let colspan_attr = ' colspan="' . cell.colspan . '"'
|
||||
else "cell.colspan == 1
|
||||
let colspan_attr = ''
|
||||
endif
|
||||
|
||||
call add(a:ldest, '<' . tag_name . rowspan_attr . colspan_attr .'>')
|
||||
call add(a:ldest, s:process_inline_tags(cell.body))
|
||||
call add(a:ldest, '</'. tag_name . '>')
|
||||
endfor
|
||||
|
||||
call add(a:ldest, '</tr>')
|
||||
endfunction "}}}
|
||||
|
||||
let table = a:table
|
||||
let ldest = a:ldest
|
||||
if len(table)
|
||||
call s:sum_rowspan(table)
|
||||
call s:sum_colspan(table)
|
||||
|
||||
if table[0] == 'center'
|
||||
call add(ldest, "<table class='center'>")
|
||||
else
|
||||
@ -651,21 +711,15 @@ function! s:close_tag_table(table, ldest) "{{{
|
||||
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>')
|
||||
call s:close_tag_row(row, 1, ldest)
|
||||
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>')
|
||||
call s:close_tag_row(row, 0, ldest)
|
||||
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>')
|
||||
call s:close_tag_row(row, 0, ldest)
|
||||
endfor
|
||||
endif
|
||||
call add(ldest, "</table>")
|
||||
@ -741,11 +795,15 @@ function! s:process_tag_list(line, lists) "{{{
|
||||
|
||||
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" />'
|
||||
if len(chk[1])>0
|
||||
"wildcard characters are difficult to match correctly
|
||||
if chk[1] =~ '[.*\\^$~]'
|
||||
let chk[1] ='\'.chk[1]
|
||||
endif
|
||||
let completion = match(g:vimwiki_listsyms, '\C' . chk[1])
|
||||
if completion >= 0 && completion <=4
|
||||
let st_tag = '<li class="done'.completion.'">'
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
return [st_tag, en_tag]
|
||||
@ -790,7 +848,7 @@ function! s:process_tag_list(line, lists) "{{{
|
||||
|
||||
let checkbox = '\s*\[\(.\?\)\]\s*'
|
||||
let [st_tag, en_tag] = s:add_checkbox(line,
|
||||
\ lstRegExp.checkbox, '<li>', '</li>')
|
||||
\ lstRegExp.checkbox, '<li>', '')
|
||||
|
||||
if !in_list
|
||||
call add(a:lists, [lstTagClose, indent])
|
||||
@ -948,10 +1006,27 @@ endfunction "}}}
|
||||
|
||||
function! s:process_tag_table(line, table) "{{{
|
||||
function! s:table_empty_cell(value) "{{{
|
||||
if a:value =~ '^\s*$'
|
||||
return ' '
|
||||
let cell = {}
|
||||
|
||||
if a:value =~ '^\s*\\/\s*$'
|
||||
let cell.body = ''
|
||||
let cell.rowspan = 0
|
||||
let cell.colspan = 1
|
||||
elseif a:value =~ '^\s*>\s*$'
|
||||
let cell.body = ''
|
||||
let cell.rowspan = 1
|
||||
let cell.colspan = 0
|
||||
elseif a:value =~ '^\s*$'
|
||||
let cell.body = ' '
|
||||
let cell.rowspan = 1
|
||||
let cell.colspan = 1
|
||||
else
|
||||
let cell.body = a:value
|
||||
let cell.rowspan = 1
|
||||
let cell.colspan = 1
|
||||
endif
|
||||
return a:value
|
||||
|
||||
return cell
|
||||
endfunction "}}}
|
||||
|
||||
function! s:table_add_row(table, line) "{{{
|
||||
@ -1010,6 +1085,12 @@ function! s:parse_line(line, state) " {{{
|
||||
|
||||
let processed = 0
|
||||
|
||||
if !processed
|
||||
if line =~ g:vimwiki_rxComment
|
||||
let processed = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
" nohtml -- placeholder
|
||||
if !processed
|
||||
if line =~ '^\s*%nohtml'
|
||||
@ -1027,6 +1108,16 @@ function! s:parse_line(line, state) " {{{
|
||||
endif
|
||||
endif
|
||||
|
||||
" html template -- placeholder "{{{
|
||||
if !processed
|
||||
if line =~ '^\s*%template'
|
||||
let processed = 1
|
||||
let param = matchstr(line, '^\s*%template\s\zs.*')
|
||||
let state.placeholder = ['template', param]
|
||||
endif
|
||||
endif
|
||||
"}}}
|
||||
|
||||
" toc -- placeholder "{{{
|
||||
if !processed
|
||||
if line =~ '^\s*%toc'
|
||||
@ -1093,6 +1184,7 @@ function! s:parse_line(line, state) " {{{
|
||||
let state.table = s:close_tag_table(state.table, res_lines)
|
||||
let state.pre = s:close_tag_pre(state.pre, res_lines)
|
||||
let state.quote = s:close_tag_quote(state.quote, res_lines)
|
||||
let state.para = s:close_tag_para(state.para, res_lines)
|
||||
|
||||
let line = s:process_inline_tags(line)
|
||||
|
||||
@ -1189,25 +1281,32 @@ function! s:parse_line(line, state) " {{{
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
|
||||
function! vimwiki#html#Wiki2HTML(path, wikifile) "{{{
|
||||
|
||||
let starttime = reltime() " start the clock
|
||||
echo 'Generating HTML ... '
|
||||
if !s:syntax_supported()
|
||||
echomsg 'vimwiki: Only vimwiki_default syntax supported!!!'
|
||||
return
|
||||
endif
|
||||
|
||||
let wikifile = fnamemodify(a:wikifile, ":p")
|
||||
let subdir = vimwiki#subdir(VimwikiGet('path'), wikifile)
|
||||
|
||||
let lsource = s:remove_comments(readfile(wikifile))
|
||||
let ldest = []
|
||||
let subdir = vimwiki#base#subdir(VimwikiGet('path'), wikifile)
|
||||
|
||||
let path = expand(a:path).subdir
|
||||
call vimwiki#mkdir(path)
|
||||
let htmlfile = fnamemodify(wikifile, ":t:r").'.html'
|
||||
|
||||
let lsource = readfile(wikifile)
|
||||
let ldest = []
|
||||
|
||||
call vimwiki#base#mkdir(path)
|
||||
|
||||
" nohtml placeholder -- to skip html generation.
|
||||
let nohtml = 0
|
||||
|
||||
" template placeholder
|
||||
let template_name = ''
|
||||
|
||||
" for table of contents placeholders.
|
||||
let placeholders = []
|
||||
|
||||
@ -1238,43 +1337,70 @@ function! vimwiki_html#Wiki2HTML(path, wikifile) "{{{
|
||||
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)])
|
||||
let state.placeholder = []
|
||||
endif
|
||||
let state.placeholder = []
|
||||
endif
|
||||
|
||||
call extend(ldest, lines)
|
||||
endfor
|
||||
|
||||
|
||||
if !nohtml
|
||||
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_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"))
|
||||
call extend(ldest, s:get_html_header(title, subdir, &fileencoding), 0)
|
||||
call extend(ldest, s:get_html_footer())
|
||||
|
||||
"" make html file.
|
||||
let wwFileNameOnly = fnamemodify(wikifile, ":t:r")
|
||||
call writefile(ldest, path.wwFileNameOnly.'.html')
|
||||
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_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
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_html#WikiAll2HTML(path) "{{{
|
||||
|
||||
function! vimwiki#html#WikiAll2HTML(path) "{{{
|
||||
if !s:syntax_supported()
|
||||
echomsg 'vimwiki: Only vimwiki_default syntax supported!!!'
|
||||
return
|
||||
@ -1289,9 +1415,9 @@ function! vimwiki_html#WikiAll2HTML(path) "{{{
|
||||
let &eventignore = save_eventignore
|
||||
|
||||
let path = expand(a:path)
|
||||
call vimwiki#mkdir(path)
|
||||
call vimwiki#base#mkdir(path)
|
||||
|
||||
echomsg 'Deleting old html files...'
|
||||
echomsg 'Deleting non-wiki html files...'
|
||||
call s:delete_html_files(path)
|
||||
|
||||
echomsg 'Converting wiki to html files...'
|
||||
@ -1300,8 +1426,12 @@ function! vimwiki_html#WikiAll2HTML(path) "{{{
|
||||
|
||||
let wikifiles = split(glob(VimwikiGet('path').'**/*'.VimwikiGet('ext')), '\n')
|
||||
for wikifile in wikifiles
|
||||
echomsg 'Processing '.wikifile
|
||||
call vimwiki_html#Wiki2HTML(path, wikifile)
|
||||
if !s:is_html_uptodate(wikifile)
|
||||
echomsg 'Processing '.wikifile
|
||||
call vimwiki#html#Wiki2HTML(path, wikifile)
|
||||
else
|
||||
echomsg 'Skipping '.wikifile
|
||||
endif
|
||||
endfor
|
||||
call s:create_default_CSS(path)
|
||||
echomsg 'Done!'
|
@ -46,7 +46,7 @@ endfunction "}}}
|
||||
" Get level of the list item.
|
||||
function! s:get_level(lnum) "{{{
|
||||
if VimwikiGet('syntax') == 'media'
|
||||
let level = vimwiki#count_first_sym(getline(a:lnum))
|
||||
let level = vimwiki#base#count_first_sym(getline(a:lnum))
|
||||
else
|
||||
let level = indent(a:lnum)
|
||||
endif
|
||||
@ -287,7 +287,7 @@ endfunction "}}}
|
||||
" Script functions }}}
|
||||
|
||||
" Toggle list item between [ ] and [X]
|
||||
function! vimwiki_lst#ToggleListItem(line1, line2) "{{{
|
||||
function! vimwiki#lst#ToggleListItem(line1, line2) "{{{
|
||||
let line1 = a:line1
|
||||
let line2 = a:line2
|
||||
|
||||
@ -316,7 +316,7 @@ function! vimwiki_lst#ToggleListItem(line1, line2) "{{{
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_lst#kbd_cr() "{{{
|
||||
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()
|
||||
@ -325,35 +325,45 @@ function! vimwiki_lst#kbd_cr() "{{{
|
||||
return cr
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_lst#kbd_oO(cmd) "{{{
|
||||
function! vimwiki#lst#kbd_oO(cmd) "{{{
|
||||
" cmd should be 'o' or 'O'
|
||||
|
||||
let beg_lnum = foldclosed('.')
|
||||
let end_lnum = foldclosedend('.')
|
||||
if end_lnum != -1 && a:cmd ==# 'o'
|
||||
let lnum = end_lnum
|
||||
let line = getline(beg_lnum)
|
||||
else
|
||||
let line = getline('.')
|
||||
let lnum = line('.')
|
||||
endif
|
||||
let l:count = v:count1
|
||||
while l:count > 0
|
||||
|
||||
let beg_lnum = foldclosed('.')
|
||||
let end_lnum = foldclosedend('.')
|
||||
if end_lnum != -1 && a:cmd ==# 'o'
|
||||
let lnum = end_lnum
|
||||
let line = getline(beg_lnum)
|
||||
else
|
||||
let line = getline('.')
|
||||
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*$', ' ', '').'[ ] '
|
||||
elseif line =~ s:rx_list_item()
|
||||
let res = substitute(m, '\s*$', ' ', '')
|
||||
elseif &autoindent || &smartindent
|
||||
let res = matchstr(line, '^\s*')
|
||||
endif
|
||||
|
||||
if a:cmd ==# 'o'
|
||||
call append(lnum, res)
|
||||
call cursor(lnum + 1, col('$'))
|
||||
else
|
||||
call append(lnum - 1, res)
|
||||
call cursor(lnum, col('$'))
|
||||
endif
|
||||
|
||||
let l:count -= 1
|
||||
endwhile
|
||||
|
||||
startinsert!
|
||||
|
||||
" 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*$', ' ', '').'[ ] '
|
||||
elseif line =~ s:rx_list_item()
|
||||
let res = substitute(m, '\s*$', ' ', '')
|
||||
elseif &autoindent || &smartindent
|
||||
let res = matchstr(line, '^\s*')
|
||||
endif
|
||||
if a:cmd ==# 'o'
|
||||
call append(lnum, res)
|
||||
call cursor(lnum + 1, col('$'))
|
||||
else
|
||||
call append(lnum - 1, res)
|
||||
call cursor(lnum, col('$'))
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
39
autoload/vimwiki/style.css
Normal file
39
autoload/vimwiki/style.css
Normal file
@ -0,0 +1,39 @@
|
||||
body {font-family: Tahoma, Geneva, sans-serif; margin: 1em 2em 1em 2em; font-size: 100%; line-height: 130%;}
|
||||
h1, h2, h3, h4, h5, h6 {font-family: Trebuchet MS, Helvetica, sans-serif; font-weight: bold; line-height:100%; margin-top: 1.5em; margin-bottom: 0.5em;}
|
||||
h1 {font-size: 2.6em; color: #000000;}
|
||||
h2 {font-size: 2.2em; color: #404040;}
|
||||
h3 {font-size: 1.8em; color: #707070;}
|
||||
h4 {font-size: 1.4em; color: #909090;}
|
||||
h5 {font-size: 1.3em; color: #989898;}
|
||||
h6 {font-size: 1.2em; color: #9c9c9c;}
|
||||
p, pre, blockquote, table, ul, ol, dl {margin-top: 1em; margin-bottom: 1em;}
|
||||
ul ul, ul ol, ol ol, ol ul {margin-top: 0.5em; margin-bottom: 0.5em;}
|
||||
li {margin: 0.3em auto;}
|
||||
ul {margin-left: 2em; padding-left: 0.5em;}
|
||||
dt {font-weight: bold;}
|
||||
img {border: none;}
|
||||
pre {border-left: 1px solid #ccc; margin-left: 2em; padding-left: 0.5em;}
|
||||
blockquote {padding: 0.4em; background-color: #f6f5eb;}
|
||||
th, td {border: 1px solid #ccc; padding: 0.3em;}
|
||||
th {background-color: #f0f0f0;}
|
||||
hr {border: none; border-top: 1px solid #ccc; width: 100%;}
|
||||
del {text-decoration: line-through; color: #777777;}
|
||||
.toc li {list-style-type: none;}
|
||||
.todo {font-weight: bold; background-color: #f0ece8; color: #a03020;}
|
||||
.justleft {text-align: left;}
|
||||
.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;}
|
@ -299,7 +299,7 @@ endfunction "}}}
|
||||
" Keyboard functions "{{{
|
||||
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>:call vimwiki#tbl#format(line('.'))\<CR>"
|
||||
if a:goto_first
|
||||
let cmd .= "\<ESC>0:call search('|', 'c', line('.'))\<CR>la"
|
||||
else
|
||||
@ -341,7 +341,7 @@ endfunction "}}}
|
||||
"}}}
|
||||
|
||||
" Global functions {{{
|
||||
function! vimwiki_tbl#kbd_cr() "{{{
|
||||
function! vimwiki#tbl#kbd_cr() "{{{
|
||||
let lnum = line('.')
|
||||
if !s:is_table(getline(lnum))
|
||||
return "\<CR>"
|
||||
@ -355,7 +355,7 @@ function! vimwiki_tbl#kbd_cr() "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#kbd_tab() "{{{
|
||||
function! vimwiki#tbl#kbd_tab() "{{{
|
||||
let lnum = line('.')
|
||||
if !s:is_table(getline(lnum))
|
||||
return "\<Tab>"
|
||||
@ -369,7 +369,7 @@ function! vimwiki_tbl#kbd_tab() "{{{
|
||||
return s:kbd_goto_next_col(last)
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#kbd_shift_tab() "{{{
|
||||
function! vimwiki#tbl#kbd_shift_tab() "{{{
|
||||
let lnum = line('.')
|
||||
if !s:is_table(getline(lnum))
|
||||
return "\<S-Tab>"
|
||||
@ -382,7 +382,7 @@ function! vimwiki_tbl#kbd_shift_tab() "{{{
|
||||
return s:kbd_goto_prev_col(first)
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#format(lnum, ...) "{{{
|
||||
function! vimwiki#tbl#format(lnum, ...) "{{{
|
||||
let line = getline(a:lnum)
|
||||
if !s:is_table(line)
|
||||
return
|
||||
@ -406,7 +406,7 @@ function! vimwiki_tbl#format(lnum, ...) "{{{
|
||||
let &tw = s:textwidth
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#create(...) "{{{
|
||||
function! vimwiki#tbl#create(...) "{{{
|
||||
if a:0 > 1
|
||||
let cols = a:1
|
||||
let rows = a:2
|
||||
@ -441,15 +441,15 @@ function! vimwiki_tbl#create(...) "{{{
|
||||
call append(line('.'), lines)
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#align_or_cmd(cmd) "{{{
|
||||
function! vimwiki#tbl#align_or_cmd(cmd) "{{{
|
||||
if s:is_table(getline('.'))
|
||||
call vimwiki_tbl#format(line('.'))
|
||||
call vimwiki#tbl#format(line('.'))
|
||||
else
|
||||
exe 'normal! '.a:cmd
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#reset_tw(lnum) "{{{
|
||||
function! vimwiki#tbl#reset_tw(lnum) "{{{
|
||||
let line = getline(a:lnum)
|
||||
if !s:is_table(line)
|
||||
return
|
||||
@ -461,7 +461,7 @@ endfunction "}}}
|
||||
|
||||
" TODO: move_column_left and move_column_right are good candidates to be
|
||||
" refactored.
|
||||
function! vimwiki_tbl#move_column_left() "{{{
|
||||
function! vimwiki#tbl#move_column_left() "{{{
|
||||
if !s:is_table(getline('.'))
|
||||
return
|
||||
endif
|
||||
@ -472,7 +472,7 @@ function! vimwiki_tbl#move_column_left() "{{{
|
||||
endif
|
||||
|
||||
if cur_col > 0
|
||||
call vimwiki_tbl#format(line('.'), cur_col-1, cur_col)
|
||||
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')
|
||||
@ -482,7 +482,7 @@ function! vimwiki_tbl#move_column_left() "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#move_column_right() "{{{
|
||||
function! vimwiki#tbl#move_column_right() "{{{
|
||||
if !s:is_table(getline('.'))
|
||||
return
|
||||
endif
|
||||
@ -493,7 +493,7 @@ function! vimwiki_tbl#move_column_right() "{{{
|
||||
endif
|
||||
|
||||
if cur_col < s:col_count(line('.'))-1
|
||||
call vimwiki_tbl#format(line('.'), cur_col, cur_col+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')
|
||||
@ -503,7 +503,7 @@ function! vimwiki_tbl#move_column_right() "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki_tbl#get_rows(lnum) "{{{
|
||||
function! vimwiki#tbl#get_rows(lnum) "{{{
|
||||
return s:get_rows(a:lnum)
|
||||
endfunction "}}}
|
||||
|
Reference in New Issue
Block a user