MCPcopy Index your code
hub / github.com/ronreiter/interactive-tutorials / run

Method run

markdown/blockprocessors.py:342–361  ·  view source on GitHub ↗
(self, parent, blocks)

Source from the content-addressed store, hash-verified

340 return bool(self.RE.search(block))
341
342 def run(self, parent, blocks):
343 block = blocks.pop(0)
344 m = self.RE.search(block)
345 if m:
346 before = block[:m.start()] # All lines before header
347 after = block[m.end():] # All lines after header
348 if before:
349 # As the header was not the first line of the block and the
350 # lines before the header must be parsed first,
351 # recursively parse this lines as a block.
352 self.parser.parseBlocks(parent, [before])
353 # Create header using named groups from RE
354 h = markdown.etree.SubElement(parent, 'h%d' % len(m.group('level')))
355 h.text = m.group('header').strip()
356 if after:
357 # Insert remaining lines as first block for future parsing.
358 blocks.insert(0, after)
359 else:
360 # This should never happen, but just in case...
361 message(CRITICAL, "We've got a problem header!")
362
363
364class SetextHeaderProcessor(BlockProcessor):

Callers

nothing calls this directly

Calls 6

messageFunction · 0.85
parseBlocksMethod · 0.80
popMethod · 0.45
startMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected