Katex introduces errors in footnotes
pbreheny opened this issue · comments
I recently switched my book over to using Katex as the math engine by adding the following to _output.yml
:
bookdown::gitbook:
math_method: r-katex
The math looks wonderful, everything renders correctly, but it screws up the footnotes -- all footnotes now appear on the last page, as in this issue: #793.
You can reproduce this in any book (so far as I can tell), but here's an explicit example:
git clone git@github.com:rstudio/bookdown-demo.git
then add math_method: r-katex
as in the above.
Thanks for the report! I can reproduce.
We are probably not handling something correctly when detecting footnote to move when r-katex
is used.
I think our regex in
Lines 1027 to 1037 in f244cf1
does not take into account the SVG content resulting from r-katex or something else 🤔
I think the issue that with KaTeX processing we get
<a href=\"#fnref2\" class=\"footnote-back\">↩︎</a></p></li>
where without we get
<a href=\"#fnref2\" class=\"footnote-back\">↩︎</a></p></li>
Not the difference between single unicode chars and several HTML sequence characters.
So <a href="#fnref\\1" target="_blank" rel="nofollow"[^>]*?>\\X</a></p></li>
is not adapated here. Maybe using \\X+
is enough, or we need something more tailored to what we want to match.
@yihui hope it helps do the right thing. Thanks!
Works for me! 🎉