From 43410759c35ec6985a9ae7881a7eae28e0a2f7e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Thu, 12 Jun 2014 19:53:43 +0200 Subject: [PATCH] Improved TOC title parsing --- autoload/latex/toc.vim | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) 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))