paragraph
paragraph
¶
Custom element classes related to paragraphs (CT_P).
CT_P
¶
Bases: BaseOxmlElement
<w:p> element, containing the properties and text for a paragraph.
alignment
property
writable
¶
alignment: WD_PARAGRAPH_ALIGNMENT | None
The value of the <w:jc> grandchild element or None if not present.
inner_content_elements
property
¶
inner_content_elements: List[CT_R | CT_Hyperlink]
Run and hyperlink children of the w:p element, in document order.
A run-level w:sdt (content control) is looked through, so the runs it wraps
appear here in its place.
lastRenderedPageBreaks
property
¶
lastRenderedPageBreaks: List[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.
style
property
writable
¶
String contained in w:val attribute of ./w:pPr/w:pStyle grandchild.
None if not present.
text
property
¶
The textual content of this paragraph.
Inner-content child elements like w:r and w:hyperlink are translated to
their text equivalent, including those wrapped in a run-level w:sdt.
assert_deletable
¶
Raise ValueError if removing this paragraph would invalidate the document.
A w:tc must contain at least one block-level element, so the last paragraph of
a table cell cannot simply be removed.
Source code in src/docx/oxml/text/paragraph.py
add_bookmark_around_content
¶
add_bookmark_around_content(
id: int, name: str
) -> CT_BookmarkStart
Wrap the inner content of this paragraph in a bookmark named name.
The w:bookmarkStart goes after w:pPr and before the first run; the
w:bookmarkEnd goes at the end of the paragraph.
Source code in src/docx/oxml/text/paragraph.py
add_p_before
¶
add_p_before() -> CT_P
Return a new <w:p> element inserted directly prior to this one.