Skip to content

Commit

Permalink
Skip preformatted and math text while scanning for headers
Browse files Browse the repository at this point in the history
Fix #191
  • Loading branch information
EinfachToll committed Mar 18, 2016
1 parent 4bd0690 commit 4c2e13a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions autoload/vimwiki/base.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1736,10 +1736,27 @@ endfunction " }}}
" a:create == 0: update if TOC exists
function! vimwiki#base#table_of_contents(create)
" collect new headers
let is_inside_pre_or_math = 0 " 1: inside pre, 2: inside math, 0: outside
let headers = []
let headers_levels = [['', 0], ['', 0], ['', 0], ['', 0], ['', 0], ['', 0]]
for lnum in range(1, line('$'))
let line_content = getline(lnum)
if (is_inside_pre_or_math == 1 && line_content =~# g:vimwiki_rxPreEnd) ||
\ (is_inside_pre_or_math == 2 && line_content =~# g:vimwiki_rxMathEnd)
let is_inside_pre_or_math = 0
continue
endif
if is_inside_pre_or_math > 0
continue
endif
if line_content =~# g:vimwiki_rxPreStart
let is_inside_pre_or_math = 1
continue
endif
if line_content =~# g:vimwiki_rxMathStart
let is_inside_pre_or_math = 2
continue
endif
if line_content !~# g:vimwiki_rxHeader
continue
endif
Expand Down

0 comments on commit 4c2e13a

Please sign in to comment.