aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/Muse.hs9
-rw-r--r--test/Tests/Writers/Muse.hs6
2 files changed, 11 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs
index b74016ec2..005909ac1 100644
--- a/src/Text/Pandoc/Writers/Muse.hs
+++ b/src/Text/Pandoc/Writers/Muse.hs
@@ -171,19 +171,20 @@ simpleTable :: PandocMonad m
-> [[TableCell]]
-> Muse m Doc
simpleTable caption headers rows = do
+ topLevel <- asks envTopLevel
caption' <- inlineListToMuse caption
headers' <- mapM blockListToMuse headers
rows' <- mapM (mapM blockListToMuse) rows
let widthsInChars = maximum . map offset <$> transpose (headers' : rows')
let hpipeBlocks sep blocks = hcat $ intersperse sep' blocks
where sep' = lblock (length sep) $ text sep
- let makeRow sep = (" " <>) . hpipeBlocks sep . zipWith lblock widthsInChars
+ let makeRow sep = hpipeBlocks sep . zipWith lblock widthsInChars
let head' = makeRow " || " headers'
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' <> " +|")
+ return $ (if topLevel then nest 1 else id) ((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 " | "
diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs
index 6cf718c0b..c2439b1a2 100644
--- a/test/Tests/Writers/Muse.hs
+++ b/test/Tests/Writers/Muse.hs
@@ -400,6 +400,12 @@ tests = [ testGroup "block elements"
, " Para 2.1 | Para 2.2"
, " |+ Table 1 +|"
]
+ , "table inside bullet list" =:
+ bulletList [simpleTable [] [[para "foo", para "bar"]
+ ,[para "bat", para "baz"]]]
+ =?> unlines [ " - foo | bar"
+ , " bat | baz"
+ ]
, "table with one column" =:
let headers = []
rows = [[para "Para 1"]