From 1e873a397c314843444adb68dcd5238af62dfe22 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 19 May 2026 11:26:26 +0200 Subject: [PATCH] fix: ignore links in code after literal dollar during link validation (#691) Signed-off-by: squidfunk --- python/tests/unit/collectors/test_references.py | 5 +++++ python/zensical/collectors/references/cursor.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/python/tests/unit/collectors/test_references.py b/python/tests/unit/collectors/test_references.py index 60ebf46..cec0ca2 100644 --- a/python/tests/unit/collectors/test_references.py +++ b/python/tests/unit/collectors/test_references.py @@ -1854,6 +1854,11 @@ class TestMath: refs = collect(md) assert len(refs) == 0 + def test_no_math_inline_across_code(self) -> None: + md = b"| $ | `#!python 'ab$'` | `#!python '[abc]'` |" + refs = collect(md) + assert len(refs) == 0 + @pytest.mark.parametrize( "md", [ diff --git a/python/zensical/collectors/references/cursor.py b/python/zensical/collectors/references/cursor.py index 9345092..bc7f777 100644 --- a/python/zensical/collectors/references/cursor.py +++ b/python/zensical/collectors/references/cursor.py @@ -1042,6 +1042,8 @@ def _scan_math_inline(cursor: Cursor) -> int | None: # Scan for closing $ while end < cursor.end and cursor.data[end] not in (_CR, _NL): + if cursor.data[end] == _BACKTICK: + return None if ( cursor.data[end] == _DOLLAR # Closing $ must not be preceded by whitespace or $