ickc / pantable

CSV Tables in Markdown: Pandoc Filter for CSV Tables
https://ickc.github.io/pantable/
BSD 3-Clause "New" or "Revised" License
86 stars 15 forks source link

fixed width tables do not get parsed in docx #63

Closed luerhard closed 2 years ago

luerhard commented 2 years ago

Hey there, i am currently trying to use pantable to export tables into a couple of different formats.

When I export this table

\```table
---
alignment: LLL
markdown: true
width: [0.2, 0.5, 0.3]
---
1,2,3
hello,my,name
\```

to latex, I get the following latex code:

\begin{longtable}[]{@{}
  >{\raggedright\arraybackslash}p{(\columnwidth - 4\tabcolsep) * \real{0.2000}}
  >{\raggedright\arraybackslash}p{(\columnwidth - 4\tabcolsep) * \real{0.5000}}
  >{\raggedright\arraybackslash}p{(\columnwidth - 4\tabcolsep) * \real{0.3000}}@{}}
\toprule
\begin{minipage}[b]{\linewidth}\raggedright
1
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
2
\end{minipage} & \begin{minipage}[b]{\linewidth}\raggedright
3
\end{minipage} \\
\midrule
\endhead
hello & my & name \\
\bottomrule
\end{longtable}

When I try to use pandoc to convert this to a docx file, the table does not get parsed (and the header is cut off).

image

This definitely has to do with the width: [0.2, 0.5, 0.3]. Is this an issue with pantable or with pandoc?

ickc commented 2 years ago

I'm pretty sure it is not a bug of pantable.

One of the problem in trying to reproduce your result is that your example above is not self-contained. i.e. you do not have the command you use to generate the docx.

I also assume your \ in the beginning is not what you meant (you may be trying to escape that in showing it as code in markdown here, which you can do will either using another delimiter such as ~~~ or even indent the whole block.)

In test.md:

```table
---
alignment: LLL
markdown: true
width: [0.2, 0.5, 0.3]
---
1,2,3
hello,my,name
```
pandoc -F pantable test.md -o test.docx

is a normal looking table to me.

Another reason to know that this is not a problem of pantable is that your LaTeX output is correct—pantable only convert the table code-block to pandoc AST, and is output format agnostic.