Remove recently introduced code duplication
This commit is contained in:
parent
bf2039555a
commit
86a8604c4e
@ -1783,34 +1783,13 @@ endfunction
|
|||||||
" a:create == 1: creates or updates TOC in current file
|
" a:create == 1: creates or updates TOC in current file
|
||||||
" a:create == 0: update if TOC exists
|
" a:create == 0: update if TOC exists
|
||||||
function! vimwiki#base#table_of_contents(create)
|
function! vimwiki#base#table_of_contents(create)
|
||||||
" collect new headers
|
let headers = s:collect_headers()
|
||||||
let is_inside_pre_or_math = 0 " 1: inside pre, 2: inside math, 0: outside
|
|
||||||
let numbering = vimwiki#vars#get_global('html_header_numbering')
|
let numbering = vimwiki#vars#get_global('html_header_numbering')
|
||||||
let headers = []
|
|
||||||
let headers_levels = [['', 0], ['', 0], ['', 0], ['', 0], ['', 0], ['', 0]]
|
let headers_levels = [['', 0], ['', 0], ['', 0], ['', 0], ['', 0], ['', 0]]
|
||||||
for lnum in range(1, line('$'))
|
let complete_header_infos = []
|
||||||
let line_content = getline(lnum)
|
for header in headers
|
||||||
if (is_inside_pre_or_math == 1 && line_content =~# vimwiki#vars#get_syntaxlocal('rxPreEnd')) ||
|
let h_text = header[2]
|
||||||
\ (is_inside_pre_or_math == 2 && line_content =~# vimwiki#vars#get_syntaxlocal('rxMathEnd'))
|
let h_level = header[1]
|
||||||
let is_inside_pre_or_math = 0
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
if is_inside_pre_or_math > 0
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
if line_content =~# vimwiki#vars#get_syntaxlocal('rxPreStart')
|
|
||||||
let is_inside_pre_or_math = 1
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
if line_content =~# vimwiki#vars#get_syntaxlocal('rxMathStart')
|
|
||||||
let is_inside_pre_or_math = 2
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
if line_content !~# vimwiki#vars#get_syntaxlocal('rxHeader')
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
let h_level = vimwiki#u#count_first_sym(line_content)
|
|
||||||
let h_text = vimwiki#u#trim(matchstr(line_content, vimwiki#vars#get_syntaxlocal('rxHeader')))
|
|
||||||
if h_text ==# vimwiki#vars#get_global('toc_header') " don't include the TOC's header itself
|
if h_text ==# vimwiki#vars#get_global('toc_header') " don't include the TOC's header itself
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
@ -1831,14 +1810,14 @@ function! vimwiki#base#table_of_contents(create)
|
|||||||
let h_text = h_number.' '.h_text
|
let h_text = h_number.' '.h_text
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(headers, [h_level, h_complete_id, h_text])
|
call add(complete_header_infos, [h_level, h_complete_id, h_text])
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
let lines = []
|
let lines = []
|
||||||
let startindent = repeat(' ', vimwiki#lst#get_list_margin())
|
let startindent = repeat(' ', vimwiki#lst#get_list_margin())
|
||||||
let indentstring = repeat(' ', vimwiki#u#sw())
|
let indentstring = repeat(' ', vimwiki#u#sw())
|
||||||
let bullet = vimwiki#lst#default_symbol().' '
|
let bullet = vimwiki#lst#default_symbol().' '
|
||||||
for [lvl, link, desc] in headers
|
for [lvl, link, desc] in complete_header_infos
|
||||||
let esc_link = substitute(link, "'", "''", 'g')
|
let esc_link = substitute(link, "'", "''", 'g')
|
||||||
let esc_desc = substitute(desc, "'", "''", 'g')
|
let esc_desc = substitute(desc, "'", "''", 'g')
|
||||||
let link = s:safesubstitute(vimwiki#vars#get_global('WikiLinkTemplate2'), '__LinkUrl__',
|
let link = s:safesubstitute(vimwiki#vars#get_global('WikiLinkTemplate2'), '__LinkUrl__',
|
||||||
|
Loading…
Reference in New Issue
Block a user