diff options
| author | Timothy Humphries <tim@utf8.me> | 2014-10-17 20:06:25 -0400 | 
|---|---|---|
| committer | Timothy Humphries <tim@utf8.me> | 2014-10-17 20:06:25 -0400 | 
| commit | f1f56e85334fd29b4ed670d0b280e85f68e21bf2 (patch) | |
| tree | f07f8b4f200331afdca883b00b2995336dabbd64 /src/Text/Pandoc | |
| parent | 4f4b0f031d17927b6787c9deee736cf0892cab70 (diff) | |
| download | pandoc-f1f56e85334fd29b4ed670d0b280e85f68e21bf2.tar.gz | |
Fix indent issue for definition lists
Tidy up fix for #1650, #1698 as per comments in #1680.
Fix same issue for definition lists with the same method.
Diffstat (limited to 'src/Text/Pandoc')
| -rw-r--r-- | src/Text/Pandoc/Readers/Org.hs | 39 | 
1 files changed, 25 insertions, 14 deletions
| diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs index 199c9f2de..a75e3cec8 100644 --- a/src/Text/Pandoc/Readers/Org.hs +++ b/src/Text/Pandoc/Readers/Org.hs @@ -828,13 +828,14 @@ list :: OrgParser (F Blocks)  list = choice [ definitionList, bulletList, orderedList ] <?> "list"  definitionList :: OrgParser (F Blocks) -definitionList = fmap B.definitionList . fmap compactify'DL . sequence -                 <$> many1 (definitionListItem bulletListStart) +definitionList = try $ do n <- lookAhead (bulletListStart' Nothing) +                          fmap B.definitionList . fmap compactify'DL . sequence +                            <$> many1 (definitionListItem $ bulletListStart' (Just n))  bulletList :: OrgParser (F Blocks) -bulletList = try $ do n <- lookAhead bulletListStart +bulletList = try $ do n <- lookAhead (bulletListStart' Nothing)                        fmap B.bulletList . fmap compactify' . sequence -                        <$> many1 (listItem (bulletListCont n)) +                        <$> many1 (listItem (bulletListStart' $ Just n))  orderedList :: OrgParser (F Blocks)  orderedList = fmap B.orderedList . fmap compactify' . sequence @@ -846,17 +847,27 @@ genericListStart listMarker = try $    (+) <$> (length <$> many spaceChar)        <*> (length <$> listMarker <* many1 spaceChar) --- parses bullet list start and returns its length (excl. following whitespace) +-- parses bullet list marker. maybe we know the indent level  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 +bulletListStart = bulletListStart' Nothing + +bulletListStart' :: Maybe Int -> OrgParser Int +-- returns length of bulletList prefix, inclusive of marker +bulletListStart' Nothing  = do ind <- many spaceChar +                               oneOf bullets +                               many1 spaceChar +                               return $ length ind + 1 + -- Unindented lists are legal, but they can't use '*' bullets + -- We return n to maintain compatibility with the generic listItem +bulletListStart' (Just n) = do count (n-1) spaceChar +                               oneOf validBullets +                               many1 spaceChar +                               return n +  where validBullets = if n == 1 then noAsterisks else bullets +        noAsterisks  = filter (/= '*') bullets + +bullets :: String +bullets = "*+-"  orderedListStart :: OrgParser Int  orderedListStart = genericListStart orderedListMarker | 
