git.iko.soy/typeable/pandoc
on master help sign in
Org reader: text adjacent to a list yields a Plain, not Para.

This gives better results for tight lists. Closes #1437. An alternative solution would be to use Para everywhere, and never Plain. I am not sufficiently familiar with org to know which is best. Thoughts, @tarleb?

commit87096c64f8707c660303a45e16bc1b6741781542 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 20 Jul 2014, 12:56 (12 years ago) parent0f01421
2 files changed+14−10
src/Text/Pandoc/Readers/Org.hs+7−3 tests/Tests/Readers/Org.hs+7−7
src/Text/Pandoc/Readers/Org.hs+7−3
@@ -44,7 +44,7 @@ import Text.Pandoc.Shared (compactify', compactify'DL)
4444import Text.TeXMath (texMathToPandoc, DisplayType(..))
4545
4646import Control.Applicative ( Applicative, pure
47− , (<$>), (<$), (<*>), (<*), (*>), (<**>) )
47+ , (<$>), (<$), (<*>), (<*), (*>) )
4848import Control.Arrow (first)
4949import Control.Monad (foldM, guard, liftM, liftM2, mplus, mzero, when)
5050import Control.Monad.Reader (Reader, runReader, ask, asks)
@@ -802,8 +802,12 @@ noteBlock = try $ do
802802
803803-- Paragraphs or Plain text
804804paraOrPlain :: OrgParser (F Blocks)
805−paraOrPlain = try $
806− parseInlines <**> (fmap <$> option B.plain (try $ newline *> pure B.para))
805+paraOrPlain = try $ do
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))
807811
808812inlinesTillNewline :: OrgParser (F Inlines)
809813inlinesTillNewline = trimInlinesF . mconcat <$> manyTill inline newline
tests/Tests/Readers/Org.hs+7−7
@@ -593,7 +593,7 @@ tests =
593593 " + Technologic\n" ++
594594 " + Robot Rock\n") =?>
595595 bulletList [ mconcat
596− [ para "Discovery"
596+ [ plain "Discovery"
597597 , bulletList [ plain ("One" <> space <>
598598 "More" <> space <>
599599 "Time")
@@ -604,14 +604,14 @@ tests =
604604 ]
605605 ]
606606 , mconcat
607− [ para "Homework"
607+ [ plain "Homework"
608608 , bulletList [ plain ("Around" <> space <>
609609 "the" <> space <>
610610 "World")
611611 ]
612612 ]
613613 , mconcat
614− [ para ("Human" <> space <> "After" <> space <> "All")
614+ [ plain ("Human" <> space <> "After" <> space <> "All")
615615 , bulletList [ plain "Technologic"
616616 , plain ("Robot" <> space <> "Rock")
617617 ]
@@ -654,13 +654,13 @@ tests =
654654 " 2. Two-Two\n") =?>
655655 let listStyle = (1, DefaultStyle, DefaultDelim)
656656 listStructure = [ mconcat
657− [ para "One"
657+ [ plain "One"
658658 , orderedList [ plain "One-One"
659659 , plain "One-Two"
660660 ]
661661 ]
662662 , mconcat
663− [ para "Two"
663+ [ plain "Two"
664664 , orderedList [ plain "Two-One"
665665 , plain "Two-Two"
666666 ]
@@ -671,14 +671,14 @@ tests =
671671 , "Ordered List in Bullet List" =:
672672 ("- Emacs\n" ++
673673 " 1. Org\n") =?>
674− bulletList [ (para "Emacs") <>
674+ bulletList [ (plain "Emacs") <>
675675 (orderedList [ plain "Org"])
676676 ]
677677
678678 , "Bullet List in Ordered List" =:
679679 ("1. GNU\n" ++
680680 " - Freedom\n") =?>
681− orderedList [ (para "GNU") <> bulletList [ (plain "Freedom") ] ]
681+ orderedList [ (plain "GNU") <> bulletList [ (plain "Freedom") ] ]
682682
683683 , "Definition List" =:
684684 unlines [ "- PLL :: phase-locked loop"