Process blocks that are empty or start with an empty line.
| 548 | |
| 549 | |
| 550 | class EmptyBlockProcessor(BlockProcessor): |
| 551 | """ Process blocks that are empty or start with an empty line. """ |
| 552 | |
| 553 | def test(self, parent: etree.Element, block: str) -> bool: |
| 554 | return not block or block.startswith('\n') |
| 555 | |
| 556 | def run(self, parent: etree.Element, blocks: list[str]) -> None: |
| 557 | block = blocks.pop(0) |
| 558 | filler = '\n\n' |
| 559 | if block: |
| 560 | # Starts with empty line |
| 561 | # Only replace a single line. |
| 562 | filler = '\n' |
| 563 | # Save the rest for later. |
| 564 | theRest = block[1:] |
| 565 | if theRest: |
| 566 | # Add remaining lines to master blocks for later. |
| 567 | blocks.insert(0, theRest) |
| 568 | sibling = self.lastChild(parent) |
| 569 | if (sibling is not None and sibling.tag == 'pre' and |
| 570 | len(sibling) and sibling[0].tag == 'code'): |
| 571 | # Last block is a code block. Append to preserve whitespace. |
| 572 | sibling[0].text = util.AtomicString( |
| 573 | '{}{}'.format(sibling[0].text, filler) |
| 574 | ) |
| 575 | |
| 576 | |
| 577 | class ReferenceProcessor(BlockProcessor): |
no outgoing calls
no test coverage detected
searching dependent graphs…