mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Create catalog: Fix handling of the tilde character in BiBTeX catalogs
Fixes #1832726 [Wrong ASCII conversion when writing bibtex file](https://bugs.launchpad.net/calibre/+bug/1832726)
This commit is contained in:
parent
5a4ca12432
commit
b2f299de88
@ -2558,7 +2558,7 @@ class BibTeX:
|
||||
self.invalid_cit = re.compile('[ "@\',\\#}{~%&$^]')
|
||||
self.upper = re.compile('[' +
|
||||
string.ascii_uppercase + ']')
|
||||
self.escape = re.compile('[~#&%_]')
|
||||
self.escape = re.compile('[#&%_]')
|
||||
|
||||
def ValidateCitationKey(self, text):
|
||||
"""
|
||||
@ -2584,7 +2584,8 @@ class BibTeX:
|
||||
"""
|
||||
Latex escaping some (not all) special characters
|
||||
"""
|
||||
text.replace('\\', '\\\\')
|
||||
text = text.replace('\\', '\\\\')
|
||||
text = text.replace('~', '{\\char`\\~}') # TILDE
|
||||
return self.escape.sub(lambda m: '\\%s' % m.group(), text)
|
||||
|
||||
# Calibre functions: Option to go to official ASCII Bibtex or unofficial UTF-8
|
||||
@ -2594,11 +2595,11 @@ class BibTeX:
|
||||
"""
|
||||
if len(text) == 0:
|
||||
return ''
|
||||
text.replace('\\', '\\\\')
|
||||
text = self.resolveEntities(text)
|
||||
text = self.escapeSpecialCharacters(text)
|
||||
if self.ascii_bibtex :
|
||||
text = self.resolveUnicode(text)
|
||||
return self.escapeSpecialCharacters(text)
|
||||
return text
|
||||
|
||||
def bibtex_author_format(self, item):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user