-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sometimes, tables have row-level headings as well as column level headings. To be accessible, these need to be marked up as `<th>` tags. Otherwise users of screen readers and other assistive technology may not be able to work out that they're table headings rather than ordinary table cells.
- Loading branch information
1 parent
9e8160d
commit 9f6c0b9
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
RSpec.describe GovukTechDocs::TechDocsHTMLRenderer do | ||
describe "#render a table" do | ||
it "renders tables with row headings" do | ||
app = double("app") | ||
context = double("context") | ||
allow(context).to receive(:app) { app } | ||
allow(app).to receive(:api) | ||
|
||
processor = Redcarpet::Markdown.new(described_class.new(context: context), tables: true) | ||
output = processor.render <<~MARKDOWN | ||
| A | B | | ||
|------|---| | ||
|# C | D | | ||
| E | F | | ||
|# *G* | H | | ||
MARKDOWN | ||
|
||
# Cells in the heading row should be treated as headings | ||
expect(output).to include("<th>A</th>") | ||
expect(output).to include("<th>B</th>") | ||
|
||
# Cells starting with `# ` should be treated as row headings | ||
expect(output).to include('<th scope="row">C</th>') | ||
|
||
# Other cells should be treated as ordinary cells | ||
expect(output).to include("<td>D</td>") | ||
expect(output).to include("<td>E</td>") | ||
expect(output).to include("<td>F</td>") | ||
expect(output).to include("<td>H</td>") | ||
|
||
# Heading cells with more complex markup aren't handled yet | ||
expect(output).to include("<td># <em>G</em></td>") | ||
end | ||
end | ||
end |