@a11ign/documents

中文文档
0.1.2发布于 2026/10/09Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2369

The PDF layer (ADR 0036's second layer, #68): reads a PDF's own accessibility tag tree -- tagged/untagged, the document language, alt text on figures -- with no browser, no NVDA and no fleet.

原始使用文档
文档目录3 节
  1. What it checks
  2. Why this exists
  3. Working here

@a11ign/documents

The PDF layer (ADR 0036, #68). Reads a PDF's own accessibility tag tree directly -- the structure a screen reader or a checker like PAC reads -- rather than rendering the document or driving any assistive technology. No browser, no NVDA, no fleet.

import { scanPdfTagTree } from "@a11ign/documents";

const result = await scanPdfTagTree("https://example.com/report.pdf");
if (result.ok) {
  for (const finding of result.findings) {
    console.log(finding.rule, finding.wcag, finding.help);
  }
} else {
  console.error(result.error);
}

looksLikePdfUrl(url) tells a caller whether a target is this layer's to run, by extension, before anything is fetched -- the CLI (a11ign) uses it to route a .pdf URL here instead of leasing a screen-reader worker.

What it checks

Three structural facts, read straight from the catalog and struct-element dictionaries with pdf-lib, never inferred from rendering:

findingWCAGwhat it reads
pdf-untagged1.3.1/MarkInfo /Marked true and /StructTreeRoot are not BOTH present -- nothing in the document has a programmatically determinable structure
pdf-missing-lang3.1.1the catalog has no /Lang
pdf-figure-no-alt1.1.1a Figure struct element (walking /StructTreeRoot's /K tree) has no /Alt

pdf-figure-no-alt names the page, when the struct element's /Pg resolves to one of the document's pages.

Why this exists

#68's own criterion for the second layer was "which one most cheaply proves the [layer] contract wrong if it is wrong -- not which is most useful to a user." A PDF has no DOM, no live navigation order, and arguably not even "a page" the way the screen-reader and rule-based layers assume one. ceo's ruling on #1131 picked it over keyboard-only (tests the model least), contrast/visual (needs a rendering pipeline this repo does not have) and cognitive (almost entirely referrals) for exactly that reason.

Reports through Report.pdf (packages/cli/src/report.ts in a11ign/a11ign) the same way axe-core reports through Report.axe -- a new field, never a change to @a11ign/evidence or @a11ign/judge's shape.

Working here

The package is this repository's root: one package.json, one README.md (this file, also the npm page), one LICENSE, no workspace file. pnpm run layout-check fails on the monorepo shape coming back (@a11ign/toolchain/layout-check), and CI runs it.

pnpm install --frozen-lockfile
pnpm test         # what the `gate` check runs on every pull request and merge-queue entry
pnpm run smoke    # packs the package and runs it from the tarball, outside this repository

main takes pull requests only, each with one approving review, through the merge queue. A change that should reach npm carries a changeset (pnpm exec changeset), and its merge to main is the release (.github/workflows/release.yml; .changeset/README.md).

版本与发布记录

@a11ign/documents 共发布 4 个版本,首次发布于 2026/10/04;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.2latest2026/10/0929 天前
0.1.12026/10/061 个月前
0.1.02026/10/041 个月前
0.0.0-reserved.0reserved2026/10/041 个月前

关于 @a11ign/documents 的常见问题

@a11ign/documents 是什么?

The PDF layer (ADR 0036's second layer, #68): reads a PDF's own accessibility tag tree -- tagged/untagged, the document language, alt text on figures -- with no browser, no NVDA and no fleet.

如何安装 @a11ign/documents?

在项目目录运行 npm install @a11ign/documents,或使用 pnpm add / yarn add / bun add。

@a11ign/documents 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@a11ign/documents 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@a11ign/documents 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@a11ign/documents 可以商用吗?

@a11ign/documents 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@a11ign/documents 的下载量有多少?

根据 npm 官方下载统计,@a11ign/documents 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,369 次,日均约 79 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@a11ign/documents 还在维护吗?

最新版本 0.1.2 发布于 2026/10/09(29 天前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/10/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。