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)
| 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) |