-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(toc): support for comment package
refer: #2882
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
" VimTeX - LaTeX plugin for Vim | ||
" | ||
" Maintainer: Karl Yngve Lervåg | ||
" Email: [email protected] | ||
" | ||
|
||
function! vimtex#parser#toc#comment#new() abort " {{{1 | ||
return s:matcher | ||
endfunction | ||
|
||
" }}}1 | ||
|
||
let s:matcher = { | ||
\ 'in_preamble' : 1, | ||
\ 'prefilter_cmds': ['begin'], | ||
\ 're': '^\s*\\begin{comment}', | ||
\ 're_end': '^\s*\\end{comment}', | ||
\} | ||
function! s:matcher.get_entry(context) abort dict " {{{1 | ||
let a:context.continue = 'comment' | ||
return {} | ||
endfunction | ||
|
||
" }}}1 | ||
function! s:matcher.continue(context) abort dict " {{{1 | ||
if a:context.line =~# self.re_end | ||
unlet! a:context.continue | ||
endif | ||
endfunction | ||
|
||
" }}}1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
\documentclass{article} | ||
\usepackage{comment} | ||
|
||
\begin{document} | ||
|
||
\section{Real section} | ||
|
||
\begin{comment} | ||
\section{Commented section} | ||
\subsection{Commented subsection} | ||
\subsubsection{Commented subsubsection} | ||
\end{comment} | ||
|
||
\begin{comment} | ||
\begin{figure} \label{fig:commented} | ||
\end{figure} | ||
\end{comment} | ||
|
||
\section{Next real section} | ||
|
||
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
set nocompatible | ||
let &rtp = '../..,' . &rtp | ||
filetype plugin on | ||
|
||
set nomore | ||
|
||
nnoremap q :qall!<cr> | ||
silent edit test-comment.tex | ||
|
||
if empty($INMAKE) | finish | endif | ||
|
||
let s:toc = vimtex#toc#get_entries() | ||
call assert_equal(len(s:toc), 3) | ||
|
||
" let s:i = 0 | ||
" for s:x in s:toc | ||
" echo s:i '--' s:x.title "\n" | ||
" let s:i += 1 | ||
" endfor | ||
|
||
call vimtex#test#finished() |