From: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Date: Wed, 24 Nov 2010 09:04:13 +0000 (+0100)
Subject: annotations and motifs forbidden in nota_red
X-Git-Tag: 1.7~248
X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/be641fe5a98107edfe4fa423337c0bf8a06a9a4b

annotations and motifs forbidden in nota_red
---

diff --git a/librarian/html.py b/librarian/html.py
index c942fe7..f7bd618 100644
--- a/librarian/html.py
+++ b/librarian/html.py
@@ -49,6 +49,8 @@ def transform(input, output_filename=None, is_file=True, \
             document = WLDocument.from_string(input, True, \
                 parse_dublincore=parse_dublincore)
 
+        document.clean_ed_note()
+
         result = document.transform(style, **options)
         del document # no longer needed large object :)
 
diff --git a/librarian/parser.py b/librarian/parser.py
index b470957..3f9f710 100644
--- a/librarian/parser.py
+++ b/librarian/parser.py
@@ -119,4 +119,14 @@ class WLDocument(object):
             except Exception, e:
                 unmerged.append( repr( (key, xpath, e) ) )
 
-        return unmerged
\ No newline at end of file
+        return unmerged
+
+    def clean_ed_note(self):
+        """ deletes forbidden tags from nota_red """
+
+        for node in self.edoc.xpath('|'.join('//nota_red//%s' % tag for tag in
+                    ('pa', 'pe', 'pr', 'pt', 'begin', 'end', 'motyw'))):
+            tail = node.tail
+            node.clear()
+            node.tag = 'span'
+            node.tail = tail