diff --git a/.github/scripts/wiki_check.py b/.github/scripts/wiki_check.py index 6a01a0a..c4b6a02 100755 --- a/.github/scripts/wiki_check.py +++ b/.github/scripts/wiki_check.py @@ -18,6 +18,9 @@ _FENCE = re.compile(r"^( {0,3})(`{3,}|~{3,})") _ASSET_DIR = "assets" _ASSET_SUFFIXES = (".png",) +# The wiki's own image URL, root-relative: the same from every page, including Home, +# which GitHub serves at /OWNER/REPO/wiki where a relative assets/ path misses the wiki. +_ROOTED_ASSET = re.compile(r"^/[^/]+/[^/]+/wiki/(assets/[^/?#]+)$") _ASSET_REFERENCE = re.compile(r"""(?:src|srcset)\s*=\s*["']([^"']+)["']|!\[[^]\n]*\]\(([^)\s]+)""") @@ -166,6 +169,9 @@ def validate(wiki_dir: Path) -> list[str]: visible_text = _without_code(text) for match in _ASSET_REFERENCE.finditer(visible_text): reference = (match.group(1) or match.group(2)).strip() + rooted = _ROOTED_ASSET.match(reference) + if rooted: + reference = rooted.group(1) if _is_external(reference) or not reference.startswith(f"{_ASSET_DIR}/"): continue if reference not in assets: diff --git a/tests/test_wiki_check.py b/tests/test_wiki_check.py index a99371d..89927bd 100644 --- a/tests/test_wiki_check.py +++ b/tests/test_wiki_check.py @@ -114,6 +114,19 @@ def test_rejects_missing_image(tmp_path: Path) -> None: assert "references a missing image: assets/flow-dark.png" in result.stderr +def test_checks_root_relative_images_against_assets(tmp_path: Path) -> None: + wiki_dir = tmp_path / "wiki" + page = 'Flow\n' + _write_pages(wiki_dir, **{"Flow.md": page, "Lost.md": page.replace("flow-light", "lost")}) + _write_assets(wiki_dir, "flow-light.png") + + result = _run_validator(wiki_dir) + + assert result.returncode == 1 + assert "references a missing image: assets/lost.png" in result.stderr + assert "flow-light" not in result.stderr + + def test_rejects_non_png_files_in_assets(tmp_path: Path) -> None: wiki_dir = tmp_path / "wiki" _write_pages(wiki_dir) diff --git a/wiki/Home.md b/wiki/Home.md index e9a3f56..7e6a83f 100644 --- a/wiki/Home.md +++ b/wiki/Home.md @@ -6,9 +6,9 @@ It is written for proteomics first, where a protein can be missing from a whole

- - - Four proteins measured in two batches: batch 2 reads about 1.5 units higher before correction, and the two batch means come within 0.3 of each other after harmonize(). + + + Four proteins measured in two batches: batch 2 reads about 1.5 units higher before correction, and the two batch means come within 0.3 of each other after harmonize().

Figure 1. Four proteins from the Quick start example. Each short bar is a batch mean: the dashed line between them is the batch effect, and after correction it is nearly flat while each protein keeps its own level.