summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-23 16:54:24 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-23 16:54:47 +0100
commita939cfe769408ec41aee7ebe5ce4d36f5160d7d1 (patch)
tree869d9e83a9e35c6e25a8576bb842f81520fb9583
parente92941a9ca75560d6de99b86061492ec49ef1525 (diff)
Pipe tables: impose minimum cell size.
This might help with #3526. At any rate, it fixes another bug (see test/command/3526.md).
-rw-r--r--src/Text/Pandoc/Writers/Shared.hs12
-rw-r--r--test/command/3526.md14
2 files changed, 21 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
index 7e08724d8..615733a78 100644
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -230,8 +230,11 @@ gridTable opts blocksToDoc headless aligns widths headers rows = do
let numcols = maximum (length aligns : length widths :
map length (headers:rows))
let handleGivenWidths widths' = do
- let widthsInChars' = map ((\x -> x - 3) . floor .
- (fromIntegral (writerColumns opts) *)) widths'
+ let widthsInChars' = map (
+ (\x -> if x < 1 then 1 else x) .
+ (\x -> x - 3) . floor .
+ (fromIntegral (writerColumns opts) *)
+ ) widths'
rawHeaders' <- zipWithM blocksToDoc
(map (\w -> opts{writerColumns =
min (w - 2) (writerColumns opts)}) widthsInChars')
@@ -268,11 +271,10 @@ gridTable opts blocksToDoc headless aligns widths headers rows = do
let head' = makeRow rawHeaders
let rows' = map (makeRow . map chomp) rawRows
let borderpart ch align widthInChars =
- let widthInChars' = if widthInChars < 1 then 1 else widthInChars
- in (if (align == AlignLeft || align == AlignCenter)
+ (if (align == AlignLeft || align == AlignCenter)
then char ':'
else char ch) <>
- text (replicate widthInChars' ch) <>
+ text (replicate widthInChars ch) <>
(if (align == AlignRight || align == AlignCenter)
then char ':'
else char ch)
diff --git a/test/command/3526.md b/test/command/3526.md
new file mode 100644
index 000000000..e197bcf32
--- /dev/null
+++ b/test/command/3526.md
@@ -0,0 +1,14 @@
+```
+% pandoc -t rst
++--+---+
+| | |
++--+---+
+| | |
++--+---+
+^D
++---+---+
+| | |
++---+---+
+| | |
++---+---+
+```