diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-07-20 16:33:59 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-07-20 16:33:59 -0700 |
commit | 4af8eed764e4b5f84377cf946b03203d01078102 (patch) | |
tree | 198ad4642cab66eda50ee4dad3825a972dff5abb /tests | |
parent | cdc4ecbe98471512b6751c4068002218b5b28f33 (diff) | |
download | pandoc-4af8eed764e4b5f84377cf946b03203d01078102.tar.gz |
Markdown reader: revised definition list syntax (closes #1429).
* This change brings pandoc's definition list syntax into alignment
with that used in PHP markdown extra and multimarkdown (with the
exception that pandoc is more flexible about the definition markers,
allowing tildes as well as colons).
* Lazily wrapped definitions are now allowed; blank space is required
between list items; and the space before definition is used to
determine whether it is a paragraph or a "plain" element.
* For backwards compatibility, a new extension,
`compact_definition_lists`, has been added that restores the behavior
of pandoc 1.12.x, allowing tight definition lists with no blank space
between items, and disallowing lazy wrapping.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Tests/Readers/Markdown.hs | 41 | ||||
-rw-r--r-- | tests/testsuite.txt | 12 |
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/Tests/Readers/Markdown.hs b/tests/Tests/Readers/Markdown.hs index f7d07f6cd..6e64a6f15 100644 --- a/tests/Tests/Readers/Markdown.hs +++ b/tests/Tests/Readers/Markdown.hs @@ -16,6 +16,10 @@ markdown = readMarkdown def markdownSmart :: String -> Pandoc markdownSmart = readMarkdown def { readerSmart = True } +markdownCDL :: String -> Pandoc +markdownCDL = readMarkdown def { readerExtensions = Set.insert + Ext_compact_definition_lists $ readerExtensions def } + infix 4 =: (=:) :: ToString c => String -> (String, c) -> Test @@ -222,6 +226,43 @@ tests = [ testGroup "inline code" -- , testGroup "round trip" -- [ property "p_markdown_round_trip" p_markdown_round_trip -- ] + , testGroup "definition lists" + [ "no blank space" =: + "foo1\n : bar\n\nfoo2\n : bar2\n : bar3\n" =?> + definitionList [ (text "foo1", [plain (text "bar")]) + , (text "foo2", [plain (text "bar2"), + plain (text "bar3")]) + ] + , "blank space before first def" =: + "foo1\n\n : bar\n\nfoo2\n\n : bar2\n : bar3\n" =?> + definitionList [ (text "foo1", [para (text "bar")]) + , (text "foo2", [para (text "bar2"), + plain (text "bar3")]) + ] + , "blank space before second def" =: + "foo1\n : bar\n\nfoo2\n : bar2\n\n : bar3\n" =?> + definitionList [ (text "foo1", [plain (text "bar")]) + , (text "foo2", [plain (text "bar2"), + para (text "bar3")]) + ] + , "laziness" =: + "foo1\n : bar\nbaz\n : bar2\n" =?> + definitionList [ (text "foo1", [plain (text "bar baz"), + plain (text "bar2")]) + ] + , "no blank space before first of two paragraphs" =: + "foo1\n : bar\n\n baz\n" =?> + definitionList [ (text "foo1", [para (text "bar") <> + para (text "baz")]) + ] + ] + , testGroup "+compact_definition_lists" + [ test markdownCDL "basic compact list" $ + "foo1\n: bar\n baz\nfoo2\n: bar2\n" =?> + definitionList [ (text "foo1", [plain (text "bar baz")]) + , (text "foo2", [plain (text "bar2")]) + ] + ] , testGroup "lists" [ "issue #1154" =: " - <div>\n first div breaks\n </div>\n\n <button>if this button exists</button>\n\n <div>\n with this div too.\n </div>\n" diff --git a/tests/testsuite.txt b/tests/testsuite.txt index 4ddaae23f..f6b0a7c95 100644 --- a/tests/testsuite.txt +++ b/tests/testsuite.txt @@ -270,8 +270,10 @@ Tight using spaces: apple : red fruit + orange : orange fruit + banana : yellow fruit @@ -279,31 +281,38 @@ Tight using tabs: apple : red fruit + orange : orange fruit + banana : yellow fruit Loose: apple + : red fruit orange + : orange fruit banana + : yellow fruit Multiple blocks with italics: *apple* + : red fruit contains seeds, crisp, pleasant to taste *orange* + : orange fruit { orange code block } @@ -315,6 +324,7 @@ Multiple definitions, tight: apple : red fruit : computer + orange : orange fruit : bank @@ -322,11 +332,13 @@ orange Multiple definitions, loose: apple + : red fruit : computer orange + : orange fruit : bank |