git.iko.soy/typeable/pandoc
on master help sign in
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

commitd5adbcb7746331d57c914d507286d50f86db0365 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateMon 29 Oct 2007, 21:00 (19 years ago) parent63dfc3a
3 files changed+7−7
src/Text/Pandoc/Readers/Markdown.hs+4−2 src/Text/Pandoc/Readers/RST.hs+1−1 src/Text/Pandoc/Shared.hs+2−4
src/Text/Pandoc/Readers/Markdown.hs+4−2
@@ -142,14 +142,16 @@ parseMarkdown = do
142142 startPos <- getPosition
143143 -- go through once just to get list of reference keys
144144 -- docMinusKeys is the raw document with blanks where the keys were...
145− docMinusKeys <- many (referenceKey <|> lineClump) >>= return . concat
145+ docMinusKeys <- manyTill (referenceKey <|> lineClump) eof >>=
146+ return . concat
146147 setInput docMinusKeys
147148 setPosition startPos
148149 st <- getState
149150 -- go through again for notes unless strict...
150151 if stateStrict st
151152 then return ()
152− else do docMinusNotes <- many (noteBlock <|> lineClump) >>= return . concat
153+ else do docMinusNotes <- manyTill (noteBlock <|> lineClump) eof >>=
154+ return . concat
153155 st <- getState
154156 let reversedNotes = stateNotes st
155157 updateState $ \st -> st { stateNotes = reverse reversedNotes }
src/Text/Pandoc/Readers/RST.hs+1−1
@@ -86,7 +86,7 @@ parseRST = do
8686 startPos <- getPosition
8787 -- go through once just to get list of reference keys
8888 -- docMinusKeys is the raw document with blanks where the keys were...
89− docMinusKeys <- many (referenceKey <|> lineClump) >>= return . concat
89+ docMinusKeys <- manyTill (referenceKey <|> lineClump) eof >>= return . concat
9090 setInput docMinusKeys
9191 setPosition startPos
9292 st <- getState
src/Text/Pandoc/Shared.hs+2−4
@@ -298,10 +298,8 @@ parseFromString parser str = do
298298
299299-- | Parse raw line block up to and including blank lines.
300300lineClump :: GenParser Char st String
301−lineClump = do
302− lns <- many1 (notFollowedBy blankline >> anyLine)
303− blanks <- blanklines <|> (eof >> return "\n")
304− return $ (unlines lns) ++ blanks
301+lineClump = blanklines
302+ <|> (many1 (notFollowedBy blankline >> anyLine) >>= return . unlines)
305303
306304-- | Parse a string of characters between an open character
307305-- and a close character, including text between balanced