"""Convert a LaTeX .toc file to some PDFTeX magic to create that neat outline.
The output file has an extension of '.bkm' instead of '.out', since hyperref
-already uses that extension. Let's avoid clashing.
+already uses that extension.
"""
import getopt
('subsubsection', 'chapter'): 3,
}
+INCLUDED_LEVELS = ("chapter", "section", "subsection", "subsubsection")
+
+
def parse_toc(fp, bigpart=None):
toc = top = []
stack = [toc]
if stype == level:
toc.append(entry)
else:
+ if stype not in INCLUDED_LEVELS:
+ # we don't want paragraphs & subparagraphs
+ continue
direction = _transition_map[(level, stype)]
if direction == OUTER_TO_INNER:
toc = toc[-1][-1]