I am using Bookdown, and I would like to refer to a theorem in the middle of a mathematical derivation. The closest I have got is to use
\begin{align*}
b^2 &= c^2 -a^2 \text{ by Theorem @ref(thm:pythagoras)} \\
\end{align*}
where I have previously defined a theorem labelled pythagoras as follows
```{theorem, label="pythagoras"}
$c^2=a^2+b^2$
```
The pdf output renders as I would like:

but the HTML does not:
.
Looking at the HTML source, the problem is that MathJAX has broken due to the inclusion of a link of the form <a href=""></a>. It works if I manually remove the hyperlink, however this is not a practical solution as I have quite a lot of these in my document.
Is there a way to fix this?