Muse writer: Indent tables with one space (#3649)
It is required to trigger Muse table rendering.
This commit is contained in:
parent
6b086acae8
commit
69110cde81
3 changed files with 37 additions and 37 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue