1
1
diff --git a/src/Text/Pandoc/Writers/Haddock.hs b/src/Text/Pandoc/Writers/Haddock.hs
2
- index 9d8c5ec41..139510ecf 100644
2
+ index dfd89bc54..a31132ef1 100644
3
3
--- a/src/Text/Pandoc/Writers/Haddock.hs
4
4
+++ b/src/Text/Pandoc/Writers/Haddock.hs
5
- @@ -121 ,9 +121 ,11 @@ blockToHaddock opts (Table _ blkCapt specs thead tbody tfoot) = do
5
+ @@ -131 ,9 +131 ,11 @@ blockToHaddock opts (Table _ blkCapt specs thead tbody tfoot) = do
6
6
let caption'' = if null caption
7
7
then empty
8
8
else blankline <> caption' <> blankline
@@ -17,10 +17,10 @@ index 9d8c5ec41..139510ecf 100644
17
17
blockToHaddock opts (BulletList items) = do
18
18
contents <- mapM (bulletListItemToHaddock opts) items
19
19
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
20
- index e41273b27..b34e440af 100644
20
+ index f6a207991..746d01602 100644
21
21
--- a/src/Text/Pandoc/Writers/Markdown.hs
22
22
+++ b/src/Text/Pandoc/Writers/Markdown.hs
23
- @@ -640 ,7 +640 ,7 @@ blockToMarkdown' opts t@(Table _ blkCapt specs thead tbody tfoot) = do
23
+ @@ -622 ,7 +622 ,7 @@ blockToMarkdown' opts t@(Table _ blkCapt specs thead tbody tfoot) = do
24
24
| isEnabled Ext_grid_tables opts &&
25
25
writerColumns opts >= 8 * numcols -> (id,) <$>
26
26
gridTable opts blockListToMarkdown
@@ -30,10 +30,10 @@ index e41273b27..b34e440af 100644
30
30
isEnabled Ext_pipe_tables opts -> do
31
31
rawHeaders <- padRow <$> mapM (blockListToMarkdown opts) headers
32
32
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs
33
- index bf3265107..d1a4c5a31 100644
33
+ index f3eecceb8..90fce5fa1 100644
34
34
--- a/src/Text/Pandoc/Writers/Muse.hs
35
35
+++ b/src/Text/Pandoc/Writers/Muse.hs
36
- @@ -264 ,7 +264 ,7 @@ blockToMuse (Table _ blkCapt specs thead tbody tfoot) =
36
+ @@ -266 ,7 +266 ,7 @@ blockToMuse (Table _ blkCapt specs thead tbody tfoot) =
37
37
then simpleTable caption headers rows
38
38
else do
39
39
opts <- asks envOptions
@@ -43,10 +43,10 @@ index bf3265107..d1a4c5a31 100644
43
43
(caption, aligns, widths, headers, rows) = toLegacyTable blkCapt specs thead tbody tfoot
44
44
blocksToDoc opts blocks =
45
45
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
46
- index 43bf382b7..98b4ef3f6 100644
46
+ index 021674b34..a4cc1f429 100644
47
47
--- a/src/Text/Pandoc/Writers/RST.hs
48
48
+++ b/src/Text/Pandoc/Writers/RST.hs
49
- @@ -296 ,15 +296 ,16 @@ blockToRST (Table _ blkCapt specs thead tbody tfoot) = do
49
+ @@ -322 ,15 +322 ,16 @@ blockToRST (Table _ blkCapt specs thead tbody tfoot) = do
50
50
return result
51
51
opts <- gets stOptions
52
52
let isSimple = all (== 0) widths && length widths > 1
@@ -66,29 +66,29 @@ index 43bf382b7..98b4ef3f6 100644
66
66
headers rows
67
67
return $ blankline $$
68
68
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
69
- index 642b33933..7c341df7b 100644
69
+ index 64cd85997..9ae09809c 100644
70
70
--- a/src/Text/Pandoc/Writers/Shared.hs
71
71
+++ b/src/Text/Pandoc/Writers/Shared.hs
72
- @@ -211 ,12 +211 ,17 @@ gridTable :: (Monad m, HasChars a)
72
+ @@ -236 ,12 +236 ,17 @@ gridTable :: (Monad m, HasChars a)
73
73
=> WriterOptions
74
- -> (WriterOptions -> [Block] -> m (Doc a))
75
- -> Bool -- ^ headless
74
+ -> (WriterOptions -> [Block] -> m (Doc a)) -- ^ format Doc writer
75
+ -> Bool -- ^ headless
76
76
+ -> Bool
77
77
+ -- ^ strict wrapping, this applies when wrapping with given widths.
78
78
+ -- If it is false then the columns may be wider than specified. They
79
79
+ -- may be widened to accomodate the contents generated by blocksToDoc
80
80
+ -- at their minimum width rendering.
81
- -> [Alignment]
82
- -> [Double]
83
- -> [[Block]]
84
- -> [[[Block]]]
81
+ -> [Alignment] -- ^ column alignments
82
+ -> [Double] -- ^ column widths
83
+ -> [[Block]] -- ^ table header row
84
+ -> [[[Block]]] -- ^ table body rows
85
85
-> m (Doc a)
86
86
- gridTable opts blocksToDoc headless aligns widths headers rows = do
87
87
+ gridTable opts blocksToDoc headless strictWrapping aligns widths headers rows = do
88
88
-- the number of columns will be used in case of even widths
89
- let numcols = maximum (length aligns : length widths :
89
+ let numcols = maximum (length aligns :| length widths :
90
90
map length (headers:rows))
91
- @@ -238 ,7 +243 ,15 @@ gridTable opts blocksToDoc headless aligns widths headers rows = do
91
+ @@ -263 ,7 +268 ,15 @@ gridTable opts blocksToDoc headless aligns widths headers rows = do
92
92
rawRows' <- mapM
93
93
(\cs -> zipWithM blocksToDoc columnOptions cs)
94
94
rows
@@ -105,3 +105,11 @@ index 642b33933..7c341df7b 100644
105
105
let handleGivenWidths widths' = handleGivenWidthsInChars
106
106
(officialWidthsInChars widths')
107
107
-- handleFullWidths tries to wrap cells to the page width or even
108
+ @@ -307,6 +320,7 @@ gridTable opts blocksToDoc headless aligns widths headers rows = do
109
+ -- on command line options, widths given in this specific table, and
110
+ -- cells' contents
111
+ let handleWidths
112
+ + | strictWrapping = handleFullWidths widths
113
+ | writerWrapText opts == WrapNone = handleFullWidths widths
114
+ | all (== 0) widths = handleZeroWidths widths
115
+ | otherwise = handleGivenWidths widths
0 commit comments