OLD-7872: test_docs_links strips code fences line by line, as CommonMark does #29

Manually merged
github merged 1 commit from gh-pr/29/head into gh-pr/29/base 2026-11-26 08:41:33 +00:00
Owner

@⁠ItsMrDubey on GitHub · 2026-11-24 02:02 UTC · original
ItsMrDubey:docs-links-fences → main · +76 −3 · 1 files · 1 commits · merged 2026-11-24 02:26 UTC

Claimed in the coordination issue as: OLD-7872 (#14)

What and why

Old #7872 (ray3242): strip_fences() in tests/test_docs_links.py used re.compile(r"```.*?```", re.S), which pairs any two triple-backtick runs. An inline ``` in prose, a 4-backtick fence holding a 3-backtick one, a ~~~ fence, or a closing line with an info string all mis-pair it: text between unrelated fences was dropped, so real headings vanished from the anchor set and links in that text went unchecked.

strip_fences() is now a line-based scanner following CommonMark: a fence opens on a line indented at most 3 spaces past its list item's content column (so the 4-space fences nested in list items in the i18n quickstarts still count), with >=3 backticks (no backtick in the info string) or tildes; it closes on a line of the same character, at least as long, with nothing after it; an unclosed fence runs to the end of the page. CRLF input is handled.

No other test or tool carries the regex. The other tests/test_docs_*.py checkers use a separate line.lstrip().startswith("```") toggle; I left those alone because they do a different job and this issue does not cover them.

New StripFencesTest cases cover inline backticks, a longer fence holding a shorter one, tilde fences, closing lines with an info string, fences nested in list items, 4-space indent outside a list, an unclosed fence, CRLF, and a heading after inline backticks showing up as an anchor.

On the real docs, the old and new scanners give identical link and anchor sets for every tracked .md file, so no doc links needed fixing.

Tested

Windows 11, Python 3.11.9, no GPU needed.

  • python -I tests/test_docs_links.py: before 7 tests OK; after 16 tests OK.
  • The new StripFencesTest run against the old strip_fences: 7 of 9 fail (the bug reproduces); all pass with the new one.
  • Comparing old and new links()/anchors() over all tracked Markdown: no differences.
  • python -I tests/test_ci_registration.py, tests/test_docs_repo_paths.py, tests/test_runtime_paths.py: OK.
  • python -I scripts/check_no_game_data.py tests/test_docs_links.py: clean.

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. n/a: no translator rule
**@⁠ItsMrDubey** on GitHub · 2026-11-24 02:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/29) `ItsMrDubey:docs-links-fences` → `main` · +76 −3 · 1 files · 1 commits · merged 2026-11-24 02:26 UTC Claimed in the coordination issue as: OLD-7872 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why Old #7872 (ray3242): `strip_fences()` in `tests/test_docs_links.py` used `re.compile(r"```.*?```", re.S)`, which pairs any two triple-backtick runs. An inline ```` ``` ```` in prose, a 4-backtick fence holding a 3-backtick one, a `~~~` fence, or a closing line with an info string all mis-pair it: text between unrelated fences was dropped, so real headings vanished from the anchor set and links in that text went unchecked. `strip_fences()` is now a line-based scanner following CommonMark: a fence opens on a line indented at most 3 spaces past its list item's content column (so the 4-space fences nested in list items in the i18n quickstarts still count), with >=3 backticks (no backtick in the info string) or tildes; it closes on a line of the same character, at least as long, with nothing after it; an unclosed fence runs to the end of the page. CRLF input is handled. No other test or tool carries the regex. The other `tests/test_docs_*.py` checkers use a separate `line.lstrip().startswith("```")` toggle; I left those alone because they do a different job and this issue does not cover them. New `StripFencesTest` cases cover inline backticks, a longer fence holding a shorter one, tilde fences, closing lines with an info string, fences nested in list items, 4-space indent outside a list, an unclosed fence, CRLF, and a heading after inline backticks showing up as an anchor. On the real docs, the old and new scanners give identical link and anchor sets for every tracked `.md` file, so no doc links needed fixing. ### Tested Windows 11, Python 3.11.9, no GPU needed. - `python -I tests/test_docs_links.py`: before 7 tests OK; after 16 tests OK. - The new `StripFencesTest` run against the old `strip_fences`: 7 of 9 fail (the bug reproduces); all pass with the new one. - Comparing old and new `links()`/`anchors()` over all tracked Markdown: no differences. - `python -I tests/test_ci_registration.py`, `tests/test_docs_repo_paths.py`, `tests/test_runtime_paths.py`: OK. - `python -I scripts/check_no_game_data.py tests/test_docs_links.py`: clean. AI-assisted: yes ### Checklist - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. n/a: no translator rule
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:41:32 +00:00
github manually merged commit ce560e07f4 into gh-pr/29/base 2026-11-26 08:41:33 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.