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

Method run

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

Source from the content-addressed store, hash-verified

255 return block.startswith(' '*self.tab_length)
256
257 def run(self, parent: etree.Element, blocks: list[str]) -> None:
258 sibling = self.lastChild(parent)
259 block = blocks.pop(0)
260 theRest = ''
261 if (sibling is not None and sibling.tag == "pre" and
262 len(sibling) and sibling[0].tag == "code"):
263 # The previous block was a code block. As blank lines do not start
264 # new code blocks, append this block to the previous, adding back
265 # line breaks removed from the split into a list.
266 code = sibling[0]
267 block, theRest = self.detab(block)
268 code.text = util.AtomicString(
269 '{}\n{}\n'.format(code.text, util.code_escape(block.rstrip()))
270 )
271 else:
272 # This is a new code block. Create the elements and insert text.
273 pre = etree.SubElement(parent, 'pre')
274 code = etree.SubElement(pre, 'code')
275 block, theRest = self.detab(block)
276 code.text = util.AtomicString('%s\n' % util.code_escape(block.rstrip()))
277 if theRest:
278 # This block contained unindented line(s) after the first indented
279 # line. Insert these lines as the first block of the master blocks
280 # list for future processing.
281 blocks.insert(0, theRest)
282
283
284class BlockQuoteProcessor(BlockProcessor):

Callers

nothing calls this directly

Calls 2

lastChildMethod · 0.80
detabMethod · 0.45

Tested by

no test coverage detected