From cfd29a2160fb83700fb9cbb97a567e5811c5903b Mon Sep 17 00:00:00 2001 From: Nick Vigilante Date: Fri, 16 Oct 2026 15:21:34 -0400 Subject: [PATCH] fix(scripts/docshtmlcheck): decode entities and count alt text in table headers goldmark keeps an entity such as   as literal source text until it renders, so a pipe header cell or the Markdown between blocks holding only   looked non-empty and passed, while axe still reports it because U+00A0 trims to nothing. Text nodes are now run through UnescapeString, except inside a code span, where the entity renders literally and is real text. axe's has-visible-text also counts an image's alt text, so an in a or a pipe header cell, and an autolink or code block between blocks, no longer read as empty. A table nested inside a still does, and the README lists that under Limitations. The README intro and "How it works" now describe the table check too. Assisted-by: AI --- scripts/docshtmlcheck/README.md | 14 +++++--- scripts/docshtmlcheck/tables.go | 52 +++++++++++++++++++++++++--- scripts/docshtmlcheck/tables_test.go | 47 +++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 9 deletions(-) diff --git a/scripts/docshtmlcheck/README.md b/scripts/docshtmlcheck/README.md index 76f5a420637..d93cceb4504 100644 --- a/scripts/docshtmlcheck/README.md +++ b/scripts/docshtmlcheck/README.md @@ -1,8 +1,7 @@ # docshtmlcheck -`docshtmlcheck` fails CI when Markdown under `docs/` contains invalid inline -HTML that the documentation site's renderer silently drops or mangles. It runs -as `make lint/docs-html` (part of `make lint`). +`docshtmlcheck` fails CI when Markdown under `docs/` contains invalid inline HTML that the documentation site's renderer silently drops or mangles, or a table header cell with no text. +It runs as `make lint/docs-html` (part of `make lint`). ## What it catches @@ -24,8 +23,9 @@ as `make lint/docs-html` (part of `make lint`). closed and leaks its wrapper over the rest of the page. - **Empty table header cells** (`empty-table-header`). Screen readers announce a header cell with no text as an unnamed column or row. - The check covers the header row of Markdown pipe tables and every `` in raw HTML tables, after decoding entities and trimming whitespace, so ` ` and `
` are reported. - Markdown between the HTML blocks of a `` counts as its text. + The check covers the header row of Markdown pipe tables and every `` in raw HTML tables, after decoding entities and trimming whitespace, so ` `, `|   |`, and `
` are reported. + An entity inside a code span is literal text, so `` ` ` `` counts. + Markdown between the HTML blocks of a `` counts as its text, and so do an image's alt text, an autolink, and a code block. Each finding names the table by its first non-empty header. For the top-left corner of a matrix, name what the row headers hold, such as `Permission`. @@ -45,6 +45,9 @@ changes. A finding on a generated page under `docs/reference/**` also prints a note pointing at the generator source, since edits to the generated file do not persist. +The table check parses the same file a second time with goldmark's table extension. +It reads the header row of each pipe table from the parsed cells, and follows `` and `
` through the raw-HTML nodes, so a table split across several HTML blocks is checked as one and Markdown between its blocks counts toward the open cell. + ## Limitations A few gaps are accepted because no docs page hits them today: @@ -55,6 +58,7 @@ A few gaps are accepted because no docs page hits them today: - The interior of a raw-text element (`