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

hyperref in HTML5 produces invalid internal links #316

Open
eudoxos opened this issue Feb 9, 2023 · 0 comments · May be fixed by #363
Open

hyperref in HTML5 produces invalid internal links #316

eudoxos opened this issue Feb 9, 2023 · 0 comments · May be fixed by #363

Comments

@eudoxos
Copy link

eudoxos commented Feb 9, 2023

I am hitting a bug where the HTML5 renderer render \hyperref[label]{text} incorrectly (producing #. anchor):

name: hyperref
<a href="{{ obj.attributes.url }}#{{ obj.attributes.category }}.{{ obj.attributes.name}}" >{{ obj }}</a>

This is trivially reproducible with

\documentclass{article}
\usepackage{hyperref}
\begin{document}
    Reference to \hyprref[foo]{the next section}
    \section{foo}\label{foo}
\end{document}

I get something functional if I copy the definition of ref from

name: ref
{% if 'label' in obj.idref and obj.idref.label.ref %}<a href="{{obj.idref.label.url}}">{{obj.idref.label.ref}}</a>{% else %}??{% endif %}

just replacing {{obj.idref.label.ref}} with {{ obj }}. Please apply that after reviewing, I am not much sure if this is correct.

(As a note, I found out that \label is always bound to the last section heading (unlike in LaTeX, where it can be positioned anywhere), and that \hypertarget does not suffer from that... Just saying, perhaps this observation is useful for someone later.)

christianp added a commit to christianp/plastex that referenced this issue Mar 12, 2024
fixes plastex#316

It looks like the template for \hyperref in the HTML5 renderer was for
the \hyperref{URL}{category}{name}{text} version, but only the
\hyperref[ref]{text} version was implemented.

This commit changes the template to use the `idref` property if it's
present, which is true for the square bracket version which links to a
ref.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant