示例#1
0
    def _append_line_break(cls, element, container):
        """
        <br> Creates a break item inside the given container.
        """
        element.tail = replace_whitespaces(element.tail)
        element.tail = element.tail.lstrip()

        run = container.add_run()
        run.add_break(break_type=WD_BREAK.LINE_CLEAR_RIGHT)
        return container
示例#2
0
 def _append_emphasis(cls, text, element, container):
     """
     <em> Creates an italic text run inside the paragraph container.
     Appends remainder of text as a additional run
     """
     text = replace_whitespaces(text)
     run = container.add_run(text=text)
     run.italic = True
     if element.getparent().tag == 'strong':
         run.bold = True
     return container
示例#3
0
    def _append_list_item(cls, element, text, container):
        """
        <li> Create a list item element inside a docx container.
        Style it according to its parents list type.
        """
        text = replace_whitespaces(text)
        text = '' if text == ' ' else text

        style = _list_style.get(element.getparent().tag, 'ListBullet')
        container.style = style
        container.add_run(text)

        return container
示例#4
0
    def _append_paragraph(cls, text, element, container):
        """
        <p> creates a paragraph element inside a docx container element.
        """
        text = replace_whitespaces(text)
        if not text:
            return container

        style = None
        if element.getparent().tag == 'blockquote':
            style = 'IntenseQuote'

        container.add_run(text=text, style=style)
        return container