git.iko.soy/typeable/pandoc
on master help sign in
Org reader: text adjacent to a list yields a Plain, not Para.
87096c6John MacFarlane
src/Text/Pandoc/Readers/Org.hs+7−3
@@ -44,7 +44,7 @@ import Text.Pandoc.Shared (compactify', compactify'DL)
44import Text.TeXMath (texMathToPandoc, DisplayType(..))
44import Text.TeXMath (texMathToPandoc, DisplayType(..))
45
45
46import Control.Applicative ( Applicative, pure
46import Control.Applicative ( Applicative, pure
47− , (<$>), (<$), (<*>), (<*), (*>), (<**>) )
47+ , (<$>), (<$), (<*>), (<*), (*>) )
48import Control.Arrow (first)
48import Control.Arrow (first)
49import Control.Monad (foldM, guard, liftM, liftM2, mplus, mzero, when)
49import Control.Monad (foldM, guard, liftM, liftM2, mplus, mzero, when)
50import Control.Monad.Reader (Reader, runReader, ask, asks)
50import Control.Monad.Reader (Reader, runReader, ask, asks)
@@ -802,8 +802,12 @@ noteBlock = try $ do
802
802
803-- Paragraphs or Plain text
803-- Paragraphs or Plain text
804paraOrPlain :: OrgParser (F Blocks)
804paraOrPlain :: OrgParser (F Blocks)
805−paraOrPlain = try $
805+paraOrPlain = try $ do
806− parseInlines <**> (fmap <$> option B.plain (try $ newline *> pure B.para))
806+ ils <- parseInlines
807+ nl <- option False (newline >> return True)
808+ try (guard nl >> notFollowedBy (orderedListStart <|> bulletListStart) >>
809+ return (B.para <$> ils))
810+ <|> (return (B.plain <$> ils))
807
811
808inlinesTillNewline :: OrgParser (F Inlines)
812inlinesTillNewline :: OrgParser (F Inlines)
809inlinesTillNewline = trimInlinesF . mconcat <$> manyTill inline newline
813inlinesTillNewline = trimInlinesF . mconcat <$> manyTill inline newline
tests/Tests/Readers/Org.hs+7−7
@@ -593,7 +593,7 @@ tests =
593 " + Technologic\n" ++
593 " + Technologic\n" ++
594 " + Robot Rock\n") =?>
594 " + Robot Rock\n") =?>
595 bulletList [ mconcat
595 bulletList [ mconcat
596− [ para "Discovery"
596+ [ plain "Discovery"
597 , bulletList [ plain ("One" <> space <>
597 , bulletList [ plain ("One" <> space <>
598 "More" <> space <>
598 "More" <> space <>
599 "Time")
599 "Time")
@@ -604,14 +604,14 @@ tests =
604 ]
604 ]
605 ]
605 ]
606 , mconcat
606 , mconcat
607− [ para "Homework"
607+ [ plain "Homework"
608 , bulletList [ plain ("Around" <> space <>
608 , bulletList [ plain ("Around" <> space <>
609 "the" <> space <>
609 "the" <> space <>
610 "World")
610 "World")
611 ]
611 ]
612 ]
612 ]
613 , mconcat
613 , mconcat
614− [ para ("Human" <> space <> "After" <> space <> "All")
614+ [ plain ("Human" <> space <> "After" <> space <> "All")
615 , bulletList [ plain "Technologic"
615 , bulletList [ plain "Technologic"
616 , plain ("Robot" <> space <> "Rock")
616 , plain ("Robot" <> space <> "Rock")
617 ]
617 ]
@@ -654,13 +654,13 @@ tests =
654 " 2. Two-Two\n") =?>
654 " 2. Two-Two\n") =?>
655 let listStyle = (1, DefaultStyle, DefaultDelim)
655 let listStyle = (1, DefaultStyle, DefaultDelim)
656 listStructure = [ mconcat
656 listStructure = [ mconcat
657− [ para "One"
657+ [ plain "One"
658 , orderedList [ plain "One-One"
658 , orderedList [ plain "One-One"
659 , plain "One-Two"
659 , plain "One-Two"
660 ]
660 ]
661 ]
661 ]
662 , mconcat
662 , mconcat
663− [ para "Two"
663+ [ plain "Two"
664 , orderedList [ plain "Two-One"
664 , orderedList [ plain "Two-One"
665 , plain "Two-Two"
665 , plain "Two-Two"
666 ]
666 ]
@@ -671,14 +671,14 @@ tests =
671 , "Ordered List in Bullet List" =:
671 , "Ordered List in Bullet List" =:
672 ("- Emacs\n" ++
672 ("- Emacs\n" ++
673 " 1. Org\n") =?>
673 " 1. Org\n") =?>
674− bulletList [ (para "Emacs") <>
674+ bulletList [ (plain "Emacs") <>
675 (orderedList [ plain "Org"])
675 (orderedList [ plain "Org"])
676 ]
676 ]
677
677
678 , "Bullet List in Ordered List" =:
678 , "Bullet List in Ordered List" =:
679 ("1. GNU\n" ++
679 ("1. GNU\n" ++
680 " - Freedom\n") =?>
680 " - Freedom\n") =?>
681− orderedList [ (para "GNU") <> bulletList [ (plain "Freedom") ] ]
681+ orderedList [ (plain "GNU") <> bulletList [ (plain "Freedom") ] ]
682
682
683 , "Definition List" =:
683 , "Definition List" =:
684 unlines [ "- PLL :: phase-locked loop"
684 unlines [ "- PLL :: phase-locked loop"