1. Nikolaj Šujskij
  2. rst2epub

Commits

Nikolaj Šujskij  committed 4dd7c21

Fix (quick'n'dirty) Unicode problems

  • Participants
  • Parent commits d3d1753
  • Branches default

Comments (0)

Files changed (2)

File rst2epub/epub.py

View file
  • Ignore whitespace
         self.ncx = NavigationControl(self.identifier, 1, self.title)
 
     def add_content(self, content):
-        self.content = content
+        self.content = content.encode('utf-8')
 
     def write(self):
         self.file.writestr(self.container.path, self.container.to_xml())

File rst2epub/rst.py

View file
  • Ignore whitespace
 
             parser = docutils.parsers.rst.Parser()
 
-            parser.parse(txt.read(), document)
+            text = txt.read()
+            text = text.decode('utf-8')
+            parser.parse(text, document)
             self.dom = document.asdom()
 
     def _get_field_value(self, field_name, path_to_value):
         # return self._get_field_value("Contact", "./field_body/paragraph//*")
 
     def get_title(self):
-        element = ElementTree.fromstring(self.dom.toxml())
+        element = ElementTree.fromstring(self.dom.toxml().encode('utf-8'))
         return element.findtext("section/title")
 
     def to_xhtml(self):
             body = publish_parts(source.read(), writer_name='html',
                                     settings_overrides=settings)['html_body']
             content = content % (self.get_title(), body)
+            content = content.encode('utf-8')
 
             # FIXME name attributes are not allowed
             dom = parseString(content)