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

Closed
rgaiacs opened this issue Mar 25, 2024 · 5 comments
Closed

DOCX Reader to support DOCX table custom style #9603

rgaiacs opened this issue Mar 25, 2024 · 5 comments

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)

@denismaier
Copy link
Contributor

+1 Support for table styling would be super useful.

@jgm
Copy link
Owner

jgm commented Jan 10, 2025

For consistency it would be good to implement this also for docx output (and ODT). But maybe okay to start with reader support.

@jgm
Copy link
Owner

jgm commented Jan 10, 2025

Oh, it looks like the docx writer already supports custom-style on tables. (Not documented.)

@jgm jgm closed this as completed in 6051d62 Jan 10, 2025
@denismaier
Copy link
Contributor

Very cool that is now supported. Thank you for adding this so quickly.

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

4 participants