diff options
author | Timothy Humphries <tim@utf8.me> | 2014-10-12 03:18:36 -0400 |
---|---|---|
committer | Timothy Humphries <tim@utf8.me> | 2014-10-12 03:18:36 -0400 |
commit | 4f4b0f031d17927b6787c9deee736cf0892cab70 (patch) | |
tree | 02c16ef9e5d0924e15d16c6865bc673f4ee51971 /src | |
parent | 8b60d430f2095c42daf26f2921359d5c49f0757d (diff) | |
download | pandoc-4f4b0f031d17927b6787c9deee736cf0892cab70.tar.gz |
Respect indent when parsing Org bullet lists
Fixes issue with top-level bullet list parsing.
Previously we would use `many1 spaceChars` rather than respecting
the list's indent level. We also permitted `*` bullets on unindented
lists, which should unambiguously parse as `header 1`.
Combined, this meant headers at a different indent level were
being unwittingly slurped into preceding bullet lists, as per
Issue #1650.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/Org.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs index 5c00a1b27..199c9f2de 100644 --- a/src/Text/Pandoc/Readers/Org.hs +++ b/src/Text/Pandoc/Readers/Org.hs @@ -832,8 +832,9 @@ definitionList = fmap B.definitionList . fmap compactify'DL . sequence <$> many1 (definitionListItem bulletListStart) bulletList :: OrgParser (F Blocks) -bulletList = fmap B.bulletList . fmap compactify' . sequence - <$> many1 (listItem bulletListStart) +bulletList = try $ do n <- lookAhead bulletListStart + fmap B.bulletList . fmap compactify' . sequence + <$> many1 (listItem (bulletListCont n)) orderedList :: OrgParser (F Blocks) orderedList = fmap B.orderedList . fmap compactify' . sequence @@ -850,6 +851,13 @@ bulletListStart :: OrgParser Int bulletListStart = genericListStart bulletListMarker where bulletListMarker = pure <$> oneOf "*-+" +-- parses bullet list marker at a known indent level +bulletListCont :: Int -> OrgParser Int +bulletListCont n + -- Unindented lists are legal, but they can't use '*' bullets + | n <= 1 = oneOf "+-" >> return n + | otherwise = count (n-1) spaceChar >> oneOf "+-*" >> return n + orderedListStart :: OrgParser Int orderedListStart = genericListStart orderedListMarker -- Ordered list markers allowed in org-mode |