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

Method run

markdown/extensions/codehilite.py:267–288  ·  view source on GitHub ↗

Find code blocks and store in `htmlStash`.

(self, root: etree.Element)

Source from the content-addressed store, hash-verified

265 return text
266
267 def run(self, root: etree.Element) -> None:
268 """ Find code blocks and store in `htmlStash`. """
269 blocks = root.iter('pre')
270 for block in blocks:
271 if len(block) == 1 and block[0].tag == 'code':
272 local_config = self.config.copy()
273 text = block[0].text
274 if text is None:
275 continue
276 code = CodeHilite(
277 self.code_unescape(text),
278 tab_length=self.md.tab_length,
279 style=local_config.pop('pygments_style', 'default'),
280 **local_config
281 )
282 placeholder = self.md.htmlStash.store(code.hilite())
283 # Clear code block in `etree` instance
284 block.clear()
285 # Change to `p` element which will later
286 # be removed when inserting raw html
287 block.tag = 'p'
288 block.text = placeholder
289
290
291class CodeHiliteExtension(Extension):

Callers

nothing calls this directly

Calls 4

code_unescapeMethod · 0.95
hiliteMethod · 0.95
CodeHiliteClass · 0.85
storeMethod · 0.80

Tested by

no test coverage detected