@@ -744,7 +744,7 @@ paraOrPlain = try $ do
744744 -- is directly followed by a list item, in which case the block is read as
745745 -- plain text.
746746 try (guard nl
747− *> notFollowedBy (inList *> (() <$ orderedListStart <|> bulletListStart))
747+ *> notFollowedBy (inList *> (orderedListStart <|> bulletListStart))
748748 *> return (B.para <$> ils))
749749 <|> return (B.plain <$> ils)
750750
@@ -757,40 +757,34 @@ list :: PandocMonad m => OrgParser m (F Blocks)
757757list = choice [ definitionList, bulletList, orderedList ] <?> "list"
758758
759759definitionList :: PandocMonad m => OrgParser m (F Blocks)
760−definitionList = try $ do n <- lookAhead (bulletListStart' Nothing)
761− fmap (B.definitionList . compactifyDL) . sequence
762− <$> many1 (definitionListItem $ bulletListStart' (Just n))
760+definitionList = try $ do
761+ indent <- lookAhead bulletListStart
762+ fmap (B.definitionList . compactifyDL) . sequence
763+ <$> many1 (definitionListItem (bulletListStart `indented` indent))
763764
764765bulletList :: PandocMonad m => OrgParser m (F Blocks)
765−bulletList = try $ do n <- lookAhead (bulletListStart' Nothing)
766− fmap (B.bulletList . compactify) . sequence
767− <$> many1 (listItem (bulletListStart' $ Just n))
766+bulletList = try $ do
767+ indent <- lookAhead bulletListStart
768+ fmap (B.bulletList . compactify) . sequence
769+ <$> many1 (listItem (bulletListStart `indented` indent))
770+
771+indented :: Monad m => OrgParser m Int -> Int -> OrgParser m Int
772+indented indentedMarker minIndent = try $ do
773+ n <- indentedMarker
774+ guard (minIndent <= n)
775+ return n
768776
769777orderedList :: PandocMonad m => OrgParser m (F Blocks)
770−orderedList = fmap (B.orderedList . compactify) . sequence
771− <$> many1 (listItem orderedListStart)
772−
773−bulletListStart' :: Monad m => Maybe Int -> OrgParser m Int
774−-- returns length of bulletList prefix, inclusive of marker
775−bulletListStart' Nothing = do ind <- length <$> many spaceChar
776− oneOf (bullets $ ind == 0)
777− skipSpaces1
778− return (ind + 1)
779−bulletListStart' (Just n) = do count (n-1) spaceChar
780− oneOf (bullets $ n == 1)
781− many1 spaceChar
782− return n
783−
784−-- Unindented lists are legal, but they can't use '*' bullets.
785−-- We return n to maintain compatibility with the generic listItem.
786−bullets :: Bool -> String
787−bullets unindented = if unindented then "+-" else "*+-"
778+orderedList = try $ do
779+ indent <- lookAhead orderedListStart
780+ fmap (B.orderedList . compactify) . sequence
781+ <$> many1 (listItem (orderedListStart `indented` indent))
788782
789783definitionListItem :: PandocMonad m
790784 => OrgParser m Int
791785 -> OrgParser m (F (Inlines, [Blocks]))
792−definitionListItem parseMarkerGetLength = try $ do
793− markerLength <- parseMarkerGetLength
786+definitionListItem parseIndentedMarker = try $ do
787+ markerLength <- parseIndentedMarker
794788 term <- manyTill (noneOf "\n\r") (try definitionMarker)
795789 line1 <- anyLineNewline
796790 blank <- option "" ("\n" <$ blankline)
@@ -802,13 +796,12 @@ definitionListItem parseMarkerGetLength = try $ do
802796 definitionMarker =
803797 spaceChar *> string "::" <* (spaceChar <|> lookAhead newline)
804798
805−
806−-- parse raw text for one list item, excluding start marker and continuations
799+-- | parse raw text for one list item
807800listItem :: PandocMonad m
808801 => OrgParser m Int
809802 -> OrgParser m (F Blocks)
810−listItem start = try . withContext ListItemState $ do
811− markerLength <- try start
803+listItem parseIndentedMarker = try . withContext ListItemState $ do
804+ markerLength <- try parseIndentedMarker
812805 firstLine <- anyLineNewline
813806 blank <- option "" ("\n" <$ blankline)
814807 rest <- concat <$> many (listContinuation markerLength)
@@ -818,9 +811,9 @@ listItem start = try . withContext ListItemState $ do
818811-- Note: nested lists are parsed as continuations.
819812listContinuation :: Monad m => Int
820813 -> OrgParser m String
821−listContinuation markerLength = try $
814+listContinuation markerLength = try $ do
822815 notFollowedBy' blankline
823− *> (mappend <$> (concat <$> many1 listLine)
824− <*> many blankline)
816+ mappend <$> (concat <$> many1 listLine)
817+ <*> many blankline
825818 where
826819 listLine = try $ indentWith markerLength *> anyLineNewline