diff --git a/python/tests/unit/collectors/test_references.py b/python/tests/unit/collectors/test_references.py index 9ea5c83..dc66d97 100644 --- a/python/tests/unit/collectors/test_references.py +++ b/python/tests/unit/collectors/test_references.py @@ -1672,6 +1672,11 @@ class TestMath: assert text(md, links[0].text) == b"before" assert text(md, links[0].href) == b"href" + def test_no_math(self) -> None: + md = b"1.000$" + refs = collect(md) + assert len(refs) == 0 + # --------------------------------------------------------------------------- diff --git a/python/zensical/collectors/references/cursor.py b/python/zensical/collectors/references/cursor.py index b79f2cc..2240c33 100644 --- a/python/zensical/collectors/references/cursor.py +++ b/python/zensical/collectors/references/cursor.py @@ -1021,12 +1021,12 @@ def _scan_inline_code(cursor: Cursor) -> int | None: def _scan_math_inline(cursor: Cursor) -> int | None: """Scan for `$...$` math.""" end = cursor.pos - if end >= cursor.end and cursor.data[end] != _DOLLAR: + if end >= cursor.end or cursor.data[end] != _DOLLAR: return None # Skip opening $ and abort if it's followed by whitespace or another $ end += 1 - if end >= cursor.end and ( + if end >= cursor.end or ( cursor.data[end] in (_DOLLAR, _SPACE, _TAB, _NL, _CR) ): return None