aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/HTML.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-03-28 22:20:05 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-03-28 22:20:05 -0700
commit7cb8b60910ede36bba3598f85a06ddde6fc545d0 (patch)
tree956fd879932010f5ed094ec64eef4eea1c49fe9c /src/Text/Pandoc/Readers/HTML.hs
parent30969974f065710d3abc8dcfcce92a84af32f1d9 (diff)
downloadpandoc-7cb8b60910ede36bba3598f85a06ddde6fc545d0.tar.gz
Parsing: Better error reporting in readWith.
- Specialize readWith to String input. - On error have it print the line in which the error occurred, with a caret pointing to the column. - This should help diagnose parsing problems in LaTeX especially.
Diffstat (limited to 'src/Text/Pandoc/Readers/HTML.hs')
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index 6dbba8c35..32ce46fba 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -59,7 +59,10 @@ readHtml :: ReaderOptions -- ^ Reader options
-> String -- ^ String to parse (assumes @'\n'@ line endings)
-> Pandoc
readHtml opts inp = Pandoc meta blocks
- where blocks = readWith parseBody def{ stateOptions = opts } rest
+ where blocks = case runParser parseBody def{ stateOptions = opts }
+ "source" rest of
+ Left err' -> error $ "\nError at " ++ show err'
+ Right result -> result
tags = canonicalizeTags $
parseTagsOptions parseOptions{ optTagPosition = True } inp
hasHeader = any (~== TagOpen "head" []) tags