Skip to content

Commit

Permalink
Protect words with numbers and uppercase characters (zotero#2086)
Browse files Browse the repository at this point in the history
For example 3D will then become {3D} in BibTeX export.
This fixes zotero#1949 for BibTeX.
  • Loading branch information
zuphilip authored and adam3smith committed Jan 20, 2020
1 parent d77ae04 commit b80ec52
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions BibTeX.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"inRepository": true,
"translatorType": 3,
"lastUpdated": "2019-11-30 10:00:00"
"lastUpdated": "2019-12-15 20:11:00"
}

/*
Expand Down Expand Up @@ -1307,14 +1307,14 @@ function doExport() {
// Case of words with uppercase characters in non-initial positions is
// preserved with braces.
// Two extra captures because of the other regexp below
protectCapsRE = new ZU.XRegExp("()()\\b(\\p{Letter}+\\p{Uppercase_Letter}\\p{Letter}*)", 'g');
protectCapsRE = new ZU.XRegExp("()()\\b([\\p{Letter}\\d]+\\p{Uppercase_Letter}[\\p{Letter}\\d]*)", 'g');
} else {
// Protect all upper case letters, even if the uppercase letter is only in
// initial position of the word.
// Don't protect first word if only first letter is capitalized
protectCapsRE = new ZU.XRegExp(
"(.)\\b(\\p{Letter}*\\p{Uppercase_Letter}\\p{Letter}*)" // Non-initial words with capital letter anywhere
+ "|^(\\p{Letter}+\\p{Uppercase_Letter}\\p{Letter}*)" // Initial word with capital in non-initial position
"(.)\\b([\\p{Letter}\\d]*\\p{Uppercase_Letter}[\\p{Letter}\\d]*)" // Non-initial words with capital letter anywhere
+ "|^([\\p{Letter}\\d]+\\p{Uppercase_Letter}[\\p{Letter}\\d]*)" // Initial word with capital in non-initial position
, 'g');
}

Expand Down

0 comments on commit b80ec52

Please sign in to comment.