MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / run

Method run

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

Source from the content-addressed store, hash-verified

127 )
128
129 def run(self, parent, blocks):
130 block = blocks.pop(0)
131 level, sibling = self.get_level(parent, block)
132 block = self.looseDetab(block, level)
133
134 self.parser.state.set('detabbed')
135 if parent.tag in self.ITEM_TYPES:
136 # The parent is already a li. Just parse the child block.
137 self.parser.parseBlocks(parent, [block])
138 elif sibling.tag in self.ITEM_TYPES:
139 # The sibling is a li. Use it as parent.
140 self.parser.parseBlocks(sibling, [block])
141 elif len(sibling) and sibling[-1].tag in self.ITEM_TYPES:
142 # The parent is a list (``ol`` or ``ul``) which has children.
143 # Assume the last child li is the parent of this block.
144 if sibling[-1].text:
145 # If the parent li has text, that text needs to be moved to a p
146 block = '%s\n\n%s' % (sibling[-1].text, block)
147 sibling[-1].text = ''
148 self.parser.parseChunk(sibling[-1], block)
149 else:
150 self.create_item(sibling, block)
151 self.parser.state.reset()
152
153 def create_item(self, parent, block):
154 """ Create a new li and parse the block with it as the parent. """

Callers

nothing calls this directly

Calls 8

get_levelMethod · 0.95
create_itemMethod · 0.95
looseDetabMethod · 0.80
parseBlocksMethod · 0.80
parseChunkMethod · 0.80
popMethod · 0.45
setMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected