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

Method run

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

Source from the content-addressed store, hash-verified

596 return True
597
598 def run(self, parent: etree.Element, blocks: list[str]) -> bool:
599 block = blocks.pop(0)
600 m = self.RE.search(block)
601 if m:
602 start = end = m.start()
603 # Record the definitions on the following lines in this pass rather
604 # than one per pass through the block processors. A definition after
605 # the first which spans lines is left for the next pass, as another
606 # processor may claim part of it.
607 for m in self.RE.finditer(block, start):
608 if m.start() > start and (block[end:m.start()].strip('\n') or '\n' in m.group()):
609 break
610 id = m.group(1).strip().lower()
611 link = m.group(2).lstrip('<').rstrip('>')
612 title = m.group(5) or m.group(6)
613 self.parser.md.references[id] = (link, title)
614 end = m.end()
615 if block[end:].strip():
616 # Add any content after match back to blocks as separate block
617 blocks.insert(0, block[end:].lstrip('\n'))
618 if block[:start].strip():
619 # Add any content before match back to blocks as separate block
620 blocks.insert(0, block[:start].rstrip('\n'))
621 return True
622 # No match. Restore block.
623 blocks.insert(0, block)
624 return False
625
626
627class ParagraphProcessor(BlockProcessor):

Callers

nothing calls this directly

Calls 2

searchMethod · 0.80
finditerMethod · 0.80

Tested by

no test coverage detected