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 writer : Changeable Table style (not hard-coded) #7549

Open
shutingrz opened this issue Sep 5, 2021 · 3 comments
Open

docx writer : Changeable Table style (not hard-coded) #7549

shutingrz opened this issue Sep 5, 2021 · 3 comments

Comments

@shutingrz
Copy link

I would like to use multiple styles of Table in a single docx, but the docx writer only allows the hard-coded "Table" style.

( mknode "w:tblStyle" [("w:val","Table")] () :

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

@danblaker
Copy link

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.

@jgm
Copy link
Owner

jgm commented Sep 6, 2022

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.

@FabienSe
Copy link

FabienSe commented Oct 7, 2022

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.

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