Commit e91687e7 authored by User expired's avatar User expired
Browse files

bib-format: Escape percent signs and test it

parent 2f8a4803
Pipeline #28425 passed with stage
in 1 minute and 38 seconds
......@@ -147,6 +147,9 @@ do
# Replace utf8 characters by latex (except in abstract field).
bib-convl -i "$tmpfile" -f '/^ [Aa]bstract\|^ [Uu]rl/!'
# Escape percent signs (TeX comment, also escaped in abstract!).
sed -i '/^ [Uu]rl/!{/%/s/\([^\\]\)%/\1\\%/g}' "$tmpfile"
# Escape ampersands.
sed -i '/^ [Aa]bstract\|^ [Uu]rl/!{/&/s/\([^\\]\)&/\1\\\&/g}' "$tmpfile"
......
......@@ -248,6 +248,15 @@ testUsingUrlAsDoi() {
assertEquals ' Doi = {10.1021/acs.jpca.8b08286}' "$(cat $fileOne)"
}
testLatexEscaping() {
echo ' Anyfield = {Problematic ampersand & a 100% chance to miss the closing curly bracket.}' > $fileOne
bib-format $fileOne
assertEquals ' Anyfield = {Problematic ampersand \& a 100\% chance to miss the closing curly bracket.}' "$(cat $fileOne)"
echo ' Abstract = {Problematic ampersand & a 100% chance to miss the closing curly bracket.}' > $fileOne
bib-format $fileOne
assertEquals ' Abstract = {Problematic ampersand & a 100\% chance to miss the closing curly bracket.}' "$(cat $fileOne)"
}
testFormatStructure() {
bib-format -u $fileOne
bib-format -u $fileTwo
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment