Workaround was bad.
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 20 Jun 2013 11:37:37 +0000 (13:37 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 20 Jun 2013 11:37:37 +0000 (13:37 +0200)
librarian/pyhtml.py
librarian/xmlutils.py

index 7047cc9..096e1f6 100644 (file)
@@ -36,7 +36,7 @@ class EduModule(Xmill):
                 txt = txt.replace("/\n", "<br/>\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):
index 8890f4e..345e011 100644 (file)
@@ -17,17 +17,23 @@ class Xmill(object):
         if options:
             self._options.append(options)
         self.text_filters = []
+        self.escaped_text_filters = []
 
     def register_text_filter(self, fun):
         self.text_filters.append(fun)
 
     def filter_text(self, text):
+        for flt in self.text_filters:
+            if text is None:
+                return None
+            else:
+                text = flt(text)
         # TODO: just work on the tree and let lxml handle escaping.
         e = etree.Element("x")
         e.text = text
         # This whole mixing text with ML is so wrong.
         output = etree.tostring(e, encoding=unicode)[3:-4]
-        for flt in self.text_filters:
+        for flt in self.escaped_text_filters:
             output = flt(output)
         return output