Skip to content

Text fragments, port fallback, GitHub alerts and rel="external" - #139

Merged
shenxianpeng merged 4 commits into
mainfrom
claude/project-thread-r8fi8v
Nov 1, 2026
Merged

shenxianpeng merged 4 commits into
mainfrom
claude/project-thread-r8fi8v

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Four small, long-standing annoyances from the roadmap, one commit each, all for 1.11.0.

  1. Text fragment links are no longer reported as missing anchors. page.md#:~:text=some%20words is resolved by the browser by searching the page's text, but anchor validation took the whole fragment for an element ID. Now only the part before :~: is checked (page.md#heading:~:text=… still checks #heading), and nothing when it's empty.
  2. mkdocs serve uses the next free port when 8000 is busy. Instead of failing with "Address already in use" (typically a second mkdocs serve), it tries 8001–8010 and logs Port 8000 is in use, so serving on port 8001 instead. A port set with --dev-addr or dev_addr is still used as given. The server now binds before the first build, so the site is built for the port it's actually served on. On Windows the socket uses SO_EXCLUSIVEADDRUSE, since SO_REUSEADDR there lets two servers share a port without an error (not tested on Windows).
  3. GitHub-style alerts render as admonitions. A blockquote starting with [!NOTE], [!TIP], [!IMPORTANT], [!WARNING] or [!CAUTION] on its own line becomes <div class="admonition note"> with a title, the same HTML as the admonition extension, so themes style it with no setup. Consecutive alerts stay separate, nested ones work, \[!NOTE] stays literal. It runs after Sumi's own callouts (treeprocessor priority 22 vs 25), so Sumi's output is unchanged; checked with mkdocs-sumi main. The mkdocs theme gets colors for tip, important and caution; readthedocs already had them.
  4. Links to other sites get rel="external". For Markdown links to https://, http:// and // URLs, so themes and CSS can mark them. A rel set with attr_list is kept and external added. Links in raw HTML are untouched, as before.

The built-in themes with all five alerts:

mkdocs readthedocs
Note blue, Tip green, Important light blue, Warning orange, Caution red Note blue, Tip and Important green, Warning and Caution orange

Related Issue

Roadmap items 9, 14, 15 and 17 in #59.

Checklist

  • New tests added for new behavior (if applicable)
  • Documentation updated (if applicable): dev_addr, anchor validation, new "Alerts" and "External links" sections in Writing your docs, Fixed Upstream Issues page
  • Release notes docs/about/release-notes.md updated (if applicable): new Added and Fixed sections under 1.11.0

Checked locally: full unit test suite (962 tests), hatch run integration.py3.12-default:test, mkdocs build --strict of the docs site, uvx prek run, and two real mkdocs serve processes (the second one moved to 8001).

A link such as `page.md#:~:text=some%20words` uses a text fragment, which
the browser resolves by searching the page's text. Anchor validation took
the whole fragment for an element ID and warned that the anchor doesn't
exist. Now only the part before `:~:` is checked, and nothing when it is
empty.
`mkdocs serve` failed with "Address already in use" when another program,
often another `mkdocs serve`, had port 8000. When the port is the default
one, it now tries 8001 to 8010 and logs which one it uses. A port set with
`--dev-addr` or `dev_addr` is still used as given.

The server now binds before the first build, so the site is built for the
port it is actually served on. On Windows the socket uses
SO_EXCLUSIVEADDRUSE, because SO_REUSEADDR there lets two servers share a
port silently.
A blockquote that starts with `[!NOTE]`, `[!TIP]`, `[!IMPORTANT]`,
`[!WARNING]` or `[!CAUTION]` on its own line is how GitHub writes a
callout. MkDocs showed it as a plain quote starting with `[!NOTE]`. It now
becomes the same HTML as the `admonition` extension produces, which themes
already style; the `mkdocs` theme gains colors for tip, important and
caution.

The conversion runs after other treeprocessors that handle these alerts
themselves, such as Sumi's callouts, so their output is unchanged.
Themes and site CSS had no reliable way to tell a link to another site from
an internal one, for example to add an icon. Markdown links to `https://`,
`http://` or protocol-relative `//` URLs now get `rel="external"`. A `rel`
the author set, such as with `attr_list`, is kept and `external` is added to
it. Links in raw HTML are left alone, as before.
@shenxianpeng
shenxianpeng merged commit fc0c740 into main Nov 1, 2026
23 checks passed
@shenxianpeng
shenxianpeng deleted the claude/project-thread-r8fi8v branch November 1, 2026 22:17
@codspeed

codspeed Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 16.49%

1 warning

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

❌ 1 regressed benchmark
✅ 28 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_get_yaml_loader 315.6 µs 378 µs -16.49%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing claude/project-thread-r8fi8v (7791d8d) with main (7016c72)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant