MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / run

Method run

markdown/blockprocessors.py:622–651  ·  view source on GitHub ↗
(self, parent: etree.Element, blocks: list[str])

Source from the content-addressed store, hash-verified

620 return True
621
622 def run(self, parent: etree.Element, blocks: list[str]) -> None:
623 block = blocks.pop(0)
624 if block.strip():
625 # Not a blank block. Add to parent, otherwise throw it away.
626 if self.parser.state.isstate('list'):
627 # The parent is a tight-list.
628 #
629 # Check for any children. This will likely only happen in a
630 # tight-list when a header isn't followed by a blank line.
631 # For example:
632 #
633 # * # Header
634 # Line 2 of list item - not part of header.
635 sibling = self.lastChild(parent)
636 if sibling is not None:
637 # Insert after sibling.
638 if sibling.tail:
639 sibling.tail = '{}\n{}'.format(sibling.tail, block)
640 else:
641 sibling.tail = '\n%s' % block
642 else:
643 # Append to parent.text
644 if parent.text:
645 parent.text = '{}\n{}'.format(parent.text, block)
646 else:
647 parent.text = block.lstrip()
648 else:
649 # Create a regular paragraph
650 p = etree.SubElement(parent, 'p')
651 p.text = block.lstrip()

Callers

nothing calls this directly

Calls 2

isstateMethod · 0.80
lastChildMethod · 0.80

Tested by

no test coverage detected