git.iko.soy/typeable/pandoc
on master help sign in
Text.Pandoc.Error: fix line calculations in reporting parsec errors.

Also remove a spurious initial newline in the error report.

commitf045e59248116228093bfebf03ce9f7f4f0cc4ce authorJohn MacFarlane <jgm@berkeley.edu> dateMon 28 Jun 2021, 13:28 (5 years ago) parent4262898
1 file changed+3−3
src/Text/Pandoc/Error.hs+3−3
src/Text/Pandoc/Error.hs+3−3
@@ -97,13 +97,13 @@ renderError e =
9797 [] -> ""
9898 ((pos,txt):_) ->
9999 let ls = T.lines txt <> [""]
100− ln = errLine - sourceLine pos
101− in if length ls > ln - 1
100+ ln = (errLine - sourceLine pos) + 1
101+ in if length ls > ln && ln >= 1
102102 then T.concat ["\n", ls !! (ln - 1)
103103 ,"\n", T.replicate (errColumn - 1) " "
104104 ,"^"]
105105 else ""
106− in "\nError at " <> tshow err' <> errorInFile
106+ in "Error at " <> tshow err' <> errorInFile
107107 PandocMakePDFError s -> s
108108 PandocOptionError s -> s
109109 PandocSyntaxMapError s -> s