Step through tree to find known abbreviations.
(self, root: etree.Element)
| 125 | el.tail = tail |
| 126 | |
| 127 | def run(self, root: etree.Element) -> etree.Element | None: |
| 128 | ''' Step through tree to find known abbreviations. ''' |
| 129 | if not self.abbrs: |
| 130 | # No abbreviations defined. Skip running processor. |
| 131 | return |
| 132 | # Build and compile regex |
| 133 | abbr_list = list(self.abbrs.keys()) |
| 134 | abbr_list.sort(key=len, reverse=True) |
| 135 | self.RE = re.compile(f"\\b(?:{ '|'.join(re.escape(key) for key in abbr_list) })\\b") |
| 136 | # Step through tree and modify on matches |
| 137 | self.iter_element(root) |
| 138 | |
| 139 | |
| 140 | class AbbrBlockprocessor(BlockProcessor): |
nothing calls this directly
no test coverage detected