(self, parent: etree.Element, block: str)
| 470 | RE = re.compile(r'(?:^|\n)(?P<level>#{1,6})(?P<header>(?:\\.|[^\\#]|#+(?=[^#\n]))*?)#*(?:\n|$)') |
| 471 | |
| 472 | def test(self, parent: etree.Element, block: str) -> bool: |
| 473 | # Check for a line starting with `#` before running the regex, which is |
| 474 | # slow to scan long blocks. |
| 475 | return (block.startswith('#') or '\n#' in block) and bool(self.RE.search(block)) |
| 476 | |
| 477 | def run(self, parent: etree.Element, blocks: list[str]) -> None: |
| 478 | block = blocks.pop(0) |