diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-07-20 13:51:03 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-07-20 13:51:03 -0700 |
commit | cdc4ecbe98471512b6751c4068002218b5b28f33 (patch) | |
tree | a7dab9b7764b9b5130480a403768f3a4935e61df /src | |
parent | 87096c64f8707c660303a45e16bc1b6741781542 (diff) | |
download | pandoc-cdc4ecbe98471512b6751c4068002218b5b28f33.tar.gz |
readWith: reverted generalization from f201bdcb.
We need input to be a string so we can print the offending line
on an error.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index f77ce60d8..54c645fc5 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -826,10 +826,10 @@ gridTableFooter = blanklines --- -- | Parse a string with a given parser and state. -readWith :: (Show s, Stream s Identity Char) - => ParserT s st Identity a -- ^ parser - -> st -- ^ initial state - -> s -- ^ input +readWith :: (Stream [Char] Identity Char) + => ParserT [Char] st Identity a -- ^ parser + -> st -- ^ initial state + -> [Char] -- ^ input -> a readWith parser state input = case runParser parser state "source" input of @@ -837,16 +837,16 @@ readWith parser state input = let errPos = errorPos err' errLine = sourceLine errPos errColumn = sourceColumn errPos - theline = (lines (show input) ++ [""]) !! (errLine - 1) + theline = (lines input ++ [""]) !! (errLine - 1) in error $ "\nError at " ++ show err' ++ "\n" ++ theline ++ "\n" ++ replicate (errColumn - 1) ' ' ++ "^" Right result -> result -- | Parse a string with @parser@ (for testing). -testStringWith :: (Show s, Show a, Stream s Identity Char) - => ParserT s ParserState Identity a - -> s +testStringWith :: (Show a, Stream [Char] Identity Char) + => ParserT [Char] ParserState Identity a + -> [Char] -> IO () testStringWith parser str = UTF8.putStrLn $ show $ readWith parser defaultParserState str |