Render Markdown links and images in one bounded pass #196

Merged
aluminum-ice merged 1 commit from md-links-one-pass into main 2026-11-15 07:54:15 +00:00
Owner

What this PR does

Reworks the inline step of the dashboard's Markdown renderer (_md_inline in web.py, used for /guide and the What's new release notes):

  • One pattern, one pass. Links ([label](url)) and images (![alt](url), shown as a "Picture: alt" link, never loaded) are matched by a single _MD_LINK pattern in a single pass, and each generated link is stashed behind a placeholder, the way code spans already were. No later pass (links, bold, italic) ever sees markup the renderer generated.
  • Bounded patterns. The label is at most 500 characters and holds no brackets or newline; the URL is at most 2,048 characters with no brackets, parentheses or whitespace. That keeps matching linear on long lines of unmatched brackets, which release notes (off the network) can contain.
  • Labels still get bold and italic; the scheme allow-lists are unchanged (links: http, https, #, /, mailto; images: http, https, /).

Checklist

  • Lint passes — the real-data check is clean locally; the Lint workflow runs the rest.

  • Tests pass — new tests in test_web.py:

    • nested and back-to-back links and images come out as separate, well-formed links;
    • a 3,000-case fuzz of bracket, URL, quote and emphasis fragments only ever produces href/id/data-label attributes and allow-listed hrefs;
    • lines of 20,000 unmatched brackets render in under a second.

    In the full suite, 1,744 pass; the 5 test_web.py potfile-import tests fail locally exactly as on main (local werkzeug).

  • Nothing real: no secrets, no personal information, no real data.

  • Consent gates intact.

  • Docs updated in the same PR — no operator-visible change beyond #195's.

  • Commit messages are short and imperative.

Release impact

  • App-layer-safe — the kestrel_pi package only.
  • Reflash-class

Notes for review

Follows #195; no release carries the code this replaces.

🤖 Generated with Claude Code

## What this PR does Reworks the inline step of the dashboard's Markdown renderer (`_md_inline` in `web.py`, used for `/guide` and the *What's new* release notes): - **One pattern, one pass.** Links (`[label](url)`) and images (`![alt](url)`, shown as a "Picture: alt" link, never loaded) are matched by a single `_MD_LINK` pattern in a single pass, and each generated link is stashed behind a placeholder, the way code spans already were. No later pass (links, bold, italic) ever sees markup the renderer generated. - **Bounded patterns.** The label is at most 500 characters and holds no brackets or newline; the URL is at most 2,048 characters with no brackets, parentheses or whitespace. That keeps matching linear on long lines of unmatched brackets, which release notes (off the network) can contain. - **Labels** still get bold and italic; the scheme allow-lists are unchanged (links: http, https, #, /, mailto; images: http, https, /). ## Checklist - [x] **Lint passes** — the real-data check is clean locally; the **Lint** workflow runs the rest. - [x] **Tests pass** — new tests in `test_web.py`: - nested and back-to-back links and images come out as separate, well-formed links; - a 3,000-case fuzz of bracket, URL, quote and emphasis fragments only ever produces `href`/`id`/`data-label` attributes and allow-listed hrefs; - lines of 20,000 unmatched brackets render in under a second. In the full suite, 1,744 pass; the 5 `test_web.py` potfile-import tests fail locally exactly as on `main` (local werkzeug). - [x] **Nothing real: no secrets, no personal information, no real data.** - [x] **Consent gates intact.** - [x] **Docs updated in the same PR** — no operator-visible change beyond #195's. - [x] Commit messages are short and imperative. ## Release impact - [x] **App-layer-safe** — the `kestrel_pi` package only. - [ ] **Reflash-class** ## Notes for review Follows #195; no release carries the code this replaces. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Render Markdown links and images in one bounded pass
All checks were successful
Lint / lint (pull_request) Successful in 31s
Test / test (pull_request) Successful in 57s
Lint / lint (push) Successful in 29s
Test / test (push) Successful in 52s
34c0ef5ed1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aluminum-ice deleted branch md-links-one-pass 2026-11-15 07:54:15 +00:00
Sign in to join this conversation.
No reviewers
No labels
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
aluminum-ice/kestrel!196
No description provided.