Add FAQ on preventing column widths in pipe tables.

See #8139.
This commit is contained in:
John MacFarlane 2022-07-04 13:35:12 +02:00
parent 5df94da831
commit f2f9c896ee

View file

@ -161,4 +161,29 @@ of the citations by specifying an appropriate CSL bibliography
style using `--csl`
(see [the manual](https://pandoc.org/MANUAL.html#specifying-a-citation-style)).
### Pandoc adds column widths to pipe tables when any line is wider than the setting for `--columns`. How can I prevent this?
Save this filter as `nowidths.lua` and then pass `--lua-filter
nowidths.lua` as an additional option to pandoc.
(See <https://github.com/jgm/pandoc/issues/8139>.)
``` lua
-- Unset the width attribute of HTML colspecs in tables
-- See https://github.com/jgm/pandoc/issues/8139
function Table (tbl)
if PANDOC_VERSION[1] >= 2 and PANDOC_VERSION[2] >= 10 then
tbl.colspecs = tbl.colspecs:map(function (colspec)
local align = colspec[1]
local width = nil -- default width
return {align, width}
end)
else
for i, w in ipairs(tbl.widths) do
tbl.widths[i] = 0
end
end
return tbl
end
```
:::