Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with TOC creation and searching when documentclass is amsart. #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions ftplugin/latex-box/motion.vim
Original file line number Diff line number Diff line change
Expand Up @@ -349,26 +349,31 @@ function! s:ReadTOC(auxfile, texfile, ...)
if len(tree) > 3 && empty(tree[1])
call remove(tree, 1)
endif
if len(tree) > 1 && type(tree[0]) == type("") && tree[0] =~ '^\\\(\(chapter\)\?numberline\|tocsection\)'
let secnum = LatexBox_TreeToTex(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)

" only include section types we know how to parse.
if len(tree) > 1 && type(tree[0]) == type("") && tree[0] =~ '^\\\(chapter\)\?\(numberline\|toc\(sub\)*section\)'

if len(tree[1]) >= 1
" Check if tree[1] has at least one string under it.
let secnum = tree[1][0]
endif


" parse section title
let text = LatexBox_TreeToTex(tree[2])
let text = substitute(text, '^{\+\|}\+$','', 'g')
let text = substitute(text, '\m^\\\(no\)\?\(chapter\)\?\(numberline\|toc\(sub\)*section\s*{\)\s*', '', '')

" add TOC entry
call add(fileindices[texfile], len(toc))
call add(toc, {'file': texfile,
\ 'level': level,
\ 'number': secnum,
\ 'text': text,
\ 'page': page})

endif
" parse section title
let text = LatexBox_TreeToTex(tree)
let text = substitute(text, '^{\+\|}\+$', '', 'g')
let text = substitute(text, '\m^\\\(no\)\?\(chapter\)\?numberline\s*', '', '')
let text = substitute(text, '\*', '', 'g')

" add TOC entry
call add(fileindices[texfile], len(toc))
call add(toc, {'file': texfile,
\ 'level': level,
\ 'number': secnum,
\ 'text': text,
\ 'page': page})

endfor

return [toc, fileindices]
Expand Down
2 changes: 2 additions & 0 deletions ftplugin/latextoc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ function! s:EscapeTitle(titlestr)
let titlestr = substitute(a:titlestr, '\\[a-zA-Z@]*\>\s*{\?', '.*', 'g')
let titlestr = substitute(titlestr, '}', '', 'g')
let titlestr = substitute(titlestr, '\%(\.\*\s*\)\{2,}', '.*', 'g')
" replaces equations in titles with .*
let titlestr = substitute(titlestr, '\$.*\$', '.*','g')
return titlestr
endfunction

Expand Down