MCPcopy Index your code
hub / github.com/Python-Markdown/markdown / run

Method run

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

Source from the content-addressed store, hash-verified

290 return bool(self.RE.search(block)) and not util.nearing_recursion_limit()
291
292 def run(self, parent: etree.Element, blocks: list[str]) -> None:
293 block = blocks.pop(0)
294 m = self.RE.search(block)
295 if m:
296 before = block[:m.start()] # Lines before blockquote
297 # Pass lines before blockquote in recursively for parsing first.
298 self.parser.parseBlocks(parent, [before])
299 # Remove `> ` from beginning of each line.
300 block = '\n'.join(
301 [self.clean(line) for line in block[m.start():].split('\n')]
302 )
303 sibling = self.lastChild(parent)
304 if sibling is not None and sibling.tag == "blockquote":
305 # Previous block was a blockquote so set that as this blocks parent
306 quote = sibling
307 else:
308 # This is a new blockquote. Create a new parent element.
309 quote = etree.SubElement(parent, 'blockquote')
310 # Recursively parse block with blockquote as parent.
311 # change parser state so blockquotes embedded in lists use `p` tags
312 self.parser.state.set('blockquote')
313 self.parser.parseChunk(quote, block)
314 self.parser.state.reset()
315
316 def clean(self, line: str) -> str:
317 """ Remove `>` from beginning of a line. """

Callers

nothing calls this directly

Calls 6

cleanMethod · 0.95
parseBlocksMethod · 0.80
lastChildMethod · 0.80
setMethod · 0.80
parseChunkMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected