MCPcopy Index your code
hub / github.com/python-openxml/python-docx / add_paragraph

Method add_paragraph

src/docx/blkcntnr.py:45–59  ·  view source on GitHub ↗

Return paragraph newly added to the end of the content in this container. The paragraph has `text` in a single run if present, and is given paragraph style `style`. If `style` is |None|, no paragraph style is applied, which has the same effect as applying the 'Norma

(self, text: str = "", style: str | ParagraphStyle | None = None)

Source from the content-addressed store, hash-verified

43 self._element = element
44
45 def add_paragraph(self, text: str = "", style: str | ParagraphStyle | None = None) -> Paragraph:
46 """Return paragraph newly added to the end of the content in this container.
47
48 The paragraph has `text` in a single run if present, and is given paragraph
49 style `style`.
50
51 If `style` is |None|, no paragraph style is applied, which has the same effect
52 as applying the 'Normal' style.
53 """
54 paragraph = self._add_paragraph()
55 if text:
56 paragraph.add_run(text)
57 if style is not None:
58 paragraph.style = style
59 return paragraph
60
61 def add_table(self, rows: int, cols: int, width: Length) -> Table:
62 """Return table of `width` having `rows` rows and `cols` columns.

Callers

nothing calls this directly

Calls 2

_add_paragraphMethod · 0.95
add_runMethod · 0.80

Tested by

no test coverage detected