fix: link validation doesn't ignore fenced code blocks when \r is present

Signed-off-by: squidfunk <martin.donath@squidfunk.com>
This commit is contained in:
squidfunk
2026-05-15 11:05:07 +02:00
parent b31dd1472c
commit a418c6bd3c
2 changed files with 9 additions and 1 deletions
@@ -1470,6 +1470,14 @@ class TestFencedCodeBlocks:
b"~~~~ py\n[text](href)\n~~~~",
id="fenced-code-4-tildes-lang",
),
pytest.param(
b"\n```\n[Start][]\n```\n",
id="fenced-code-with-info",
),
pytest.param(
b"```\r\n[Start]\r\n```\r\n",
id="fenced-code-crlf-with-shortcut-link-ref",
),
],
)
def test_fenced_code(self, md: bytes) -> None:
@@ -971,7 +971,7 @@ def _scan_fenced_code(cursor: Cursor, char: int) -> int | None:
# Skip to next line and terminate if we found a closing fence
if end - start == opening:
rest = _skip_whitespace(cursor, end)
if rest >= cursor.end or cursor.data[rest] == _NL:
if rest >= cursor.end or cursor.data[rest] in (_CR, _NL):
return _skip_line(cursor, end)
# Skip to next line