Skip to content

Add table accessibility tagging (Table/TR/TH/TD structure elements)#164

Open
craigmcnamara wants to merge 1 commit intoprawnpdf:masterfrom
mes-amis:section-508-accessability
Open

Add table accessibility tagging (Table/TR/TH/TD structure elements)#164
craigmcnamara wants to merge 1 commit intoprawnpdf:masterfrom
mes-amis:section-508-accessability

Conversation

@craigmcnamara
Copy link
Copy Markdown

Summary

Adds automatic PDF structure tagging for tables when rendered on a tagged Prawn::Document (one created with marked: true).

When tagged mode is active, pdf.table(data, header: true) automatically emits:

  • <Table> wrapping the entire table
  • <TR> wrapping each row
  • <TH> with /Scope /Column for cells in header rows
  • <TD> for data cells
  • Table backgrounds and borders wrapped as /Artifact (excluded from screen readers)

No API changes required — existing pdf.table() calls gain accessibility tagging automatically.

Changes:

  • Table#draw — wraps in structure_container(:Table) when tagged
  • Cell.draw_cells — emits <TR> per row, <TH>/<TD> per cell; backgrounds/borders as artifacts
  • Cell#header? / Cell#is_header_cell — accessor for header cell detection
  • Table#mark_header_cells — auto-marks cells in header rows based on header: option
  • Gemfile — supports Gemfile.local for local gem overrides

Depends on prawnpdf/prawn#1391 and prawnpdf/pdf-core#67.

Addresses #78

Test plan

  • 10 new specs covering Table/TR/TH/TD tagging, Scope attributes, header detection, and untagged fallback
  • All 236 specs pass (226 existing + 10 new)
  • Generate a tagged PDF with tables and verify structure in Adobe Acrobat Tags panel
  • Run PAC 2024 accessibility checker

🤖 Generated with Claude Code

When rendering on a tagged Prawn::Document (marked: true), tables now
automatically emit PDF structure elements:
- <Table> wraps the entire table
- <TR> wraps each row
- <TH> with /Scope /Column for header cells
- <TD> for data cells

Header cells are detected automatically from the table's header: option.
Backgrounds and borders are wrapped as /Artifact (decorative content
not read by screen readers).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant