From 1baae95d815c6707b01f7c727069dc5a77da98f6 Mon Sep 17 00:00:00 2001 From: monosans Date: Sun, 22 Nov 2026 17:44:06 +0300 Subject: [PATCH] fix: no space before the punctuation after a formula scour ends the SVG with a newline, which shows as a space in the HTML: "formula , text". --- tests/test_2_utils.py | 1 + wikidict/svg.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_2_utils.py b/tests/test_2_utils.py index b0c61dbbb..1bc8eb577 100644 --- a/tests/test_2_utils.py +++ b/tests/test_2_utils.py @@ -17,6 +17,7 @@ def test_formula_to_svg() -> None: assert re.match(r'") assert formula in utils.svg.CACHE with patch.dict("os.environ", {"FORCE_FORMULA_RENDERING": "1"}): diff --git a/wikidict/svg.py b/wikidict/svg.py index 5ad34f972..73b55452b 100644 --- a/wikidict/svg.py +++ b/wikidict/svg.py @@ -35,4 +35,5 @@ def set(formula: str, svg_raw: str) -> None: def optimize(svg_raw: str) -> str: """Optimize a given SVG.""" - return str(scourString(svg_raw, options=SCOUR_OPTIONS)) + # Without the final newline of scour, that would show as a space before the punctuation after a formula + return str(scourString(svg_raw, options=SCOUR_OPTIONS)).rstrip()