Skip to content

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

fix(dict2md): add space for inline equations in CJK contexts

myhloli74ee428bbb45
diff --git a/magic_pdf/dict2md/ocr_mkcontent.py b/magic_pdf/dict2md/ocr_mkcontent.py
index 9c83fdb0..ad7866b2 100644
--- a/magic_pdf/dict2md/ocr_mkcontent.py
+++ b/magic_pdf/dict2md/ocr_mkcontent.py
@@ -165,8 +165,8 @@ def merge_para_with_text(para_block):
if content:
langs = ['zh', 'ja', 'ko']
# logger.info(f'block_lang: {block_lang}, content: {content}')
- if block_lang in langs: # 中文/日语/韩文语境下,换行不需要空格分隔
- if j == len(line['spans']) - 1:
+ if block_lang in langs: # 中文/日语/韩文语境下,换行不需要空格分隔,但是如果是行内公式结尾,还是要加空格
+ if j == len(line['spans']) - 1 and span_type not in [ContentType.InlineEquation]:
para_text += content
else:
para_text += f'{content} '