git.iko.soy/typeable/pandoc
on master help sign in
Pipe tables: impose minimum cell size.

This might help with #3526. At any rate, it fixes another bug (see test/command/3526.md).

commita939cfe769408ec41aee7ebe5ce4d36f5160d7d1 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 23 Mar 2017, 16:54 (10 years ago) parente92941a
2 files changed+21−5
src/Text/Pandoc/Writers/Shared.hs+7−5 test/command/3526.md+14
src/Text/Pandoc/Writers/Shared.hs+7−5
@@ -230,8 +230,11 @@ gridTable opts blocksToDoc headless aligns widths headers rows = do
230230 let numcols = maximum (length aligns : length widths :
231231 map length (headers:rows))
232232 let handleGivenWidths widths' = do
233− let widthsInChars' = map ((\x -> x - 3) . floor .
234− (fromIntegral (writerColumns opts) *)) widths'
233+ let widthsInChars' = map (
234+ (\x -> if x < 1 then 1 else x) .
235+ (\x -> x - 3) . floor .
236+ (fromIntegral (writerColumns opts) *)
237+ ) widths'
235238 rawHeaders' <- zipWithM blocksToDoc
236239 (map (\w -> opts{writerColumns =
237240 min (w - 2) (writerColumns opts)}) widthsInChars')
@@ -268,11 +271,10 @@ gridTable opts blocksToDoc headless aligns widths headers rows = do
268271 let head' = makeRow rawHeaders
269272 let rows' = map (makeRow . map chomp) rawRows
270273 let borderpart ch align widthInChars =
271− let widthInChars' = if widthInChars < 1 then 1 else widthInChars
272− in (if (align == AlignLeft || align == AlignCenter)
274+ (if (align == AlignLeft || align == AlignCenter)
273275 then char ':'
274276 else char ch) <>
275− text (replicate widthInChars' ch) <>
277+ text (replicate widthInChars ch) <>
276278 (if (align == AlignRight || align == AlignCenter)
277279 then char ':'
278280 else char ch)
test/command/3526.mdnew file+14
@@ -0,0 +1,14 @@
1+```
2+% pandoc -t rst
3++--+---+
4+| | |
5++--+---+
6+| | |
7++--+---+
8+^D
9++---+---+
10+| | |
11++---+---+
12+| | |
13++---+---+
14+```