RST writer: Avoid stack overflow with certain tables.
Closes #1197. Note that there are still problems with the formatting of the tables inside tables with output produced from the input file in the original bug report. But this fixes the stack overflow problem.
This commit is contained in:
parent
76ef65f0b3
commit
814af2002e
1 changed files with 6 additions and 2 deletions
|
@ -219,11 +219,15 @@ blockToRST (Table caption _ widths headers rows) = do
|
|||
else blankline <> text "Table: " <> caption'
|
||||
headers' <- mapM blockListToRST headers
|
||||
rawRows <- mapM (mapM blockListToRST) rows
|
||||
let isSimple = all (==0) widths && all (all (\bs -> length bs <= 1)) rows
|
||||
-- let isSimpleCell [Plain _] = True
|
||||
-- isSimpleCell [Para _] = True
|
||||
-- isSimpleCell [] = True
|
||||
-- isSimpleCell _ = False
|
||||
-- let isSimple = all (==0) widths && all (all isSimpleCell) rows
|
||||
let numChars = maximum . map offset
|
||||
opts <- get >>= return . stOptions
|
||||
let widthsInChars =
|
||||
if isSimple
|
||||
if all (== 0) widths
|
||||
then map ((+2) . numChars) $ transpose (headers' : rawRows)
|
||||
else map (floor . (fromIntegral (writerColumns opts) *)) widths
|
||||
let hpipeBlocks blocks = hcat [beg, middle, end]
|
||||
|
|
Loading…
Add table
Reference in a new issue