summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-07-20 12:56:01 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-07-20 12:56:01 -0700
commit87096c64f8707c660303a45e16bc1b6741781542 (patch)
treee982e07dd2605c4a94589154de49fd3945dd1f2a
parent0f01421f81f6075d7f76e66b3d2515cddf5ccdb9 (diff)
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?
-rw-r--r--src/Text/Pandoc/Readers/Org.hs10
-rw-r--r--tests/Tests/Readers/Org.hs14
2 files changed, 14 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index 41ba5c1a6..34e98380e 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -44,7 +44,7 @@ import Text.Pandoc.Shared (compactify', compactify'DL)
import Text.TeXMath (texMathToPandoc, DisplayType(..))
import Control.Applicative ( Applicative, pure
- , (<$>), (<$), (<*>), (<*), (*>), (<**>) )
+ , (<$>), (<$), (<*>), (<*), (*>) )
import Control.Arrow (first)
import Control.Monad (foldM, guard, liftM, liftM2, mplus, mzero, when)
import Control.Monad.Reader (Reader, runReader, ask, asks)
@@ -802,8 +802,12 @@ noteBlock = try $ do
-- Paragraphs or Plain text
paraOrPlain :: OrgParser (F Blocks)
-paraOrPlain = try $
- parseInlines <**> (fmap <$> option B.plain (try $ newline *> pure B.para))
+paraOrPlain = try $ do
+ ils <- parseInlines
+ nl <- option False (newline >> return True)
+ try (guard nl >> notFollowedBy (orderedListStart <|> bulletListStart) >>
+ return (B.para <$> ils))
+ <|> (return (B.plain <$> ils))
inlinesTillNewline :: OrgParser (F Inlines)
inlinesTillNewline = trimInlinesF . mconcat <$> manyTill inline newline
diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs
index d56b57a94..cc4e495f3 100644
--- a/tests/Tests/Readers/Org.hs
+++ b/tests/Tests/Readers/Org.hs
@@ -593,7 +593,7 @@ tests =
" + Technologic\n" ++
" + Robot Rock\n") =?>
bulletList [ mconcat
- [ para "Discovery"
+ [ plain "Discovery"
, bulletList [ plain ("One" <> space <>
"More" <> space <>
"Time")
@@ -604,14 +604,14 @@ tests =
]
]
, mconcat
- [ para "Homework"
+ [ plain "Homework"
, bulletList [ plain ("Around" <> space <>
"the" <> space <>
"World")
]
]
, mconcat
- [ para ("Human" <> space <> "After" <> space <> "All")
+ [ plain ("Human" <> space <> "After" <> space <> "All")
, bulletList [ plain "Technologic"
, plain ("Robot" <> space <> "Rock")
]
@@ -654,13 +654,13 @@ tests =
" 2. Two-Two\n") =?>
let listStyle = (1, DefaultStyle, DefaultDelim)
listStructure = [ mconcat
- [ para "One"
+ [ plain "One"
, orderedList [ plain "One-One"
, plain "One-Two"
]
]
, mconcat
- [ para "Two"
+ [ plain "Two"
, orderedList [ plain "Two-One"
, plain "Two-Two"
]
@@ -671,14 +671,14 @@ tests =
, "Ordered List in Bullet List" =:
("- Emacs\n" ++
" 1. Org\n") =?>
- bulletList [ (para "Emacs") <>
+ bulletList [ (plain "Emacs") <>
(orderedList [ plain "Org"])
]
, "Bullet List in Ordered List" =:
("1. GNU\n" ++
" - Freedom\n") =?>
- orderedList [ (para "GNU") <> bulletList [ (plain "Freedom") ] ]
+ orderedList [ (plain "GNU") <> bulletList [ (plain "Freedom") ] ]
, "Definition List" =:
unlines [ "- PLL :: phase-locked loop"