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

Method run

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

isstateMethod · 0.80
lastChildMethod · 0.80

Tested by

no test coverage detected