Example #1
0
    def depart_title(self, node):

        CustomLaTeXTranslator.depart_title(self, node)
        parent = node.parent
        if isinstance(parent, nodes.section) and self.sectionlevel == 1:
            def has_content(node):
                try:
                    secondnode = node.children[1]
                except IndexError:
                    return False
                if isinstance(secondnode, nodes.section):
                    return False
                elif isinstance(secondnode, addnodes.start_of_file):
                    return not isinstance(secondnode.children[0], nodes.section)
                else:
                    return True
            if not has_content(parent):
                self.body.append('\n\\nocontent\n')
Example #2
0
 def encode(self, text):
     text = CustomLaTeXTranslator.encode(self, text)
     if not isinstance(text, unicode):
         decoded = True
         text = text.decode('utf-8')
     else:
         decoded = False
     text = text.replace(u"”", u"''") \
         .replace(u"“", u"``") \
         .replace(u"–", u"--") \
         .replace(u"’", u"'")
     if decoded:
         text = text.encode('utf-8')
     return text