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

Method add_char

src/docx/oxml/text/run.py:287–301  ·  view source on GitHub ↗

Process next character of input through finite state maching (FSM). There are two possible states, buffer pending and not pending, but those are hidden behind the `.flush()` method which must be called at the end of text to ensure any pending ` ` element is written.

(self, char: str)

Source from the content-addressed store, hash-verified

285 self.flush()
286
287 def add_char(self, char: str):
288 """Process next character of input through finite state maching (FSM).
289
290 There are two possible states, buffer pending and not pending, but those are
291 hidden behind the `.flush()` method which must be called at the end of text to
292 ensure any pending `<w:t>` element is written.
293 """
294 if char == "\t":
295 self.flush()
296 self._r.add_tab()
297 elif char in "\r\n":
298 self.flush()
299 self._r.add_br()
300 else:
301 self._bfr.append(char)
302
303 def flush(self):
304 text = "".join(self._bfr)

Callers 1

add_textMethod · 0.95

Calls 3

flushMethod · 0.95
add_tabMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected