MCPcopy
hub / github.com/Python-Markdown/markdown / parseBlocks

Method parseBlocks

markdown/blockparser.py:138–160  ·  view source on GitHub ↗

Process blocks of Markdown text and attach to given `etree` node. Given a list of `blocks`, each `blockprocessor` is stepped through until there are no blocks left. While an extension could potentially call this method directly, it's generally expected to be used in

(self, parent: etree.Element, blocks: list[str])

Source from the content-addressed store, hash-verified

136 self.parseBlocks(parent, text.split('\n\n'))
137
138 def parseBlocks(self, parent: etree.Element, blocks: list[str]) -> None:
139 """ Process blocks of Markdown text and attach to given `etree` node.
140
141 Given a list of `blocks`, each `blockprocessor` is stepped through
142 until there are no blocks left. While an extension could potentially
143 call this method directly, it's generally expected to be used
144 internally.
145
146 This is a public method as an extension may need to add/alter
147 additional `BlockProcessors` which call this method to recursively
148 parse a nested block.
149
150 Arguments:
151 parent: The parent element.
152 blocks: The blocks of text to parse.
153
154 """
155 while blocks:
156 for processor in self.blockprocessors:
157 if processor.test(parent, blocks[0]):
158 if processor.run(parent, blocks) is not False:
159 # run returns True or None
160 break

Callers 11

parseChunkMethod · 0.95
runMethod · 0.80
create_itemMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
parse_element_contentMethod · 0.80
runMethod · 0.80
create_itemMethod · 0.80
runMethod · 0.80

Calls 2

testMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected