yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.36k stars 873 forks source link

feat(write_bib): escape & as much as possible (closes #2335) #2342

Closed atusy closed 2 months ago

atusy commented 2 months ago

In write_bib, apply gsub('(?<!\\\\)&', '\\\\&', x, perl = TRUE) to escape unespcaped ampersands.

Note that released implementation partially applies the escape. Instead, I apply the escape as later as possible so that the escape happens widely.