Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
deining opened this issue Feb 16, 2025 · 0 comments
Closed

Comments

@deining
Copy link
Contributor

deining commented Feb 16, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants