Same e-mail as previously except I added two fixes to the patch.
1. > var citeKeyCleanRe = /[^a-z0-9]+/g;
2. > value =
value.replace(/{?(\\[`"'^~=a-z]){?\\?([A-Za-z])}/g, "$1{$2}");
(See explanations below.)
I will also post these explanations to the appropriate forum thread, as
suggested.
Following
http://forums.zotero.org/discussion/10337/import-fails-then-generates-duplicates/,
I suggest a patch to the BibTeX translator which fixes a few issues.
First, a test case. (Simply copy in the clipboard and import that in
zotero.)
@inProceedings{akey,
author={M. Myself},
title={The `best' method: {A} ``final'' method to prove that my method
is the very best.},
booktitle={My very best accented \'{e}xp\'er\'{\i}ments},
editor={B. Myself},
publisher={Myself Publishing Inc.},
pages={141-155},
year={1994}
}
1) Importing from BibTeX. When transforming input string containing an
encoded accented character (such as "Tsouki`as"), the character was left
as is (resulting to "Tsouki`as" instead of the expected "Tsouki�s").
(This was simply a 'g' missing from mapped = mapped.replace(/[{}]/,
"");)
2) Importing from BibTeX. One regexp change has been changed to account
for patterns like e.g. \'{\i}.
3) Importing from BibTeX. BibTeX quotes (` and ') are now transformed to
unicode English quotes.
4) Exporting to BibTeX. There was a bug when generating the citation
key: the string ` was not excluded from the key, although this character
is not allowed in a BibTeX key. While there, I also removed the other
special characters.
Someone mentioned that special characters were accepted on his system
(ubuntu). However, it is not on mine thus it does not seem fully
compatible. Plus, I don't think having apostrophes or other strange
characters in a bibtex key is really what the user wants. Finally, it
has been suggested that the whole bibtex key generation should be done
differently. I fully agree, but what I suggest is a simple change (one
line of code, and it's a simplification rather than something more
complex) in the meantime.
Also a note marked with TODO in the patch, feel free to remove it
if irrelevant: I noticed a warning in the debug logs about cleanString
being deprecated, I thought maybe you'll want to know that...
About the dollar sign used in bibtex to input mathematics: I could not
find an adequate solution, thus I did not change anything regarding
this. Currently (as before the patch) the dollar sign is imported as-is
with the mathematical formula, and when re-exported the dollars are
changed to real dollar letters in bibtex (because zotero does not know
how to distinguish from an intended dollar sign and a "begin
mathematics" markup).
One idea could be to change $blah blah$ to <math>blah blah</math> (or
other markup) so that at least when re-exported from zotero to bibtex
the inverse conversion can be done and the user can find its dollar
signs back. But it is not very clean and I didn't implement this. I
guess it's better (at least for me) to manually deal with these
mathematical expressions when needed.
Thanks.
Olivier