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

Method add_run

src/docx/text/paragraph.py:30–44  ·  view source on GitHub ↗

Append run containing `text` and having character-style `style`. `text` can contain tab (``\\t``) characters, which are converted to the appropriate XML form for a tab. `text` can also include newline (``\\n``) or carriage return (``\\r``) characters, each of which is conver

(self, text: str | None = None, style: str | CharacterStyle | None = None)

Source from the content-addressed store, hash-verified

28 self._p = self._element = p
29
30 def add_run(self, text: str | None = None, style: str | CharacterStyle | None = None) -> Run:
31 """Append run containing `text` and having character-style `style`.
32
33 `text` can contain tab (``\\t``) characters, which are converted to the
34 appropriate XML form for a tab. `text` can also include newline (``\\n``) or
35 carriage return (``\\r``) characters, each of which is converted to a line
36 break. When `text` is `None`, the new run is empty.
37 """
38 r = self._p.add_r()
39 run = Run(r, self)
40 if text:
41 run.text = text
42 if style:
43 run.style = style
44 return run
45
46 @property
47 def alignment(self) -> WD_PARAGRAPH_ALIGNMENT | None:

Calls 1

RunClass · 0.90

Tested by 2

text_set_fixtureMethod · 0.76