From: Radek Czajka Date: Wed, 4 Jan 2012 12:34:57 +0000 (+0100) Subject: #1913: tags in section titles break table of contents X-Git-Tag: 1.7~172 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/e394602de9243608d1e99a3de448a75646f1a77f?ds=sidebyside;hp=--cc #1913: tags in section titles break table of contents --- e394602de9243608d1e99a3de448a75646f1a77f 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