Muse writer: Indent tables with one space (#3649)

It is required to trigger Muse table rendering.
This commit is contained in:
Alexander Krotov 2017-05-07 22:41:38 +03:00 committed by John MacFarlane
parent 6b086acae8
commit 69110cde81
3 changed files with 37 additions and 37 deletions

View file

@ -216,7 +216,7 @@ blockToMuse (Table caption _ _ headers rows) = do
let hpipeBlocks sep blocks = hcat $ intersperse sep' blocks let hpipeBlocks sep blocks = hcat $ intersperse sep' blocks
where h = maximum (1 : map height blocks) where h = maximum (1 : map height blocks)
sep' = lblock (length sep) $ vcat (map text $ replicate h sep) 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 head' = makeRow " || " headers'
let rowSeparator = if noHeaders then " | " else " | " let rowSeparator = if noHeaders then " | " else " | "
rows'' <- mapM (\row -> do cols <- mapM blockListToMuse row rows'' <- mapM (\row -> do cols <- mapM blockListToMuse row
@ -224,7 +224,7 @@ blockToMuse (Table caption _ _ headers rows) = do
let body = vcat rows'' let body = vcat rows''
return $ (if noHeaders then empty else head') return $ (if noHeaders then empty else head')
$$ body $$ body
$$ (if null caption then empty else "|+ " <> caption' <> " +|") $$ (if null caption then empty else " |+ " <> caption' <> " +|")
$$ blankline $$ blankline
blockToMuse (Div _ bs) = blockListToMuse bs blockToMuse (Div _ bs) = blockListToMuse bs
blockToMuse Null = return empty blockToMuse Null = return empty

View file

@ -155,8 +155,8 @@ tests = [ testGroup "block elements"
,[para $ text "Para 2.1", para $ text "Para 2.2"]] ,[para $ text "Para 2.1", para $ text "Para 2.2"]]
in simpleTable [] rows in simpleTable [] rows
=?> =?>
unlines [ "Para 1.1 | Para 1.2" unlines [ " Para 1.1 | Para 1.2"
, "Para 2.1 | Para 2.2" , " Para 2.1 | Para 2.2"
] ]
, "table with header" =: , "table with header" =:
let headers = [plain $ text "header 1", plain $ text "header 2"] 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"]] ,[para $ text "Para 2.1", para $ text "Para 2.2"]]
in simpleTable headers rows in simpleTable headers rows
=?> =?>
unlines [ "header 1 || header 2" unlines [ " header 1 || header 2"
, "Para 1.1 | Para 1.2" , " Para 1.1 | Para 1.2"
, "Para 2.1 | Para 2.2" , " Para 2.1 | Para 2.2"
] ]
, "table with header and caption" =: , "table with header and caption" =:
let caption = text "Table 1" let caption = text "Table 1"
@ -174,10 +174,10 @@ tests = [ testGroup "block elements"
rows = [[para $ text "Para 1.1", para $ text "Para 1.2"] rows = [[para $ text "Para 1.1", para $ text "Para 1.2"]
,[para $ text "Para 2.1", para $ text "Para 2.2"]] ,[para $ text "Para 2.1", para $ text "Para 2.2"]]
in table caption mempty headers rows in table caption mempty headers rows
=?> unlines [ "header 1 || header 2" =?> unlines [ " header 1 || header 2"
, "Para 1.1 | Para 1.2" , " Para 1.1 | Para 1.2"
, "Para 2.1 | Para 2.2" , " Para 2.1 | Para 2.2"
, "|+ Table 1 +|" , " |+ Table 1 +|"
] ]
] ]
-- Div is trivial -- Div is trivial

View file

@ -1,46 +1,46 @@
Simple table with caption: Simple table with caption:
Right || Left || Center || Default Right || Left || Center || Default
12 | 12 | 12 | 12 12 | 12 | 12 | 12
123 | 123 | 123 | 123 123 | 123 | 123 | 123
1 | 1 | 1 | 1 1 | 1 | 1 | 1
|+ Demonstration of simple table syntax. +| |+ Demonstration of simple table syntax. +|
Simple table without caption: Simple table without caption:
Right || Left || Center || Default Right || Left || Center || Default
12 | 12 | 12 | 12 12 | 12 | 12 | 12
123 | 123 | 123 | 123 123 | 123 | 123 | 123
1 | 1 | 1 | 1 1 | 1 | 1 | 1
Simple table indented two spaces: Simple table indented two spaces:
Right || Left || Center || Default Right || Left || Center || Default
12 | 12 | 12 | 12 12 | 12 | 12 | 12
123 | 123 | 123 | 123 123 | 123 | 123 | 123
1 | 1 | 1 | 1 1 | 1 | 1 | 1
|+ Demonstration of simple table syntax. +| |+ Demonstration of simple table syntax. +|
Multiline table with caption: Multiline table with caption:
Centered Header || Left Aligned || Right Aligned || Default aligned Centered Header || Left Aligned || Right Aligned || Default aligned
First | row | 12.0 | Example of a row that spans multiple lines. First | row | 12.0 | Example of a row that spans multiple lines.
Second | row | 5.0 | Heres another one. Note the blank line between rows. Second | row | 5.0 | Heres another one. Note the blank line between rows.
|+ Heres the caption. It may span multiple lines. +| |+ Heres the caption. It may span multiple lines. +|
Multiline table without caption: Multiline table without caption:
Centered Header || Left Aligned || Right Aligned || Default aligned Centered Header || Left Aligned || Right Aligned || Default aligned
First | row | 12.0 | Example of a row that spans multiple lines. First | row | 12.0 | Example of a row that spans multiple lines.
Second | row | 5.0 | Heres another one. Note the blank line between rows. Second | row | 5.0 | Heres another one. Note the blank line between rows.
Table without column headers: Table without column headers:
12 | 12 | 12 | 12 12 | 12 | 12 | 12
123 | 123 | 123 | 123 123 | 123 | 123 | 123
1 | 1 | 1 | 1 1 | 1 | 1 | 1
Multiline table without column headers: Multiline table without column headers:
First | row | 12.0 | Example of a row that spans multiple lines. First | row | 12.0 | Example of a row that spans multiple lines.
Second | row | 5.0 | Heres another one. Note the blank line between rows. Second | row | 5.0 | Heres another one. Note the blank line between rows.