Merge pull request #253 from pubs/fix/252

Fix collision of entry type key with valid field name 'type'.
main
Olivier Mangin 4 years ago committed by GitHub
commit 60b424a745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,7 +7,7 @@ from .p3 import ustr, uchr
# Citekey stuff # Citekey stuff
TYPE_KEY = 'type' TYPE_KEY = 'ENTRYTYPE'
CONTROL_CHARS = ''.join(map(uchr, list(range(0, 32)) + list(range(127, 160)))) CONTROL_CHARS = ''.join(map(uchr, list(range(0, 32)) + list(range(127, 160))))
CITEKEY_FORBIDDEN_CHARS = '@\'\\,#}{~%/ ' # '/' is OK for bibtex but forbidden CITEKEY_FORBIDDEN_CHARS = '@\'\\,#}{~%/ ' # '/' is OK for bibtex but forbidden

@ -57,6 +57,12 @@ class TestEnDecode(unittest.TestCase):
self.assertEqual(bibraw1, bibraw2) self.assertEqual(bibraw1, bibraw2)
def test_decode_bibtex_preserves_type_field(self):
"""Test that multiple encode/decode step preserve data"""
decoder = endecoder.EnDecoder()
entry = decoder.decode_bibdata(bibtex_raw0)
self.assertEqual(entry['Page99']['type'], "technical report")
def test_endecode_bibtex_BOM(self): def test_endecode_bibtex_BOM(self):
"""Test that bibtexparser if fine with BOM-prefixed data""" """Test that bibtexparser if fine with BOM-prefixed data"""
decoder = endecoder.EnDecoder() decoder = endecoder.EnDecoder()

Loading…
Cancel
Save