use dejavu serif for cyrrylic
[librarian.git] / librarian / epub.py
index e25ce8f..a5607f7 100644 (file)
@@ -82,7 +82,8 @@ def replace_characters(node):
     def replace_chars(text):
         if text is None:
             return None
-        return text.replace("---", u"\u2014")\
+        return text.replace(u"\ufeff", u"")\
+                   .replace("---", u"\u2014")\
                    .replace("--", u"\u2013")\
                    .replace(",,", u"\u201E")\
                    .replace('"', u"\u201D")\
@@ -275,6 +276,8 @@ def transform(provider, slug=None, file_path=None, output_file=None, output_dir=
     def transform_file(input_xml, chunk_counter=1, first=True):
         """ processes one input file and proceeds to its children """
 
+        replace_characters(input_xml.getroot())
+
         children = [child.text for child in input_xml.findall('.//'+DCNS('relation.hasPart'))]
 
         # every input file will have a TOC entry,
@@ -307,8 +310,6 @@ def transform(provider, slug=None, file_path=None, output_file=None, output_dir=
                 main_text = None
 
         if main_text is not None:
-            replace_characters(main_text)
-
             for chunk_xml in chop(main_text):
                 chunk_html, chunk_toc, chunk_chars = transform_chunk(chunk_xml, chunk_counter, annotations)
                 toc.extend(chunk_toc)