From 599327bee1eac3662ec2ab32e32d794246940e25 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Mon, 7 Jan 2019 22:10:34 -0800 Subject: [PATCH] Asciidoc writer: shorter delimiters for tables, blockquotes. This matches asciidoctor reference docs. Closes #4364. --- src/Text/Pandoc/Writers/AsciiDoc.hs | 5 ++--- test/Tests/Writers/AsciiDoc.hs | 8 ++++---- test/tables.asciidoc | 28 ++++++++++++++-------------- test/writer.asciidoc | 28 ++++++++++++++-------------- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs index 79ebcf2ea..9497d0be8 100644 --- a/src/Text/Pandoc/Writers/AsciiDoc.hs +++ b/src/Text/Pandoc/Writers/AsciiDoc.hs @@ -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 diff --git a/test/Tests/Writers/AsciiDoc.hs b/test/Tests/Writers/AsciiDoc.hs index d31d4ffe2..ea61ed044 100644 --- a/test/Tests/Writers/AsciiDoc.hs +++ b/test/Tests/Writers/AsciiDoc.hs @@ -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" , "" - , "|=====" + , "|===" ] ] ] diff --git a/test/tables.asciidoc b/test/tables.asciidoc index 75632157e..6836415d6 100644 --- a/test/tables.asciidoc +++ b/test/tables.asciidoc @@ -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. -|======================================================================= +|=== diff --git a/test/writer.asciidoc b/test/writer.asciidoc index 1348ca8f8..7d8d74aa6 100644 --- a/test/writer.asciidoc +++ b/test/writer.asciidoc @@ -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.]