pandoc
pandoc copied to clipboard
docx writer : Changeable Table style (not hard-coded)
I would like to use multiple styles of Table in a single docx, but the docx writer only allows the hard-coded "Table" style.
https://github.com/jgm/pandoc/blob/4340bd52c49b987087e123de2eae4464b300332f/src/Text/Pandoc/Writers/Docx/Table.hs#L79
There is an idea to achieve this with custom-styles in fenced_divs. It would be great to be able to use multiple Styles with this kind of syntax.
::: {custom-style="other-table-style"}
| Right | Left | Default | Center |
|------:|:-----|---------|:------:|
| 12 | 12 | 12 | 12 |
| 123 | 123 | 123 | 123 |
| 1 | 1 | 1 | 1 |
:::
There are a lot of issues related to docx writer tables, but none of them exist independently for this issue. I'm sorry if this is a duplicate. Thanks
I would love to see support for custom-style
in Table nodes. Being able to specify "NormalTable" or "GridTable" seems safe, given that they're part of the default Normal template in recent (>2016) versions of Word.
Since we have attributes on Table now in the AST, we could implement custom-style.
This would require changing tableToOpenXML
to take a parameter for a table style (to use instead of hardcoded "Table"
). This parameter could be extracted from custom-style
attribute in T.P.Writers.Docx around line 954 and
passed to tableToOpenXML
.
This would be expecting the custom-style
attribute to be on the Table element itself, not an enclosing Div, so your example above wouldn't work out of the box. However, it would only take a Lua filter to migrate the custom-style to the Table itself.
I would love to have this feature to be added to the Docx writer.
I currently have a docx file generated from a markdown file and I was looking around to be able to specify several style of table in this document.
I was trying to write a custom filter to add custom-style
to the Table
element but sadly it was not possible since the table style is hard coded in the writer.
Since the description of the changes from @jgm was not that complicated, I looked to the code to may be help on this. Sadly since I have no experience in haskell language, It is hard for me to understand the code and how to add that 😢
Hope it can be added soon.