transform.toMath, invalid syntax: incorrect position in source file printed out

I’m successfully using function transform.toMath to render equations, I’m using this passthrough render hook to do so:

{{- $opts := dict "output" "htmlAndMathml" "displayMode" (eq .Type "block") }}
{{- with try (transform.ToMath .Inner $opts) }}
  {{- with .Err }}
    {{ errorf "Unable to render mathematical markup to HTML using the transform.ToMath function. The KaTeX display engine threw the following error: %s: see %s." . $.Position }}
  {{- else }}
    {{- .Value }}
    {{- $.Page.Store.Set "hasMath" true }}
  {{- end }}
{{- end -}}

With an invalid syntax given for the TeX content to rendered, I’m getting:

ERROR Unable to render mathematical markup to HTML using the transform.ToMath function.
The KaTeX display engine threw the following error:
template: _default/_markup/render-passthrough.html:2:23: executing "_default/_markup/render-passthrough.html" at <transform.ToMath>:
error calling ToMath: KaTeX parse error:
Undefined control sequence: \foo at position 1: \̲f̲o̲o̲:
see "/path/to/site/content/en/docs/chapter/section/index.md:0:1".

The position given in the last line is always 0:1, regardless of the actual position of the offending code in the source file.

Please create a GitHub issue. It would be helpful if you could test the other render hooks to see if this problem is isolated to the passthrough hook, or if it is present in all hooks.

Although this doesn’t solve the problem, you can avoid providing misleading information by reporting the file name only with .Position.Filename.

Done: