aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-06-28 13:28:22 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-06-28 13:28:49 -0700
commitf045e59248116228093bfebf03ce9f7f4f0cc4ce (patch)
tree6142cdad42a34c55846111109a6ae6865aff8b55 /src/Text/Pandoc
parent4262898fe9cc71abecffc1ffa165dd714c04407d (diff)
downloadpandoc-f045e59248116228093bfebf03ce9f7f4f0cc4ce.tar.gz
Text.Pandoc.Error: fix line calculations in reporting parsec errors.
Also remove a spurious initial newline in the error report.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Error.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Error.hs b/src/Text/Pandoc/Error.hs
index 81eb41f85..9dee8356b 100644
--- a/src/Text/Pandoc/Error.hs
+++ b/src/Text/Pandoc/Error.hs
@@ -97,13 +97,13 @@ renderError e =
[] -> ""
((pos,txt):_) ->
let ls = T.lines txt <> [""]
- ln = errLine - sourceLine pos
- in if length ls > ln - 1
+ ln = (errLine - sourceLine pos) + 1
+ in if length ls > ln && ln >= 1
then T.concat ["\n", ls !! (ln - 1)
,"\n", T.replicate (errColumn - 1) " "
,"^"]
else ""
- in "\nError at " <> tshow err' <> errorInFile
+ in "Error at " <> tshow err' <> errorInFile
PandocMakePDFError s -> s
PandocOptionError s -> s
PandocSyntaxMapError s -> s