From 69110cde81a7bad260cdca579b4dcca306d4be2b Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 7 May 2017 22:41:38 +0300 Subject: [PATCH] Muse writer: Indent tables with one space (#3649) It is required to trigger Muse table rendering. --- src/Text/Pandoc/Writers/Muse.hs | 4 +-- test/Tests/Writers/Muse.hs | 18 ++++++------ test/tables.muse | 52 ++++++++++++++++----------------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index 8b083e2c6..ccc6e9aef 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -216,7 +216,7 @@ blockToMuse (Table caption _ _ headers rows) = do let hpipeBlocks sep blocks = hcat $ intersperse sep' blocks where h = maximum (1 : map height blocks) sep' = lblock (length sep) $ vcat (map text $ replicate h sep) - let makeRow sep = hpipeBlocks sep . zipWith lblock widthsInChars + let makeRow sep = (" " <>) . (hpipeBlocks sep . zipWith lblock widthsInChars) let head' = makeRow " || " headers' let rowSeparator = if noHeaders then " | " else " | " rows'' <- mapM (\row -> do cols <- mapM blockListToMuse row @@ -224,7 +224,7 @@ blockToMuse (Table caption _ _ headers rows) = do let body = vcat rows'' return $ (if noHeaders then empty else head') $$ body - $$ (if null caption then empty else "|+ " <> caption' <> " +|") + $$ (if null caption then empty else " |+ " <> caption' <> " +|") $$ blankline blockToMuse (Div _ bs) = blockListToMuse bs blockToMuse Null = return empty diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs index 9a7dec580..65bf3e99b 100644 --- a/test/Tests/Writers/Muse.hs +++ b/test/Tests/Writers/Muse.hs @@ -155,8 +155,8 @@ tests = [ testGroup "block elements" ,[para $ text "Para 2.1", para $ text "Para 2.2"]] in simpleTable [] rows =?> - unlines [ "Para 1.1 | Para 1.2" - , "Para 2.1 | Para 2.2" + unlines [ " Para 1.1 | Para 1.2" + , " Para 2.1 | Para 2.2" ] , "table with header" =: let headers = [plain $ text "header 1", plain $ text "header 2"] @@ -164,9 +164,9 @@ tests = [ testGroup "block elements" ,[para $ text "Para 2.1", para $ text "Para 2.2"]] in simpleTable headers rows =?> - unlines [ "header 1 || header 2" - , "Para 1.1 | Para 1.2" - , "Para 2.1 | Para 2.2" + unlines [ " header 1 || header 2" + , " Para 1.1 | Para 1.2" + , " Para 2.1 | Para 2.2" ] , "table with header and caption" =: let caption = text "Table 1" @@ -174,10 +174,10 @@ tests = [ testGroup "block elements" rows = [[para $ text "Para 1.1", para $ text "Para 1.2"] ,[para $ text "Para 2.1", para $ text "Para 2.2"]] in table caption mempty headers rows - =?> unlines [ "header 1 || header 2" - , "Para 1.1 | Para 1.2" - , "Para 2.1 | Para 2.2" - , "|+ Table 1 +|" + =?> unlines [ " header 1 || header 2" + , " Para 1.1 | Para 1.2" + , " Para 2.1 | Para 2.2" + , " |+ Table 1 +|" ] ] -- Div is trivial diff --git a/test/tables.muse b/test/tables.muse index afdccd476..fdf20be49 100644 --- a/test/tables.muse +++ b/test/tables.muse @@ -1,46 +1,46 @@ Simple table with caption: -Right || Left || Center || Default -12 | 12 | 12 | 12 -123 | 123 | 123 | 123 -1 | 1 | 1 | 1 -|+ Demonstration of simple table syntax. +| + Right || Left || Center || Default + 12 | 12 | 12 | 12 + 123 | 123 | 123 | 123 + 1 | 1 | 1 | 1 + |+ Demonstration of simple table syntax. +| Simple table without caption: -Right || Left || Center || Default -12 | 12 | 12 | 12 -123 | 123 | 123 | 123 -1 | 1 | 1 | 1 + Right || Left || Center || Default + 12 | 12 | 12 | 12 + 123 | 123 | 123 | 123 + 1 | 1 | 1 | 1 Simple table indented two spaces: -Right || Left || Center || Default -12 | 12 | 12 | 12 -123 | 123 | 123 | 123 -1 | 1 | 1 | 1 -|+ Demonstration of simple table syntax. +| + Right || Left || Center || Default + 12 | 12 | 12 | 12 + 123 | 123 | 123 | 123 + 1 | 1 | 1 | 1 + |+ Demonstration of simple table syntax. +| Multiline table with caption: -Centered Header || Left Aligned || Right Aligned || Default aligned -First | row | 12.0 | Example of a row that spans multiple lines. -Second | row | 5.0 | Here’s another one. Note the blank line between rows. -|+ Here’s the caption. It may span multiple lines. +| + Centered Header || Left Aligned || Right Aligned || Default aligned + First | row | 12.0 | Example of a row that spans multiple lines. + Second | row | 5.0 | Here’s another one. Note the blank line between rows. + |+ Here’s the caption. It may span multiple lines. +| Multiline table without caption: -Centered Header || Left Aligned || Right Aligned || Default aligned -First | row | 12.0 | Example of a row that spans multiple lines. -Second | row | 5.0 | Here’s another one. Note the blank line between rows. + Centered Header || Left Aligned || Right Aligned || Default aligned + First | row | 12.0 | Example of a row that spans multiple lines. + Second | row | 5.0 | Here’s another one. Note the blank line between rows. Table without column headers: -12 | 12 | 12 | 12 -123 | 123 | 123 | 123 -1 | 1 | 1 | 1 + 12 | 12 | 12 | 12 + 123 | 123 | 123 | 123 + 1 | 1 | 1 | 1 Multiline table without column headers: -First | row | 12.0 | Example of a row that spans multiple lines. -Second | row | 5.0 | Here’s another one. Note the blank line between rows. + First | row | 12.0 | Example of a row that spans multiple lines. + Second | row | 5.0 | Here’s another one. Note the blank line between rows.