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 $