Fixed bug in org with bulleted lists:

- a
   - b
   * c

was being parsed as a list, even though an unindented `*`
should make a heading.  See
<http://orgmode.org/manual/Plain-lists.html#fn-1>.
This commit is contained in:
John MacFarlane 2014-11-13 23:40:18 -08:00
parent bd245450c4
commit 46d343f474
2 changed files with 12 additions and 5 deletions

View file

@ -879,18 +879,18 @@ bulletListStart = bulletListStart' Nothing
bulletListStart' :: Maybe Int -> OrgParser Int bulletListStart' :: Maybe Int -> OrgParser Int
-- returns length of bulletList prefix, inclusive of marker -- returns length of bulletList prefix, inclusive of marker
bulletListStart' Nothing = do ind <- many spaceChar bulletListStart' Nothing = do ind <- length <$> many spaceChar
when (ind == 0) $ notFollowedBy (char '*')
oneOf bullets oneOf bullets
many1 spaceChar many1 spaceChar
return $ length ind + 1 return (ind + 1)
-- Unindented lists are legal, but they can't use '*' bullets -- Unindented lists are legal, but they can't use '*' bullets
-- We return n to maintain compatibility with the generic listItem -- We return n to maintain compatibility with the generic listItem
bulletListStart' (Just n) = do count (n-1) spaceChar bulletListStart' (Just n) = do count (n-1) spaceChar
oneOf validBullets when (n == 1) $ notFollowedBy (char '*')
oneOf bullets
many1 spaceChar many1 spaceChar
return n return n
where validBullets = if n == 1 then noAsterisks else bullets
noAsterisks = filter (/= '*') bullets
bullets :: String bullets :: String
bullets = "*+-" bullets = "*+-"

View file

@ -622,6 +622,13 @@ tests =
, plain "Item2" , plain "Item2"
] ]
, "Unindented *" =:
("- Item1\n" ++
"* Item2\n") =?>
bulletList [ plain "Item1"
] <>
header 1 "Item2"
, "Multi-line Bullet Lists" =: , "Multi-line Bullet Lists" =:
("- *Fat\n" ++ ("- *Fat\n" ++
" Tony*\n" ++ " Tony*\n" ++