Ejemplo n.º 1
0
    def process_text(self, node):
        """
        Return a pyth Text object from a BeautifulSoup node or None if
        the text is empty.
        """
        text = node.string.strip()
        if not text:
            return

        # Set all the properties
        properties = dict()
        if self.is_bold(node):
            properties['bold'] = True
        if self.is_italic(node):
            properties['italic'] = True
        if self.url(node):
            properties['url'] = self.url(node)
        if self.is_sub(node):
            properties['sub'] = True
        if self.is_super(node):
            properties['super'] = True

        content = [node.string]

        return document.Text(properties, content)
Ejemplo n.º 2
0
    def flushRun(self):
        if self.block is None:
            self.block = document.Paragraph()

        self.block.content.append(
            document.Text(self.propStack[-1].copy(), [u"".join(self.run)]))

        self.run[:] = []
Ejemplo n.º 3
0
    def flushRun(self):
        if self.block is None:
            self.block = document.Paragraph()

        if self.isImage:
            self.block.content.append(
                document.Image(self.propStack[-1].copy(),
                               [str("".join(self.run))]))
            self.isImage = False
        else:
            self.block.content.append(
                document.Text(self.propStack[-1].copy(), [u"".join(self.run)]))

        self.run[:] = []