Paper Office
paper-docxAPI referenceoxml.text.run

CT_R

paper-docx 0.2.0 API reference

<w:r> element, containing the properties and text for a run.

Attributes

add_br

attributeadd_brCallable[[], CT_Br]

add_tab

attributeadd_tabCallable[[], CT_TabStop]

br

attributebr
= ZeroOrMore('w:br')

cr

attributecr
= ZeroOrMore('w:cr')

drawing

attributedrawing
= ZeroOrMore('w:drawing')

get_or_add_rPr

attributeget_or_add_rPrCallable[[], CT_RPr]

inner_content_items

attributeinner_content_itemsList[str | CT_Drawing | CT_LastRenderedPageBreak]

Text of run, possibly punctuated by w:lastRenderedPageBreak elements.

lastRenderedPageBreaks

attributelastRenderedPageBreaksList[CT_LastRenderedPageBreak]

All w:lastRenderedPageBreaks descendants of this run.

rPr

attributerPrCT_RPr | None
= ZeroOrOne('w:rPr')

style

attributestylestr | None

String contained in w:val attribute of w:rStyle grandchild.

None if that element is not present.

t

attributet
= ZeroOrMore('w:t')

tab

attributetab
= ZeroOrMore('w:tab')

text

attributetextstr

The textual content of this run.

Inner-content child elements like w:tab are translated to their text equivalent.

xml

attributexmlstr

XML string for this element, suitable for testing purposes.

Pretty printed for readability and without an XML declaration at the top.

Functions

add_drawing

funcadd_drawing(inline_or_anchor: CT_Inline | CT_Anchor) -> CT_Drawing

Return newly appended CT_Drawing (w:drawing) child element.

The w:drawing element has inline_or_anchor as its child.

paraminline_or_anchorCT_Inline | CT_Anchor

Returns

docx.oxml.drawing.CT_Drawing

add_t

funcadd_t(text: str) -> CT_Text

Return a newly added <w:t> element containing text.

paramtextstr

Returns

docx.oxml.text.run.CT_Text

clear_content

funcclear_content() -> None

Remove all child elements except a w:rPr element if present.

Returns

None

first_child_found_in

funcfirst_child_found_in(*tagnames: str) -> _Element | None

First child with tag in tagnames, or None if not found.

paramtagnamesstr
= ()

Returns

lxml.etree._Element | None

insert_comment_range_end_and_reference_below

funcinsert_comment_range_end_and_reference_below(comment_id: int) -> None

Insert a w:commentRangeEnd and w:commentReference element after this run.

The w:commentRangeEnd element is the immediate sibling of this w:r and is followed by a w:r containing the w:commentReference element.

paramcomment_idint

Returns

None

insert_comment_range_start_above

funcinsert_comment_range_start_above(comment_id: int) -> None

Insert a w:commentRangeStart element with comment_id before this run.

paramcomment_idint

Returns

None

insert_element_before

funcinsert_element_before(elm: ElementBase, *tagnames: str)
paramelmElementBase
paramtagnamesstr
= ()

remove_all

funcremove_all(*tagnames: str) -> None

Remove child elements with tagname (e.g. "a:p") in tagnames.

paramtagnamesstr
= ()

Returns

None

xpath

funcxpath(xpath_str: str) -> Any

Override of lxml _Element.xpath() method.

Provides standard Open XML namespace mapping (nsmap) in centralized location.

paramxpath_strstr

Returns

typing.Any

On this page