From e394602de9243608d1e99a3de448a75646f1a77f Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 4 Jan 2012 13:34:57 +0100 Subject: [PATCH] #1913: tags in section titles break table of contents --- librarian/html.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/librarian/html.py b/librarian/html.py index 997f904..39e5a01 100644 --- a/librarian/html.py +++ b/librarian/html.py @@ -228,10 +228,12 @@ def add_table_of_contents(root): if any_ancestor(element, lambda e: e.get('id') in ('footnotes',) or e.get('class') in ('person-list',)): continue + element_text = etree.tostring(element, method='text', + encoding=unicode).strip() if element.tag == 'h3' and len(sections) and sections[-1][1] == 'h2': - sections[-1][3].append((counter, element.tag, ''.join(element.xpath('text()')), [])) + sections[-1][3].append((counter, element.tag, element_text, [])) else: - sections.append((counter, element.tag, ''.join(element.xpath('text()')), [])) + sections.append((counter, element.tag, element_text, [])) add_anchor(element, "s%d" % counter, with_link=False) counter += 1 -- 2.20.1