X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/b6ec0976a383cc1823f4a199bc3e6dc40880b049..3a70fb37a8784ea703eb23d8b19b90bfd00f13bc:/librarian/html.py 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