git.iko.soy/typeable/pandoc
on master help sign in
Fixed bug in parsing files that begin with blank lines.
d5adbcbfiddlosopher
src/Text/Pandoc/Readers/Markdown.hs+4−2
@@ -142,14 +142,16 @@ parseMarkdown = do
142 startPos <- getPosition
142 startPos <- getPosition
143 -- go through once just to get list of reference keys
143 -- go through once just to get list of reference keys
144 -- docMinusKeys is the raw document with blanks where the keys were...
144 -- 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
146 setInput docMinusKeys
147 setInput docMinusKeys
147 setPosition startPos
148 setPosition startPos
148 st <- getState
149 st <- getState
149 -- go through again for notes unless strict...
150 -- go through again for notes unless strict...
150 if stateStrict st
151 if stateStrict st
151 then return ()
152 then return ()
152− else do docMinusNotes <- many (noteBlock <|> lineClump) >>= return . concat
153+ else do docMinusNotes <- manyTill (noteBlock <|> lineClump) eof >>=
154+ return . concat
153 st <- getState
155 st <- getState
154 let reversedNotes = stateNotes st
156 let reversedNotes = stateNotes st
155 updateState $ \st -> st { stateNotes = reverse reversedNotes }
157 updateState $ \st -> st { stateNotes = reverse reversedNotes }
src/Text/Pandoc/Readers/RST.hs+1−1
@@ -86,7 +86,7 @@ parseRST = do
86 startPos <- getPosition
86 startPos <- getPosition
87 -- go through once just to get list of reference keys
87 -- go through once just to get list of reference keys
88 -- docMinusKeys is the raw document with blanks where the keys were...
88 -- 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
90 setInput docMinusKeys
90 setInput docMinusKeys
91 setPosition startPos
91 setPosition startPos
92 st <- getState
92 st <- getState
src/Text/Pandoc/Shared.hs+2−4
@@ -298,10 +298,8 @@ parseFromString parser str = do
298
298
299-- | Parse raw line block up to and including blank lines.
299-- | Parse raw line block up to and including blank lines.
300lineClump :: GenParser Char st String
300lineClump :: GenParser Char st String
301−lineClump = do
301+lineClump = blanklines
302− lns <- many1 (notFollowedBy blankline >> anyLine)
302+ <|> (many1 (notFollowedBy blankline >> anyLine) >>= return . unlines)
303− blanks <- blanklines <|> (eof >> return "\n")
304− return $ (unlines lns) ++ blanks
305
303
306-- | Parse a string of characters between an open character
304-- | Parse a string of characters between an open character
307-- and a close character, including text between balanced
305-- and a close character, including text between balanced