Пример #1
0
    def boxes(element):
        current_text_elements = []
        
        for child in element:            
            if isinstance(child, xsc.Text) or style(child).display == "inline":
                current_text_elements.append(child)
            else:
                # It’s a block element
                if len(current_text_elements) > 0:
                    yield paragraph(current_text_elements)
                    current_text_elements = []

                yield elements.box(boxes(child), style=style(child))
                
        if len(current_text_elements) > 0:
            yield paragraph(current_text_elements)
Пример #2
0
 def box(self):
     paragraphs = map(self.paragraph, self.parts)
     paragraphs = filter(lambda p: len(p) > 0, paragraphs)
     return elements.box(paragraphs, style=self.style)