chirun-ncl / chirun

A Python package providing the command line interface for building flexible and accessible content with Chirun.
https://chirun.org.uk/
Other
29 stars 4 forks source link

In-page links from LaTeX hyperref no longer working #228

Closed prowlett closed 2 months ago

prowlett commented 3 months ago

I have some code like this to do an in-page link iff we're on the web version of this page.

\documentclass{article}
\usepackage{chirun}
\usepackage{hyperref}

\begin{document}
You will need \ifplastex\hyperref[datasets]{a data set}\else a data set (available on the module notes site)\fi

...

\ifplastex
\section*{Data sets}\label{datasets}

...

\fi

\end{document}

It produces HTML like this:

<article class="item-content" id="item-content">
        <p>
 You will need <a href="[#.](view-source:file:///home/.../index.html#.)">a data set</a>
</p>
<p>
... 
</p>
<section class="section">
<h2 id="a0000000002">Data sets</h2>
<p>
... 
</p>
</section>
<script id="plastex-labels" type="application/json">{}</script>
    </article>

The problem is that the heading 'Data sets' is not given the label 'datasets' and the link, instead of going to #datasets it spits out some Markdown into the href attribute.

Last year, chirun produced an id="datasets" at the \label and did this for the \ref:

<p>
To answer these questions, you will need <a href="../../case_study_informati/portfolio_activity_4/index.html#datasets">a data set</a>. 
</p>
christianp commented 3 months ago

I get the same thing with standard plasTeX, so I think this broke there. I'll see if I can work out a fix.

christianp commented 3 months ago

It looks like the problem is only in the HTML5 renderer: the XHTML renderer makes the link properly. So I'm confident this can be fixed.

christianp commented 3 months ago

OK, I've made a PR to plasTeX: https://github.com/plastex/plastex/pull/363.

Until that's accepted, there's one bit which we could take into Chirun as an override, but there's another bug to do with labelling non-numbered sections which is in the core of plasTeX.

christianp commented 2 months ago

I've switched Chirun to require my forked branch of plasTeX because I've been through moving our overrides out of Chirun and now have 16 open PRs in the plasTeX repository! So I'm going to close this, because Chirun is using the fix.