refactor: migrate autorefs MkDocs plugin replacement

Signed-off-by: squidfunk <martin.donath@squidfunk.com>
This commit is contained in:
squidfunk
2026-09-01 18:35:54 +02:00
parent 3a390c7647
commit 83b0fd7541
19 changed files with 1558 additions and 522 deletions
+26
View File
@@ -174,6 +174,32 @@ Not indexed.
assert _read_index(disabled)["items"] == []
def test_search_exclusion_attribute_is_removed_from_page(
tmp_path: Path,
) -> None:
"""Search pragmas affect the index but do not leak into final HTML."""
config = _write_project(tmp_path, plugins=" - search")
(tmp_path / "docs" / "index.md").write_text(
"""\
# Landing
Visible body.
<div data-search-exclude><p>Hidden body.</p></div>
""",
encoding="utf-8",
)
zensical.build(str(config), _BUILD_OPTIONS)
index = _read_index(tmp_path)
assert "Visible body." in index["items"][0]["text"]
assert "Hidden body." not in index["items"][0]["text"]
page = (tmp_path / "site" / "index.html").read_text()
assert "Hidden body." in page
assert "data-search-exclude" not in page
def test_search_rebuild_replaces_changed_and_removed_pages(
tmp_path: Path,
) -> None:
+40
View File
@@ -396,3 +396,43 @@ custom_dir = "overrides"
captured = capfd.readouterr()
assert "No issues found" in captured.err
def test_cached_template_refreshes_when_page_autoref_changes(
tmp_path: Path,
) -> None:
"""Page-local autoref facts participate in the template cache key."""
docs = tmp_path / "docs"
docs.mkdir()
source = docs / "index.md"
source.write_text(
"# Home\n\n[First title][first-target]\n", encoding="utf-8"
)
(docs / "other.md").write_text(
"# Other\n\n## first-target\n\n## second-target\n",
encoding="utf-8",
)
config = tmp_path / "zensical.toml"
config.write_text(
"""
[project]
site_name = "Test"
[project.plugins.autorefs]
""".lstrip(),
encoding="utf-8",
)
zensical.build(str(config), {"clean": True, "strict": False})
output = (tmp_path / "site" / "index.html").read_text(encoding="utf-8")
assert 'href="other/#first-target">First title</a>' in output
# Both references occupy page-local slot zero. Only their cached facts
# distinguish the template inputs after the Markdown pass.
source.write_text(
"# Home\n\n[Second title][second-target]\n", encoding="utf-8"
)
zensical.build(str(config), {"clean": False, "strict": False})
output = (tmp_path / "site" / "index.html").read_text(encoding="utf-8")
assert 'href="other/#second-target">Second title</a>' in output
assert 'href="other/#first-target">First title</a>' not in output