feat: mitigate MathJax formula warnings
This commit is contained in:
@@ -6,6 +6,7 @@ from pdf2md.ir import WarningCode, WarningSeverity
|
||||
from pdf2md.quality import (
|
||||
MathCheckerUnavailable,
|
||||
MathCheckResult,
|
||||
check_math_renderability_details,
|
||||
check_asset_links,
|
||||
check_math_renderability,
|
||||
extract_math_expressions,
|
||||
@@ -71,6 +72,20 @@ def test_math_render_failures_are_aggregated_with_fake_checker() -> None:
|
||||
assert "bad_math failed" in result.warnings[0].message
|
||||
|
||||
|
||||
def test_math_renderability_details_include_failed_expression_records() -> None:
|
||||
def checker(body: str) -> MathCheckResult:
|
||||
return MathCheckResult(ok="bad" not in body, message=f"{body} failed")
|
||||
|
||||
result = check_math_renderability_details("$x_i$\n\n$$\nbad_math\n$$", checker)
|
||||
|
||||
assert result.quality.math_render_error_count == 1
|
||||
assert len(result.failures) == 1
|
||||
assert result.failures[0].expression.index == 1
|
||||
assert result.failures[0].expression.body == "bad_math"
|
||||
assert result.failures[0].expression.display is True
|
||||
assert result.failures[0].message == "bad_math failed"
|
||||
|
||||
|
||||
def test_math_extraction_records_display_mode_and_markdown_spans() -> None:
|
||||
markdown = "Inline $x_i^2$ before\n\n$$\n\\frac{1}{2}\n$$\n"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user