Reactivate and fix html.vim to make it work with lists
This commit is contained in:
parent
23db33ed17
commit
e6735215ed
@ -22,15 +22,6 @@ let g:loaded_vimwiki_html_auto = 1
|
|||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
" UTILITY "{{{
|
" UTILITY "{{{
|
||||||
function s:get_completion_index(sym) "{{{
|
|
||||||
for idx in range(1, 5)
|
|
||||||
if match(g:vimwiki_listsyms, '\C\%'.idx.'v'.a:sym) != -1
|
|
||||||
return (idx-1)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
return 0
|
|
||||||
endfunction "}}}
|
|
||||||
|
|
||||||
function! s:root_path(subdir) "{{{
|
function! s:root_path(subdir) "{{{
|
||||||
return repeat('../', len(split(a:subdir, '[/\\]')))
|
return repeat('../', len(split(a:subdir, '[/\\]')))
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
@ -843,34 +834,26 @@ endfunction "}}}
|
|||||||
|
|
||||||
function! s:process_tag_list(line, lists) "{{{
|
function! s:process_tag_list(line, lists) "{{{
|
||||||
|
|
||||||
function! s:add_checkbox(line, rx_list, st_tag, en_tag) "{{{
|
function! s:add_checkbox(line, rx_list) "{{{
|
||||||
let st_tag = a:st_tag
|
let st_tag = '<li>'
|
||||||
let en_tag = a:en_tag
|
|
||||||
|
|
||||||
let chk = matchlist(a:line, a:rx_list)
|
let chk = matchlist(a:line, a:rx_list)
|
||||||
if len(chk) > 0
|
if !empty(chk) && len(chk[1]) > 0
|
||||||
if len(chk[1])>0
|
let completion = index(g:vimwiki_listsyms_list, chk[1])
|
||||||
"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])
|
|
||||||
let completion = s:get_completion_index(chk[1])
|
|
||||||
if completion >= 0 && completion <=4
|
if completion >= 0 && completion <=4
|
||||||
let st_tag = '<li class="done'.completion.'">'
|
let st_tag = '<li class="done'.completion.'">'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
return [st_tag, '']
|
||||||
return [st_tag, en_tag]
|
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
let in_list = (len(a:lists) > 0)
|
let in_list = (len(a:lists) > 0)
|
||||||
|
|
||||||
" If it is not list yet then do not process line that starts from *bold*
|
" If it is not list yet then do not process line that starts from *bold*
|
||||||
" text.
|
" text.
|
||||||
|
" XXX necessary? in *bold* text, no space must follow the first *
|
||||||
if !in_list
|
if !in_list
|
||||||
let pos = match(a:line, g:vimwiki_rxBold)
|
let pos = match(a:line, '^\s*'.g:vimwiki_rxBold)
|
||||||
if pos != -1 && strpart(a:line, 0, pos) =~ '^\s*$'
|
if pos != -1
|
||||||
return [0, []]
|
return [0, []]
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -878,16 +861,16 @@ function! s:process_tag_list(line, lists) "{{{
|
|||||||
let lines = []
|
let lines = []
|
||||||
let processed = 0
|
let processed = 0
|
||||||
|
|
||||||
if a:line =~ g:vimwiki_rxListBullet
|
if a:line =~ '^\s*'.s:bullets.'\s'
|
||||||
let lstSym = matchstr(a:line, '[*-]')
|
let lstSym = matchstr(a:line, s:bullets)
|
||||||
let lstTagOpen = '<ul>'
|
let lstTagOpen = '<ul>'
|
||||||
let lstTagClose = '</ul>'
|
let lstTagClose = '</ul>'
|
||||||
let lstRegExp = g:vimwiki_rxListBullet
|
let lstRegExp = '^\s*'.s:bullets.'\s'
|
||||||
elseif a:line =~ g:vimwiki_rxListNumber
|
elseif a:line =~ '^\s*'.s:numbers.'\s'
|
||||||
let lstSym = '#'
|
let lstSym = matchstr(a:line, s:numbers)
|
||||||
let lstTagOpen = '<ol>'
|
let lstTagOpen = '<ol>'
|
||||||
let lstTagClose = '</ol>'
|
let lstTagClose = '</ol>'
|
||||||
let lstRegExp = g:vimwiki_rxListNumber
|
let lstRegExp = '^\s*'.s:numbers.'\s'
|
||||||
else
|
else
|
||||||
let lstSym = ''
|
let lstSym = ''
|
||||||
let lstTagOpen = ''
|
let lstTagOpen = ''
|
||||||
@ -901,9 +884,8 @@ function! s:process_tag_list(line, lists) "{{{
|
|||||||
let line = substitute(a:line, '\t', repeat(' ', &tabstop), 'g')
|
let line = substitute(a:line, '\t', repeat(' ', &tabstop), 'g')
|
||||||
let indent = stridx(line, lstSym)
|
let indent = stridx(line, lstSym)
|
||||||
|
|
||||||
let checkbox = '\s*\[\(.\?\)\]\s*'
|
let checkbox = '\s*\[\(.\)\]\s*'
|
||||||
let [st_tag, en_tag] = s:add_checkbox(line,
|
let [st_tag, en_tag] = s:add_checkbox(line, lstRegExp.checkbox)
|
||||||
\ lstRegExp.checkbox, '<li>', '')
|
|
||||||
|
|
||||||
if !in_list
|
if !in_list
|
||||||
call add(a:lists, [lstTagClose, indent])
|
call add(a:lists, [lstTagClose, indent])
|
||||||
@ -929,7 +911,7 @@ function! s:process_tag_list(line, lists) "{{{
|
|||||||
call add(lines,
|
call add(lines,
|
||||||
\ substitute(a:line, lstRegExp.'\%('.checkbox.'\)\?', '', ''))
|
\ substitute(a:line, lstRegExp.'\%('.checkbox.'\)\?', '', ''))
|
||||||
let processed = 1
|
let processed = 1
|
||||||
elseif in_list > 0 && a:line =~ '^\s\+\S\+'
|
elseif in_list && a:line =~ '^\s\+\S\+'
|
||||||
if g:vimwiki_list_ignore_newline
|
if g:vimwiki_list_ignore_newline
|
||||||
call add(lines, a:line)
|
call add(lines, a:line)
|
||||||
else
|
else
|
||||||
@ -1420,6 +1402,11 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
|
|||||||
let s:gt_pattern = '\c\%(</\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>'
|
let s:gt_pattern = '\c\%(</\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" prepare regexps for lists
|
||||||
|
let s:bullets = '[*•-]'
|
||||||
|
let s:numbers =
|
||||||
|
\'\C\%(#\|\d\+)\|\d\+\.\|[ivxlcdm]\+)\|[IVXLCDM]\+)\|\l\{1,2})\|\u\{1,2})\)'
|
||||||
|
|
||||||
for line in lsource
|
for line in lsource
|
||||||
let oldquote = state.quote
|
let oldquote = state.quote
|
||||||
let [lines, state] = s:parse_line(line, state)
|
let [lines, state] = s:parse_line(line, state)
|
||||||
|
@ -847,9 +847,6 @@ or: >
|
|||||||
or: >
|
or: >
|
||||||
* Bulleted list item 1
|
* Bulleted list item 1
|
||||||
* Bulleted list item 2
|
* Bulleted list item 2
|
||||||
or: >
|
|
||||||
# Bulleted list item 1
|
|
||||||
# Bulleted list item 2
|
|
||||||
|
|
||||||
|
|
||||||
Ordered lists: >
|
Ordered lists: >
|
||||||
@ -876,6 +873,9 @@ or: >
|
|||||||
I) Numbered list item 1
|
I) Numbered list item 1
|
||||||
II) Numbered list item 2
|
II) Numbered list item 2
|
||||||
III) Numbered list item 3
|
III) Numbered list item 3
|
||||||
|
or: >
|
||||||
|
# Bulleted list item 1 ← will be converted to numbers in HTML
|
||||||
|
# Bulleted list item 2
|
||||||
|
|
||||||
Note that a space after the list item symbols (-, *, 1. etc.) is essential.
|
Note that a space after the list item symbols (-, *, 1. etc.) is essential.
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ endfunction "}}}
|
|||||||
" COMMANDS {{{
|
" COMMANDS {{{
|
||||||
command! -buffer Vimwiki2HTML
|
command! -buffer Vimwiki2HTML
|
||||||
\ silent w <bar>
|
\ silent w <bar>
|
||||||
\ let res = vimwiki#vw2html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
\ let res = vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
||||||
\ expand('%'))
|
\ expand('%'))
|
||||||
\<bar>
|
\<bar>
|
||||||
\ if res != '' | echo 'Vimwiki: HTML conversion is done.' | endif
|
\ if res != '' | echo 'Vimwiki: HTML conversion is done.' | endif
|
||||||
@ -154,7 +154,7 @@ command! -buffer Vimwiki2HTMLBrowse
|
|||||||
\ expand(VimwikiGet('path_html')),
|
\ expand(VimwikiGet('path_html')),
|
||||||
\ expand('%')))
|
\ expand('%')))
|
||||||
command! -buffer VimwikiAll2HTML
|
command! -buffer VimwikiAll2HTML
|
||||||
\ call vimwiki#vw2html#WikiAll2HTML(expand(VimwikiGet('path_html')))
|
\ call vimwiki#html#WikiAll2HTML(expand(VimwikiGet('path_html')))
|
||||||
|
|
||||||
command! -buffer VimwikiNextLink call vimwiki#base#find_next_link()
|
command! -buffer VimwikiNextLink call vimwiki#base#find_next_link()
|
||||||
command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link()
|
command! -buffer VimwikiPrevLink call vimwiki#base#find_prev_link()
|
||||||
@ -530,7 +530,7 @@ if VimwikiGet('auto_export')
|
|||||||
" Automatically generate HTML on page write.
|
" Automatically generate HTML on page write.
|
||||||
augroup vimwiki
|
augroup vimwiki
|
||||||
au BufWritePost <buffer>
|
au BufWritePost <buffer>
|
||||||
\ call vimwiki#vw2html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
\ call vimwiki#html#Wiki2HTML(expand(VimwikiGet('path_html')),
|
||||||
\ expand('%'))
|
\ expand('%'))
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user