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

commit4aa84f40060884311324d3dd0a81ec22fdd9329f authorJohn MacFarlane <jgm@berkeley.edu> dateSat 21 Oct 2017, 21:51 (9 years ago) parent204776c
1 file changed+6−1
src/Text/Pandoc/Error.hs+6−1
src/Text/Pandoc/Error.hs+6−1
@@ -90,7 +90,12 @@ handleError (Left e) =
9090 ,"\n", replicate (errColumn - 1) ' '
9191 ,"^"]
9292 else ""
93− in err 65 $ "\nError at " ++ show err' ++ errorInFile
93+ in err 65 $ "\nError at " ++ show err' ++
94+ -- if error comes from a chunk or included file,
95+ -- then we won't get the right text this way:
96+ if sourceName errPos == "source"
97+ then errorInFile
98+ else ""
9499 PandocMakePDFError s -> err 65 s
95100 PandocOptionError s -> err 2 s
96101 PandocSyntaxMapError s -> err 67 s