Accessibility issue: tables are not outputting <thead> and <th> tags
See original GitHub issueIn Microsoft Word, you can define if you wish your table to contain a < thead > and first column < th > tags through this toolbar:
However these settings are being ignored by Mammoth when a word document is being processed. Instead it strips all table headings out and simply outputs a table of basic table cells.
For the following table, I used the settings used in the image above.
This is the output that I was expecting Mammoth to output:
<table>
<thead>
<tr>
<th>
<p>Name</p>
</th>
<th>
<p>Number</p>
</th>
<th>
<p>Year</p>
</td>
</tr>
</thead>
<tbody>
<tr>
<th>
<p>Thing</p>
</th>
<td>
<p>123</p>
</td>
<td>
<p>2017</p>
</td>
</tr>
<tr>
<th>
<p>Other thing</p>
</th>
<td>
<p>458</p>
</td>
<td>
<p>2016</p>
</td>
</tr>
</tbody>
</table>
This is the markup I got though:
<table>
<tbody>
<tr>
<td>
<p>Name</p>
</td>
<td>
<p>Number</p>
</td>
<td>
<p>Year</p>
</td>
</tr>
<tr>
<td>
<p>Thing</p>
</td>
<td>
<p>123</p>
</td>
<td>
<p>2017</p>
</td>
</tr>
<tr>
<td>
<p>Other thing</p>
</td>
<td>
<p>458</p>
</td>
<td>
<p>2016</p>
</td>
</tr>
</tbody>
</table>
Mammoth version: v1.4.2 OS: Windows 10 node.js version: 6.9.4
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Acrobat - problems with table <THead> tags for Accessibility
To create a THead tag you would right click on the <Table> Tag in the Tags Panel, select "New" and Type THead, (rather...
Read more >Tables Tutorial | Web Accessibility Initiative (WAI) - W3C
This tutorial shows you how to apply appropriate structural markup to tables. It includes the following pages:
Read more >Empty or Missing Table Header - Equalize Digital
An empty table header error means that one of the table headers on your post or page does not contain any text. This...
Read more >HTML table advanced features and accessibility
The <thead> element must wrap the part of the table that is the header — this is usually the first row containing the...
Read more >Does putting the <tfoot> tag before <tbody> makes a table ...
In HTML4, tfoot had to appear before tbody , but HTML5 allowed either before or after. Placing it before causes problems for keyboard...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
There are two main places you’d need to look at. One is the code that parses the document in
lib/docx/body-reader.js
. The existing code that handles table headers is probably a good feature to look at for a rough idea of how to implement this. For header rows, you probably want to reuse the same property i.e.isHeader
on table rows, plus add a property to handle header columns. You then need to update the conversion to HTML inlib/document-to-html.js
. Header rows will already be handled by the existing code, but you’d need to add support for header columns.Each module should be covered by tests. The test directory structure should mirror the directory structure of the code under test, so hopefully they’re reasonably straightforward to navigate around. Again, looking for the existing support for table headers is probably a good place to start.
The Python implementation is fairly similar to the JavaScript implementation, but it’s worth noting that they (should!) have the same level of support for tables.