Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCX Reader to support DOCX table custom style #9603

Open
rgaiacs opened this issue Mar 25, 2024 · 1 comment
Open

DOCX Reader to support DOCX table custom style #9603

rgaiacs opened this issue Mar 25, 2024 · 1 comment

Comments

@rgaiacs
Copy link
Contributor

rgaiacs commented Mar 25, 2024

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>
@agusmba
Copy link
Contributor

agusmba commented Mar 26, 2024

Some other similar issues: #7549, #6496 (should probably be closed), #4697 (old with further references)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants