MCPcopy Create free account
hub / github.com/NanoNets/docstrange / replace_code_block

Method replace_code_block

docstrange/result.py:413–417  ·  view source on GitHub ↗
(match)

Source from the content-addressed store, hash-verified

411 """Process fenced code blocks."""
412 # Handle ```code blocks```
413 def replace_code_block(match):
414 language = match.group(1) or ''
415 code = match.group(2)
416 lang_class = f' class="language-{language}"' if language else ''
417 return f'<pre><code{lang_class}>{self._escape_html(code)}</code></pre>'
418
419 text = re.sub(r'```(\w+)?\n(.*?)\n```', replace_code_block, text, flags=re.DOTALL)
420

Callers

nothing calls this directly

Calls 1

_escape_htmlMethod · 0.95

Tested by

no test coverage detected