CT_P
paper-docx 0.2.0 API reference
<w:p> element, containing the properties and text for a paragraph.
Attributes
add_r
attributeadd_rCallable[[], CT_R]alignment
attributealignmentWD_PARAGRAPH_ALIGNMENT | NoneThe value of the <w:jc> grandchild element or None if not present.
get_or_add_pPr
attributeget_or_add_pPrCallable[[], CT_PPr]hyperlink
attributehyperlink= ZeroOrMore('w:hyperlink')hyperlink_lst
attributehyperlink_lstList[CT_Hyperlink]inner_content_elements
attributeinner_content_elementsList[CT_R | CT_Hyperlink]Run and hyperlink children of the w:p element, in document order.
lastRenderedPageBreaks
attributelastRenderedPageBreaksList[CT_LastRenderedPageBreak]All w:lastRenderedPageBreak descendants of this paragraph.
Rendered page-breaks commonly occur in a run but can also occur in a run inside a hyperlink. This returns both.
pPr
attributepPrCT_PPr | None= ZeroOrOne('w:pPr')r
attributer= ZeroOrMore('w:r')r_lst
attributer_lstList[CT_R]style
attributestylestr | NoneString contained in w:val attribute of ./w:pPr/w:pStyle grandchild.
None if not present.
text
attributetextThe textual content of this paragraph.
Inner-content child elements like w:r and w:hyperlink are translated to
their text equivalent.
xml
attributexmlstrXML string for this element, suitable for testing purposes.
Pretty printed for readability and without an XML declaration at the top.
Functions
add_p_before
funcadd_p_before() -> CT_PReturn a new <w:p> element inserted directly prior to this one.
Returns
docx.oxml.text.paragraph.CT_Pclear_content
funcclear_content()Remove all child elements, except the <w:pPr> element if present.
first_child_found_in
funcfirst_child_found_in(*tagnames: str) -> _Element | NoneFirst child with tag in tagnames, or None if not found.
paramtagnamesstr= ()Returns
lxml.etree._Element | Noneinsert_element_before
funcinsert_element_before(elm: ElementBase, *tagnames: str)paramelmElementBaseparamtagnamesstr= ()remove_all
funcremove_all(*tagnames: str) -> NoneRemove child elements with tagname (e.g. "a:p") in tagnames.
paramtagnamesstr= ()Returns
Noneset_sectPr
funcset_sectPr(sectPr: CT_SectPr)Unconditionally replace or add sectPr as grandchild in correct sequence.
paramsectPrCT_SectPrxpath
funcxpath(xpath_str: str) -> AnyOverride of lxml _Element.xpath() method.
Provides standard Open XML namespace mapping (nsmap) in centralized location.
paramxpath_strstrReturns
typing.Any