MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / rehypeAccessibleTables

Function rehypeAccessibleTables

apps/docs/astro.config.mjs:14–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12// Without this, axe-core flags "scrollable-region-focusable" on horizontally
13// overflowing tables (comparison tables, env tables, cost methodology).
14function rehypeAccessibleTables() {
15 return (tree) => {
16 const visit = (node, parent, index) => {
17 if (!node || typeof node !== "object") return;
18 if (
19 node.type === "element" &&
20 node.tagName === "table" &&
21 parent &&
22 !(
23 parent.type === "element" &&
24 parent.tagName === "div" &&
25 parent.properties?.role === "region"
26 )
27 ) {
28 const wrapper = {
29 type: "element",
30 tagName: "div",
31 properties: {
32 role: "region",
33 "aria-label": "Scrollable table",
34 tabIndex: 0,
35 className: ["bs-table-scroll"],
36 },
37 children: [node],
38 };
39 parent.children[index] = wrapper;
40 return;
41 }
42 if (Array.isArray(node.children)) {
43 for (let i = 0; i < node.children.length; i++) {
44 visit(node.children[i], node, i);
45 }
46 }
47 };
48 visit(tree, null, 0);
49 };
50}
51
52// Map each docs entry to the ISO timestamp of its most recent git commit.
53// Empty Map when git history is unavailable (shallow CI clones, etc.).

Callers

nothing calls this directly

Calls 1

visitFunction · 0.85

Tested by

no test coverage detected