summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Org.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <tarleb@moltkeplatz.de>2014-04-18 08:33:25 +0200
committerAlbert Krewinkel <tarleb@moltkeplatz.de>2014-04-18 08:34:06 +0200
commitf19d7233d8d3e47912b760fc62a253e5baf8275a (patch)
treedc7e1e95d41a77adf22bbbbae791ec2273f83afc /src/Text/Pandoc/Readers/Org.hs
parent6d6724cf2c6ae6bcc0df312c476e45644c972a85 (diff)
Org reader: Fix parsing of loose lists
Loose lists (i.e. lists with blankline separated items), were parsed as multiple lists, each containing a single item. This patch fixes this issue.
Diffstat (limited to 'src/Text/Pandoc/Readers/Org.hs')
-rw-r--r--src/Text/Pandoc/Readers/Org.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index 88e81f5fc..1fa8d4d5e 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -605,9 +605,10 @@ definitionListItem parseMarkerGetLength = try $ do
markerLength <- parseMarkerGetLength
term <- manyTill (noneOf "\n\r") (try $ string "::")
first <- anyLineNewline
+ blank <- option "" ("\n" <$ blankline)
cont <- concat <$> many (listContinuation markerLength)
term' <- parseFromString inline term
- contents' <- parseFromString parseBlocks $ first ++ cont
+ contents' <- parseFromString parseBlocks $ first ++ blank ++ cont
return $ (,) <$> term' <*> fmap (:[]) contents'
@@ -617,16 +618,18 @@ listItem :: OrgParser Int
listItem start = try $ do
markerLength <- try start
firstLine <- anyLineNewline
+ blank <- option "" ("\n" <$ blankline)
rest <- concat <$> many (listContinuation markerLength)
- parseFromString parseBlocks $ firstLine ++ rest
+ parseFromString parseBlocks $ firstLine ++ blank ++ rest
-- continuation of a list item - indented and separated by blankline or endline.
-- Note: nested lists are parsed as continuations.
listContinuation :: Int
-> OrgParser String
listContinuation markerLength = try $
- mappend <$> many blankline
- <*> (concat <$> many1 listLine)
+ notFollowedBy' blankline
+ *> (mappend <$> (concat <$> many1 listLine)
+ <*> many blankline)
where listLine = try $ indentWith markerLength *> anyLineNewline
anyLineNewline :: OrgParser String