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 = 5,

'), - ('

x=6

', - '

x=6

') + ('

x = 5,

', + '

x = 5,

'), + ('

x=6

', + '

x=6

') ] }, { @@ -67,9 +67,9 @@ ], 'raw_html': '

$x = 5$,$$x=6$$,$x=4$

', 'expected': [ - ('

x = 5,

', '

x = 5,

'), + ('

x = 5,

', '

x = 5,

'), ('

x=6

', '

x=6

'), - ('

,x=4

', '

,x=4

') + ('

,x=4

', '

,x=4

') ] }, { @@ -81,12 +81,12 @@ 'expected': [ ('

By substituting

', '

By substituting

'), - ('

x

', - '

x

'), + ('

x

', + '

x

'), ('

with

', '

with

'), - ('

t - \\dfrac{b}{3a}

', - '

t - \\dfrac{b}{3a}

'), + ('

t - \\dfrac{b}{3a}

', + '

t - \\dfrac{b}{3a}

'), ('

, the general

', '

, the general

') ]