Skip to content

Commit

Permalink
fix #1470: the footnote backreference character is not a single chara…
Browse files Browse the repository at this point in the history
…cter when katex is used for math, so instead of matching \X, we match a series of characters that are not <
  • Loading branch information
yihui committed Jun 19, 2024
1 parent f244cf1 commit 716c4cc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: bookdown
Type: Package
Title: Authoring Books and Technical Documents with R Markdown
Version: 0.39.1
Version: 0.39.2
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Christophe", "Dervieux", , "[email protected]", role = c("ctb"),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CHANGES IN bookdown VERSION 0.40

- Footnotes are not rendered correctly when `katex` is used to render LaTeX math expressions (thanks, @pbreheny, #1470).

# CHANGES IN bookdown VERSION 0.39

Expand Down
2 changes: 1 addition & 1 deletion R/html.R
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ parse_footnotes = function(x) {
j = which(x == '</div>')
j = min(j[j > i])
n = length(x)
r = '<li id="fn([0-9]+)"><p>(?s).+?<a href="#fnref\\1"[^>]*?>\\X</a></p></li>'
r = '<li id="fn([0-9]+)"><p>(?s).+?<a href="#fnref\\1"[^>]*?>[^<]+</a></p></li>'
s = paste(x[i:n], collapse = '\n')
items = unlist(regmatches(s, gregexpr(r, s, perl = TRUE)))
list(items = setNames(items, gsub(r, 'fn\\1', items, perl = TRUE)), range = i:j)
Expand Down

0 comments on commit 716c4cc

Please sign in to comment.