Asciidoc writer: shorter delimiters for tables, blockquotes.

This matches asciidoctor reference docs.

Closes #4364.
This commit is contained in:
John MacFarlane 2019-01-07 22:10:34 -08:00
parent c1d058aeb1
commit 599327bee1
4 changed files with 34 additions and 35 deletions

View file

@ -194,8 +194,7 @@ blockToAsciiDoc opts (BlockQuote blocks) = do
let contents' = if any isBlock blocks
then "--" $$ contents $$ "--"
else contents
let cols = offset contents'
let bar = text $ replicate cols '_'
let bar = text "____"
return $ bar $$ chomp contents' $$ bar <> blankline
blockToAsciiDoc opts (Table caption aligns widths headers rows) = do
caption' <- inlineListToAsciiDoc opts caption
@ -252,7 +251,7 @@ blockToAsciiDoc opts (Table caption aligns widths headers rows) = do
else 100000
let maxwidth = maximum $ map offset (head':rows')
let body = if maxwidth > colwidth then vsep rows' else vcat rows'
let border = text $ "|" ++ replicate (max 5 (min maxwidth colwidth) - 1) '='
let border = text "|==="
return $
caption'' $$ tablespec $$ border $$ head'' $$ body $$ border $$ blankline
blockToAsciiDoc opts (BulletList items) = do

View file

@ -37,22 +37,22 @@ tests = [ testGroup "emphasis"
[ test asciidoc "empty cells" $
simpleTable [] [[mempty],[mempty]] =?> unlines
[ "[cols=\"\",]"
, "|===="
, "|==="
, "|"
, "|"
, "|===="
, "|==="
]
, test asciidoc "multiblock cells" $
simpleTable [] [[para (text "Para 1") <> para (text "Para 2")]]
=?> unlines
[ "[cols=\"\",]"
, "|====="
, "|==="
, "a|"
, "Para 1"
, ""
, "Para 2"
, ""
, "|====="
, "|==="
]
]
]

View file

@ -2,66 +2,66 @@ Simple table with caption:
.Demonstration of simple table syntax.
[cols=">,<,^,",options="header",]
|============================
|===
|Right |Left |Center |Default
|12 |12 |12 |12
|123 |123 |123 |123
|1 |1 |1 |1
|============================
|===
Simple table without caption:
[cols=">,<,^,",options="header",]
|============================
|===
|Right |Left |Center |Default
|12 |12 |12 |12
|123 |123 |123 |123
|1 |1 |1 |1
|============================
|===
Simple table indented two spaces:
.Demonstration of simple table syntax.
[cols=">,<,^,",options="header",]
|============================
|===
|Right |Left |Center |Default
|12 |12 |12 |12
|123 |123 |123 |123
|1 |1 |1 |1
|============================
|===
Multiline table with caption:
.Heres the caption. It may span multiple lines.
[width="80%",cols="^20%,<17%,>20%,<43%",options="header",]
|=======================================================================
|===
|Centered Header |Left Aligned |Right Aligned |Default aligned
|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.
|=======================================================================
|===
Multiline table without caption:
[width="80%",cols="^20%,<17%,>20%,<43%",options="header",]
|=======================================================================
|===
|Centered Header |Left Aligned |Right Aligned |Default aligned
|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.
|=======================================================================
|===
Table without column headers:
[cols=">,<,^,>",]
|==================
|===
|12 |12 |12 |12
|123 |123 |123 |123
|1 |1 |1 |1
|==================
|===
Multiline table without column headers:
[width="80%",cols="^20%,<17%,>20%,43%",]
|=======================================================================
|===
|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.
|=======================================================================
|===

View file

@ -50,11 +50,11 @@ here.
E-mail style:
__________________________________________
____
This is a block quote. It is pretty short.
__________________________________________
____
______________________
____
--
Code in a block quote:
@ -72,16 +72,16 @@ A list:
Nested block quotes:
______
____
nested
______
____
______
____
nested
______
____
--
______________________
____
This should not be a block quote: 2 > 1.
@ -306,9 +306,9 @@ _orange_::
{ orange code block }
....
+
__________________
____
orange block quote
__________________
____
Multiple definitions, tight:
@ -602,9 +602,9 @@ With an ampersand: http://example.com/?foo=1&bar=2
An e-mail address: nobody@nowhere.net
________________________________
____
Blockquoted: http://example.com/
________________________________
____
Auto-links should not occur here: `<http://example.com/>`
@ -634,9 +634,9 @@ note.footnote:[This is _easier_ to type. Inline notes may contain
http://google.com[links] and `]` verbatim characters, as well as [bracketed
text].]
___________________________________________
____
Notes can go in quotes.footnote:[In quote.]
___________________________________________
____
[arabic]
. And in list items.footnote:[In list.]