Fixed bug in parsing files that begin with blank lines.
+ In Text.Pandoc.Shared: rewrote lineClump to parse EITHER a string of blank lines OR a string of nonblanks. Removed code for parsing eof. + In Markdown and RST readers, use 'manyTill (... <|> lineClump) eof' instead of many, since lineClump no longer parses eof. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1057 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
parent
63dfc3abf2
commit
d5adbcb774
3 changed files with 7 additions and 7 deletions
|
@ -142,14 +142,16 @@ parseMarkdown = do
|
||||||
startPos <- getPosition
|
startPos <- getPosition
|
||||||
-- go through once just to get list of reference keys
|
-- go through once just to get list of reference keys
|
||||||
-- docMinusKeys is the raw document with blanks where the keys were...
|
-- docMinusKeys is the raw document with blanks where the keys were...
|
||||||
docMinusKeys <- many (referenceKey <|> lineClump) >>= return . concat
|
docMinusKeys <- manyTill (referenceKey <|> lineClump) eof >>=
|
||||||
|
return . concat
|
||||||
setInput docMinusKeys
|
setInput docMinusKeys
|
||||||
setPosition startPos
|
setPosition startPos
|
||||||
st <- getState
|
st <- getState
|
||||||
-- go through again for notes unless strict...
|
-- go through again for notes unless strict...
|
||||||
if stateStrict st
|
if stateStrict st
|
||||||
then return ()
|
then return ()
|
||||||
else do docMinusNotes <- many (noteBlock <|> lineClump) >>= return . concat
|
else do docMinusNotes <- manyTill (noteBlock <|> lineClump) eof >>=
|
||||||
|
return . concat
|
||||||
st <- getState
|
st <- getState
|
||||||
let reversedNotes = stateNotes st
|
let reversedNotes = stateNotes st
|
||||||
updateState $ \st -> st { stateNotes = reverse reversedNotes }
|
updateState $ \st -> st { stateNotes = reverse reversedNotes }
|
||||||
|
|
|
@ -86,7 +86,7 @@ parseRST = do
|
||||||
startPos <- getPosition
|
startPos <- getPosition
|
||||||
-- go through once just to get list of reference keys
|
-- go through once just to get list of reference keys
|
||||||
-- docMinusKeys is the raw document with blanks where the keys were...
|
-- docMinusKeys is the raw document with blanks where the keys were...
|
||||||
docMinusKeys <- many (referenceKey <|> lineClump) >>= return . concat
|
docMinusKeys <- manyTill (referenceKey <|> lineClump) eof >>= return . concat
|
||||||
setInput docMinusKeys
|
setInput docMinusKeys
|
||||||
setPosition startPos
|
setPosition startPos
|
||||||
st <- getState
|
st <- getState
|
||||||
|
|
|
@ -298,10 +298,8 @@ parseFromString parser str = do
|
||||||
|
|
||||||
-- | Parse raw line block up to and including blank lines.
|
-- | Parse raw line block up to and including blank lines.
|
||||||
lineClump :: GenParser Char st String
|
lineClump :: GenParser Char st String
|
||||||
lineClump = do
|
lineClump = blanklines
|
||||||
lns <- many1 (notFollowedBy blankline >> anyLine)
|
<|> (many1 (notFollowedBy blankline >> anyLine) >>= return . unlines)
|
||||||
blanks <- blanklines <|> (eof >> return "\n")
|
|
||||||
return $ (unlines lns) ++ blanks
|
|
||||||
|
|
||||||
-- | Parse a string of characters between an open character
|
-- | Parse a string of characters between an open character
|
||||||
-- and a close character, including text between balanced
|
-- and a close character, including text between balanced
|
||||||
|
|
Loading…
Reference in a new issue