summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-10-21 21:51:16 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-10-21 21:54:38 -0700
commit4aa84f40060884311324d3dd0a81ec22fdd9329f (patch)
treef0755a1f77597ac8fe497e2763ce868ab68421e5
parent204776c0c4d3cfa273985564b3f1ff5fb6485628 (diff)
In rendering PandocParsecError, only print input at error location...
if the source name is `source` (i.e., the top level). Otherwise results will be misleading, since what readM does is to look up the source position of the error in the *original* input, which may not match the input used by parseFromString or in parsing from an included file. Closes #3865. Not a great fix, maybe there's something better that could be done, but this should at least avoid misleading messages.
-rw-r--r--src/Text/Pandoc/Error.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Error.hs b/src/Text/Pandoc/Error.hs
index 2bd8bef0a..a05cdfe43 100644
--- a/src/Text/Pandoc/Error.hs
+++ b/src/Text/Pandoc/Error.hs
@@ -90,7 +90,12 @@ handleError (Left e) =
,"\n", replicate (errColumn - 1) ' '
,"^"]
else ""
- in err 65 $ "\nError at " ++ show err' ++ errorInFile
+ in err 65 $ "\nError at " ++ show err' ++
+ -- if error comes from a chunk or included file,
+ -- then we won't get the right text this way:
+ if sourceName errPos == "source"
+ then errorInFile
+ else ""
PandocMakePDFError s -> err 65 s
PandocOptionError s -> err 2 s
PandocSyntaxMapError s -> err 67 s