diff --git a/autoload/latex/toc.vim b/autoload/latex/toc.vim index cb27ba8..76ed3d2 100644 --- a/autoload/latex/toc.vim +++ b/autoload/latex/toc.vim @@ -127,26 +127,25 @@ function! s:read_toc(auxfile, texfile, ...) endif " Parse number - if len(tree[1]) > 3 && empty(tree[1][1]) - call remove(tree[1], 1) + let secnum = '' + let tree = tree[1] + if len(tree) > 3 && empty(tree[1]) + call remove(tree, 1) endif - if len(tree[1]) > 1 - if !empty(tree[1][1]) - let secnum = latex#util#tree2tex(tree[1][1]) + if len(tree) > 1 + if tree[0] =~ '^\\numberline' + let secnum = latex#util#tree2tex(tree[1]) let secnum = substitute(secnum, '\\\S\+\s', '', 'g') let secnum = substitute(secnum, '\\\S\+{\(.\{-}\)}', '\1', 'g') let secnum = substitute(secnum, '^{\+\|}\+$', '', 'g') + call remove(tree, 1) endif - let tree = tree[1][2:] - else - let secnum = '' - let tree = tree[1] endif " Parse title let text = latex#util#tree2tex(tree) let text = substitute(text, '^{\+\|}\+$', '', 'g') - let text = substitute(text, '^\\nonumberline\s*', '', 'g') + let text = substitute(text, '^\\\(no\)\?numberline\s*', '', 'g') " Add TOC entry call add(fileindices[texfile], len(toc))