From 433b5cf799ebfa4c82d8f100212ed2122e94d493 Mon Sep 17 00:00:00 2001 From: Hollow Man Date: Tue, 27 Dec 2022 21:50:05 +0200 Subject: [PATCH] Outline remove toggle mark Signed-off-by: Hollow Man --- mdbook_pdf_outline/mdbook_pdf_outline.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mdbook_pdf_outline/mdbook_pdf_outline.py b/mdbook_pdf_outline/mdbook_pdf_outline.py index b3c78b3..6716ab5 100755 --- a/mdbook_pdf_outline/mdbook_pdf_outline.py +++ b/mdbook_pdf_outline/mdbook_pdf_outline.py @@ -73,9 +73,12 @@ def parse_toc(toc, reader, writer, parent_dict, level=1): dest_name = "/" a_element = None for element in head.iter(): - if element.tag == "a": + if element.tag == "a" and "href" in element.attrib: a_element = element break + to_remove = head.find_class("toggle") + for element in to_remove: + element.getparent().remove(element) if a_element is None: continue for content in a_element.attrib["href"].split("#"):