[PR #29] [MERGED] OLD-7872: test_docs_links strips code fences line by line, as CommonMark does #83

Closed
opened 2026-11-26 20:16:44 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/29
Author: @ItsMrDubey
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism

Base: main ← Head: docs-links-fences


📝 Commits (1)

  • ce560e0 tests: test_docs_links reads code fences line by line, as CommonMark does

📊 Changes

1 file changed (+76 additions, -3 deletions)

View changed files

📝 tests/test_docs_links.py (+76 -3)

📄 Description

Claimed in the coordination issue as: OLD-7872 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7119646964)

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/29 **Author:** [@ItsMrDubey](https://github.com/ItsMrDubey) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@ubiquitarianism](https://github.com/ubiquitarianism) **Base:** `main` ← **Head:** `docs-links-fences` --- ### 📝 Commits (1) - [`ce560e0`](https://github.com/ubiquitarianism/leonida/commit/ce560e07f4f3836d4dadd46bf636f5e53d168b30) tests: test_docs_links reads code fences line by line, as CommonMark does ### 📊 Changes **1 file changed** (+76 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_docs_links.py` (+76 -3) </details> ### 📄 Description Claimed in the coordination issue as: OLD-7872 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7119646964) ### 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:16:44 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#83
No description provided.