Skip to content

Commit

Permalink
Asciidoc writer: shorter delimiters for tables, blockquotes.
Browse files Browse the repository at this point in the history
This matches asciidoctor reference docs.

Closes #4364.
  • Loading branch information
jgm committed Jan 8, 2019
1 parent c1d058a commit 599327b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 35 deletions.
5 changes: 2 additions & 3 deletions src/Text/Pandoc/Writers/AsciiDoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions test/Tests/Writers/AsciiDoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
, ""
, "|====="
, "|==="
]
]
]
28 changes: 14 additions & 14 deletions test/tables.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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:

.Here’s 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 |Here’s 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 |Here’s 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 |Here’s another one. Note the blank line between rows.
|=======================================================================
|===
28 changes: 14 additions & 14 deletions test/writer.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ here.

E-mail style:

__________________________________________
____
This is a block quote. It is pretty short.
__________________________________________
____

______________________
____
--
Code in a block quote:
Expand All @@ -72,16 +72,16 @@ A list:
Nested block quotes:
______
____
nested
______
____
______
____
nested
______
____
--
______________________
____

This should not be a block quote: 2 > 1.

Expand Down Expand Up @@ -306,9 +306,9 @@ _orange_::
{ orange code block }
....
+
__________________
____
orange block quote
__________________
____

Multiple definitions, tight:

Expand Down Expand Up @@ -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/>`

Expand Down Expand Up @@ -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.]
Expand Down

0 comments on commit 599327b

Please sign in to comment.