Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat: enhance code block rendering by adding language support for syntax highlighting

myhloli4beb2ad20733
diff --git a/mineru/backend/vlm/vlm_middle_json_mkcontent.py b/mineru/backend/vlm/vlm_middle_json_mkcontent.py
index a1128af5..9cba6396 100644
--- a/mineru/backend/vlm/vlm_middle_json_mkcontent.py
+++ b/mineru/backend/vlm/vlm_middle_json_mkcontent.py
@@ -260,7 +260,11 @@ def make_blocks_to_content_list(para_block, img_buket_path, page_idx, page_size)
para_content = {'type': BlockType.CODE, 'sub_type': para_block["sub_type"], BlockType.CODE_CAPTION: []}
for block in para_block['blocks']:
if block['type'] == BlockType.CODE_BODY:
- para_content[BlockType.CODE_BODY] = merge_para_with_text(block)
+ code_text = merge_para_with_text(block)
+ if block['sub_type'] == BlockType.CODE:
+ guess_lang = para_block.get("guess_lang", "txt")
+ code_text = f"```{guess_lang}\n{code_text}\n```"
+ para_content[BlockType.CODE_BODY] = code_text
if block['type'] == BlockType.CODE_CAPTION:
para_content[BlockType.CODE_CAPTION].append(merge_para_with_text(block))