-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Support custom-style attribute for docx table #10009
Conversation
Perfect! Thanks. |
FINALLY, thank you soo soo soo much for those 4 golden lines of code Since I'm editing in markdown and you can't seem to add the style on a table (as far as I can tell?), I wrote a small luafilter https://github.com/tdewin/pandoc-lua-timo-filters/blob/main/defaulttabstyle.lua You can pass a default value for the tables with
You can override a value in text with a code block
|
Would it be possible to have an example of how to use this new parameter?
|
Pandoc Markdown doesn't yet have built-in syntax for table attributes. With {custom-style="TableCustom"}
| Header 1 | Header 2 |
|----------|----------|
| Val1 | Val2 | For pandoc Markdown it's best to use the Div-based syntax, but that requires an additional Lua filter like the one below (untested) function Div (div)
-- do nothing if the div doesn't have a custom-style attribute
-- or if the div doesn't have exactly one element
if not div.attributes['custom-style'] or #div.content == 1 then
return div
end
local tbl = div.content[1]
if tbl.t == 'Table' then
tbl.attributes['custom-style'] = div.attributes['custom-style']
return tbl
end
end |
@tarleb Thank you for the suggestion, I've tested it in quarto and couldn't make it work unfortunately. I had to use the following notation because of quarto:
I also had to adapt the lua code to:
Unfortunately, afterwards the tables were still using the If you have any suggestions on how to make it work, don't hesitate. |
This is a suggested fix to support the
custom-style
attribute for docx tables. I'm referring to the issues #9603, #7549, #6496, #4697. I needed this feature to support multiple table styles in one document and saw a lot of issues addressing this feature. With absolutely no prior experience in Haskell, I just gave it a shot :)The conversion from html to docx with and without it, worked fine. With the
table[custom-style="CustomStyle"]
attribute, it used the CustomStyle for the table and if omitted, the fallback/default style is "Table".I hope the code is okayish, but happy to change it if needed.