aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Muse.hs9
-rw-r--r--test/Tests/Readers/Muse.hs89
2 files changed, 93 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs
index ca40cebe3..201a59fc0 100644
--- a/src/Text/Pandoc/Readers/Muse.hs
+++ b/src/Text/Pandoc/Readers/Muse.hs
@@ -302,7 +302,6 @@ noteBlock = try $ do
listLine :: PandocMonad m => Int -> MuseParser m String
listLine markerLength = try $ do
- notFollowedBy blankline
indentWith markerLength
anyLineNewline
@@ -317,9 +316,9 @@ withListContext p = do
listContinuation :: PandocMonad m => Int -> MuseParser m String
listContinuation markerLength = try $ do
- blanks <- many1 blankline
result <- many1 $ listLine markerLength
- return $ blanks ++ concat result
+ blank <- option "" ("\n" <$ blankline)
+ return $ concat result ++ blank
listStart :: PandocMonad m => MuseParser m Int -> MuseParser m Int
listStart marker = try $ do
@@ -334,9 +333,9 @@ listItem :: PandocMonad m => MuseParser m Int -> MuseParser m (F Blocks)
listItem start = try $ do
markerLength <- start
firstLine <- anyLineNewline
- blank <- option "" ("\n" <$ blankline)
restLines <- many $ listLine markerLength
- let first = firstLine ++ blank ++ concat restLines
+ blank <- option "" ("\n" <$ blankline)
+ let first = firstLine ++ concat restLines ++ blank
rest <- many $ listContinuation markerLength
parseFromString (withListContext parseBlocks) $ concat (first:rest) ++ "\n"
diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs
index 6e04fd943..33fe2aeb3 100644
--- a/test/Tests/Readers/Muse.hs
+++ b/test/Tests/Readers/Muse.hs
@@ -309,6 +309,95 @@ tests =
, para "c"
]
]
+ -- Emacs Muse allows to separate lists with two or more blank lines.
+ -- Text::Amuse (Amusewiki engine) always creates a single list as of version 0.82.
+ -- pandoc follows Emacs Muse behavior
+ , testGroup "Blank lines"
+ [ "Blank lines between list items are not required" =:
+ T.unlines
+ [ " - Foo"
+ , " - Bar"
+ ] =?>
+ bulletList [ para "Foo"
+ , para "Bar"
+ ]
+ , "One blank line between list items is allowed" =:
+ T.unlines
+ [ " - Foo"
+ , ""
+ , " - Bar"
+ ] =?>
+ bulletList [ para "Foo"
+ , para "Bar"
+ ]
+ , "Two blank lines separate lists" =:
+ T.unlines
+ [ " - Foo"
+ , ""
+ , ""
+ , " - Bar"
+ ] =?>
+ bulletList [ para "Foo" ] <> bulletList [ para "Bar" ]
+ , "No blank line after multiline first item" =:
+ T.unlines
+ [ " - Foo"
+ , " bar"
+ , " - Baz"
+ ] =?>
+ bulletList [ para "Foo bar"
+ , para "Baz"
+ ]
+ , "One blank line after multiline first item" =:
+ T.unlines
+ [ " - Foo"
+ , " bar"
+ , ""
+ , " - Baz"
+ ] =?>
+ bulletList [ para "Foo bar"
+ , para "Baz"
+ ]
+ , "Two blank lines after multiline first item" =:
+ T.unlines
+ [ " - Foo"
+ , " bar"
+ , ""
+ , ""
+ , " - Baz"
+ ] =?>
+ bulletList [ para "Foo bar" ] <> bulletList [ para "Baz" ]
+ , "No blank line after list continuation" =:
+ T.unlines
+ [ " - Foo"
+ , ""
+ , " bar"
+ , " - Baz"
+ ] =?>
+ bulletList [ para "Foo" <> para "bar"
+ , para "Baz"
+ ]
+ , "One blank line after list continuation" =:
+ T.unlines
+ [ " - Foo"
+ , ""
+ , " bar"
+ , ""
+ , " - Baz"
+ ] =?>
+ bulletList [ para "Foo" <> para "bar"
+ , para "Baz"
+ ]
+ , "Two blank lines after list continuation" =:
+ T.unlines
+ [ " - Foo"
+ , ""
+ , " bar"
+ , ""
+ , ""
+ , " - Baz"
+ ] =?>
+ bulletList [ para "Foo" <> para "bar" ] <> bulletList [ para "Baz" ]
+ ]
-- Headers in first column of list continuation are not allowed
, "No headers in list continuation" =:
T.unlines