Skip to content

DOCX Reader to support DOCX table custom style #9603

Closed
@rgaiacs

Description

Microsoft Word allows user to define custom style for tables.

Screenshot of Microsoft Word Table Style Editor

Would be great if the DOCX reader would support table custom style as it support paragraph custom style.

Minimal Working Example

mwe-table-custom-style.docx

XML structure

<w:tbl>
  <w:tblPr>
    <w:tblStyle w:val="Example"/>
    <w:tblW w:w="0" w:type="auto"/>
    <w:tblLook w:val="0620" w:firstRow="1" w:lastRow="0" w:firstColumn="0" w:lastColumn="0" w:noHBand="1" w:noVBand="1"/>
  </w:tblPr>
  ...
</w:tbl>

DOCX reader would have to read the value of w:val in <w:tblStyle /> that is a child of <w:tblPr> which is a child of <w:tbl>.

Expected Output

<table> has attribute data-custom-style. For example, pandoc --from docx+styles --to html mwe-table-custom-style.docx would return

<table data-custom-style="Example">
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="header">
<th>A</th>
<th>B</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1</td>
<td>2</td>
</tr>
</tbody>
</table>

Observed Output

pandoc --version returns

pandoc 3.1.11.1
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/raniere/.local/share/pandoc
Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.

<table> is missing the attribute data-custom-style. For example, pandoc --from docx+styles --to html mwe-table-custom-style.docx returns

<table>
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="header">
<th>A</th>
<th>B</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1</td>
<td>2</td>
</tr>
</tbody>
</table>

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions