X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/893924685f2bc659cb71d7c68501fc3cf1daa0f0..565aa32ff31bdbe6e2aaf9f47b124ac1f883a990:/librarian/pyhtml.py?ds=inline
diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py
index 7047cc9..163d11c 100644
--- a/librarian/pyhtml.py
+++ b/librarian/pyhtml.py
@@ -4,7 +4,7 @@
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from lxml import etree
-from librarian import IOFile, RDFNS, DCNS, Format
+from librarian import IOFile, Format
from xmlutils import Xmill, tag, tagged, ifoption, tag_open_close
from librarian import functions
import re
@@ -13,21 +13,12 @@ from copy import deepcopy
IMAGE_THUMB_WIDTH = 300
-try:
- from fnpdjango.utils.text.slughifi import slughifi
- def naglowek_to_anchor(naglowek):
- return slughifi(naglowek.text)
-except ImportError:
- from urllib import quote
- def naglowek_to_anchor(naglowek):
- return quote(re.sub(r" +", " ", naglowek.text.strip()))
-
-
class EduModule(Xmill):
def __init__(self, options=None):
super(EduModule, self).__init__(options)
self.activity_counter = 0
+ self.activity_last = None
self.exercise_counter = 0
# text filters
@@ -36,7 +27,7 @@ class EduModule(Xmill):
txt = txt.replace("/\n", "
\n")
return txt
self.register_text_filter(functions.substitute_entities)
- self.register_text_filter(swap_endlines)
+ self.register_escaped_text_filter(swap_endlines)
@tagged('div', 'stanza')
def handle_strofa(self, element):
@@ -58,18 +49,21 @@ class EduModule(Xmill):
handle_podtytul = tag("span", "subtitle")
handle_naglowek_akt = handle_naglowek_czesc = handle_srodtytul = tag("h2")
handle_naglowek_scena = tag('h2')
- handle_naglowek_osoba = handle_naglowek_podrozdzial = tag('h3')
+ handle_naglowek_osoba = tag('h3')
handle_akap = handle_akap_dialog = handle_akap_cd = tag('p', 'paragraph')
handle_wyroznienie = tag('em')
handle_tytul_dziela = tag('em', 'title')
handle_slowo_obce = tag('em', 'foreign')
+ def naglowek_to_anchor(self, naglowek):
+ return self.options['urlmapper'].naglowek_to_anchor(naglowek)
+
def handle_nazwa_utworu(self, element):
toc = []
for naglowek in element.getparent().findall('.//naglowek_rozdzial'):
a = etree.Element("a")
- a.attrib["href"] = "#" + naglowek_to_anchor(naglowek)
+ a.attrib["href"] = "#" + self.naglowek_to_anchor(naglowek)
a.text = naglowek.text
atxt = etree.tostring(a, encoding=unicode)
toc.append("
%s
%s min