diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2018-11-06 14:02:10 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2018-11-14 14:48:38 +0300 |
commit | d27384c10962c30c2a9d5cf7bd93fb7e48ff57a4 (patch) | |
tree | 1af151a52dbbd19d74b273f55af5701300a895be /src/Text/Pandoc | |
parent | 6fd3bcceb9374654d79362514862b38991e7a321 (diff) | |
download | pandoc-d27384c10962c30c2a9d5cf7bd93fb7e48ff57a4.tar.gz |
Muse writer: simplify "simpleTable"
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Writers/Muse.hs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index 71fa0aae6..b74016ec2 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -174,22 +174,19 @@ simpleTable caption headers rows = do caption' <- inlineListToMuse caption headers' <- mapM blockListToMuse headers rows' <- mapM (mapM blockListToMuse) rows - let noHeaders = all null headers - let numChars = maximum . map offset - let widthsInChars = - map numChars $ transpose (headers' : rows') + let widthsInChars = maximum . map offset <$> transpose (headers' : rows') let hpipeBlocks sep blocks = hcat $ intersperse sep' blocks - where h = maximum (1 : map height blocks) - sep' = lblock (length sep) $ vcat (replicate h (text sep)) + where sep' = lblock (length sep) $ text sep let makeRow sep = (" " <>) . hpipeBlocks sep . zipWith lblock widthsInChars let head' = makeRow " || " headers' - let rowSeparator = if noHeaders then " | " else " | " rows'' <- mapM (\row -> makeRow rowSeparator <$> mapM blockListToMuse row) rows let body = vcat rows'' return $ (if noHeaders then empty else head') $$ body $$ (if null caption then empty else " |+ " <> caption' <> " +|") $$ blankline + where noHeaders = all null headers + rowSeparator = if noHeaders then " | " else " | " -- | Convert list of Pandoc block elements to Muse. blockListToMuse :: PandocMonad m |