From 47b8713e36bcac18ace7d2870add5845a0b689ae Mon Sep 17 00:00:00 2001 From: Yanggq <1041206149@qq.com> Date: Thu, 3 Jul 2025 11:31:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E5=BC=8F=E7=9A=84html=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../html/recognizer/cc_math/common.py | 4 +++- .../extractor/html/recognizer/test_math.py | 20 +++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/llm_web_kit/extractor/html/recognizer/cc_math/common.py b/llm_web_kit/extractor/html/recognizer/cc_math/common.py index 7e11cbc9..a81a0436 100644 --- a/llm_web_kit/extractor/html/recognizer/cc_math/common.py +++ b/llm_web_kit/extractor/html/recognizer/cc_math/common.py @@ -557,6 +557,8 @@ def process(match_text): return match math_text = self.extract_asciimath(match.strip('`').replace('\\','')) if asciimath_wrap else match wrapped_text = func(math_text) if func else math_text + # html保留原始的,而不是传入修改过的wrapped_text + original_wrapped = wrapped_text wrapped_text = self.wrap_math_md(wrapped_text) if not wrapped_text: return match @@ -566,7 +568,7 @@ def process(match_text): tail='', type=math_type, by=math_render, - html=wrapped_text + html=original_wrapped ) except Exception: return match diff --git a/tests/llm_web_kit/extractor/html/recognizer/test_math.py b/tests/llm_web_kit/extractor/html/recognizer/test_math.py index bffb7167..c11649cc 100644 --- a/tests/llm_web_kit/extractor/html/recognizer/test_math.py +++ b/tests/llm_web_kit/extractor/html/recognizer/test_math.py @@ -54,10 +54,10 @@ ], 'raw_html': '
$x = 5$,$$x=6$$
', 'expected': [ - ('$x = 5$,$$x=6$$,$x=4$
', 'expected': [ - (',
,
,
,
By substituting
', 'By substituting
'), - ('with
', 'with
'), - (', the general
', ', the general
') ]