fix: ignore links in code after literal dollar during link validation (#691)

Signed-off-by: squidfunk <martin.donath@squidfunk.com>
This commit is contained in:
squidfunk
2026-05-19 11:26:26 +02:00
parent 62a0feb8f4
commit 1e873a397c
2 changed files with 7 additions and 0 deletions
@@ -1854,6 +1854,11 @@ class TestMath:
refs = collect(md)
assert len(refs) == 0
def test_no_math_inline_across_code(self) -> None:
md = b"| <span>$<span> | `#!python 'ab$'` | `#!python '[abc]'` |"
refs = collect(md)
assert len(refs) == 0
@pytest.mark.parametrize(
"md",
[
@@ -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 $