+ def naglowek_to_anchor(self, naglowek):
+ return re.sub(r" +", " ", naglowek.text.strip())
+
+ def handle_nazwa_utworu(self, element):
+ toc = []
+ for naglowek in element.getparent().findall('.//naglowek_rozdzial'):
+ a = etree.Element("a")
+ a.attrib["href"] = "#" + self.naglowek_to_anchor(naglowek)
+ a.text = naglowek.text
+ atxt = etree.tostring(a, encoding=unicode)
+ toc.append("<li>%s</li>" % atxt)
+ toc = "<ul class='toc'>%s</ul>" % "".join(toc)
+ add_header = "Lekcja: " if self.options['wldoc'].book_info.type in ('course', 'synthetic') else ''
+ return "<h1 class='title'>%s" % add_header, "</h1>" + toc
+
+ @tagged("h2")
+ def handle_naglowek_rozdzial(self, element):
+ return "", "".join(tag_open_close("a", name=self.naglowek_to_anchor(element)))
+