From 4af8eed764e4b5f84377cf946b03203d01078102 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 20 Jul 2014 16:33:59 -0700 Subject: 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. --- tests/Tests/Readers/Markdown.hs | 41 +++++++++++++++++++++++++++++++++++++++++ tests/testsuite.txt | 12 ++++++++++++ 2 files changed, 53 insertions(+) (limited to 'tests') 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" =: " -
\n first div breaks\n
\n\n \n\n
\n with this div too.\n
\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 -- cgit v1.2.3