git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: debug list and list item separation rules (#3837)
commit8164a005c0ac9e36d9d1485fcf38e9073a1bcd68 authorAlexander <ilabdsf@gmail.com> dateSun 6 Aug 2017, 23:19 (9 years ago) parent685788c
2 files changed+93−5
src/Text/Pandoc/Readers/Muse.hs+4−5 test/Tests/Readers/Muse.hs+89
src/Text/Pandoc/Readers/Muse.hs+4−5
@@ -302,7 +302,6 @@ noteBlock = try $ do
302302
303303listLine :: PandocMonad m => Int -> MuseParser m String
304304listLine markerLength = try $ do
305− notFollowedBy blankline
306305 indentWith markerLength
307306 anyLineNewline
308307
@@ -317,9 +316,9 @@ withListContext p = do
317316
318317listContinuation :: PandocMonad m => Int -> MuseParser m String
319318listContinuation markerLength = try $ do
320− blanks <- many1 blankline
321319 result <- many1 $ listLine markerLength
322− return $ blanks ++ concat result
320+ blank <- option "" ("\n" <$ blankline)
321+ return $ concat result ++ blank
323322
324323listStart :: PandocMonad m => MuseParser m Int -> MuseParser m Int
325324listStart marker = try $ do
@@ -334,9 +333,9 @@ listItem :: PandocMonad m => MuseParser m Int -> MuseParser m (F Blocks)
334333listItem start = try $ do
335334 markerLength <- start
336335 firstLine <- anyLineNewline
337− blank <- option "" ("\n" <$ blankline)
338336 restLines <- many $ listLine markerLength
339− let first = firstLine ++ blank ++ concat restLines
337+ blank <- option "" ("\n" <$ blankline)
338+ let first = firstLine ++ concat restLines ++ blank
340339 rest <- many $ listContinuation markerLength
341340 parseFromString (withListContext parseBlocks) $ concat (first:rest) ++ "\n"
342341
test/Tests/Readers/Muse.hs+89
@@ -309,6 +309,95 @@ tests =
309309 , para "c"
310310 ]
311311 ]
312+ -- Emacs Muse allows to separate lists with two or more blank lines.
313+ -- Text::Amuse (Amusewiki engine) always creates a single list as of version 0.82.
314+ -- pandoc follows Emacs Muse behavior
315+ , testGroup "Blank lines"
316+ [ "Blank lines between list items are not required" =:
317+ T.unlines
318+ [ " - Foo"
319+ , " - Bar"
320+ ] =?>
321+ bulletList [ para "Foo"
322+ , para "Bar"
323+ ]
324+ , "One blank line between list items is allowed" =:
325+ T.unlines
326+ [ " - Foo"
327+ , ""
328+ , " - Bar"
329+ ] =?>
330+ bulletList [ para "Foo"
331+ , para "Bar"
332+ ]
333+ , "Two blank lines separate lists" =:
334+ T.unlines
335+ [ " - Foo"
336+ , ""
337+ , ""
338+ , " - Bar"
339+ ] =?>
340+ bulletList [ para "Foo" ] <> bulletList [ para "Bar" ]
341+ , "No blank line after multiline first item" =:
342+ T.unlines
343+ [ " - Foo"
344+ , " bar"
345+ , " - Baz"
346+ ] =?>
347+ bulletList [ para "Foo bar"
348+ , para "Baz"
349+ ]
350+ , "One blank line after multiline first item" =:
351+ T.unlines
352+ [ " - Foo"
353+ , " bar"
354+ , ""
355+ , " - Baz"
356+ ] =?>
357+ bulletList [ para "Foo bar"
358+ , para "Baz"
359+ ]
360+ , "Two blank lines after multiline first item" =:
361+ T.unlines
362+ [ " - Foo"
363+ , " bar"
364+ , ""
365+ , ""
366+ , " - Baz"
367+ ] =?>
368+ bulletList [ para "Foo bar" ] <> bulletList [ para "Baz" ]
369+ , "No blank line after list continuation" =:
370+ T.unlines
371+ [ " - Foo"
372+ , ""
373+ , " bar"
374+ , " - Baz"
375+ ] =?>
376+ bulletList [ para "Foo" <> para "bar"
377+ , para "Baz"
378+ ]
379+ , "One blank line after list continuation" =:
380+ T.unlines
381+ [ " - Foo"
382+ , ""
383+ , " bar"
384+ , ""
385+ , " - Baz"
386+ ] =?>
387+ bulletList [ para "Foo" <> para "bar"
388+ , para "Baz"
389+ ]
390+ , "Two blank lines after list continuation" =:
391+ T.unlines
392+ [ " - Foo"
393+ , ""
394+ , " bar"
395+ , ""
396+ , ""
397+ , " - Baz"
398+ ] =?>
399+ bulletList [ para "Foo" <> para "bar" ] <> bulletList [ para "Baz" ]
400+ ]
312401 -- Headers in first column of list continuation are not allowed
313402 , "No headers in list continuation" =:
314403 T.unlines