示例#1
0
文件: reader.py 项目: zav90/flaskr
    def build(self):
        doc = document.Document()

        ctx = DocBuilder(doc, self.clean_paragraphs)

        for bit in self.group.flatten():
            typeName = type(bit).__name__
            getattr(ctx, "handle_%s" % typeName)(bit)

        ctx.flushParagraph()

        return doc
示例#2
0
 def go(self):
     soup = BeautifulSoup.BeautifulSoup(
         self.source,
         convertEntities=BeautifulSoup.BeautifulSoup.HTML_ENTITIES,
         fromEncoding=self.encoding,
         smartQuotesTo=None)
     # Make sure the document content doesn't use multi-lines
     soup = self.format(soup)
     doc = document.Document()
     if self.css_source:
         self.css = CSS(self.css_source)
     else:
         self.css = CSS()  # empty css
     self.process_into(soup, doc)
     return doc