Skip to content

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

Closed
@deining

Description

@deining

As discussed in this thread on hugo's discourse board:

I'm using this passthrough render hook to render equations using function transform.toMath:

{{- with try (transform.ToMath .Inner ) }}
  {{- with .Err }}
    {{ errorf "KaTeX: %s: see %s." . $.Position }}
  {{- else }}
    {{- .Value }}
  {{- end }}
{{- end -}}

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

ERROR KaTeX: template: _default/_markup/render-passthrough.html:1: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/lang/section/subsection/index.md:0:1".

Bug

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

Test of render hooks

As requested in the discourse thread, I tested all available render hooks, this is the result:

Render hook Context has Position Position correct
Block quote yes yes
Code blocks yes yes
Headings no -
Images no -
Links no -
Pass through yes no
Table yes no

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.144.0-DEV-9c2f8ec61beb9521fb606848de2d14aa180facd7+extended linux/amd64

Does this issue reproduce with the latest release?

Yes.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions