def homogeneize_latex_encoding(record): """ Replace accents with latex equivalents. """ for val in record: if val not in ('ID',): record[val] = string_to_latex(record[val]) if val == 'title': record[val] = protect_uppercase(record[val]) return record
def homogeneize_latex_encoding(record): """ Homogeneize the latex enconding style for bibtex This function is experimental. :param record: the record. :type record: dict :returns: dict -- the modified record. """ # First, we convert everything to unicode record = convert_to_unicode(record) # And then, we fall back for val in record: record[val] = string_to_latex(record[val]) if val == 'title': record[val] = protect_uppercase(record[val]) return record
def homogenize_latex_encoding(record): """ Homogenize the latex enconding style for bibtex This function is experimental. :param record: the record. :type record: dict :returns: dict -- the modified record. """ # First, we convert everything to unicode record = convert_to_unicode(record) # And then, we fall back for val in record: if val not in ('ID', ): logger.debug('Apply string_to_latex to: %s', val) record[val] = string_to_latex(record[val]) if val == 'title': logger.debug('Protect uppercase in title') logger.debug('Before: %s', record[val]) record[val] = protect_uppercase(record[val]) logger.debug('After: %s', record[val]) return record
def homogeneize_latex_encoding(record): """ Homogeneize the latex enconding style for bibtex This function is experimental. :param record: the record. :type record: dict :returns: dict -- the modified record. """ # First, we convert everything to unicode record = convert_to_unicode(record) # And then, we fall back for val in record: if val not in ('ID',): logger.debug('Apply string_to_latex to: %s', val) record[val] = string_to_latex(record[val]) if val == 'title': logger.debug('Protect uppercase in title') logger.debug('Before: %s', record[val]) record[val] = protect_uppercase(record[val]) logger.debug('After: %s', record[val]) return record
def test_traps2(self): string = 'A}, mA}gnificient, it is a A}' result = protect_uppercase(string) expected = 'A}, mA}gnificient, it is a A}' self.assertEqual(result, expected)
def test_traps(self): string = '{A, m{Agnificient, it is a {A' result = protect_uppercase(string) expected = '{A, m{Agnificient, it is a {A' self.assertEqual(result, expected)
def test_alreadyprotected(self): string = '{A}, m{A}gnificient, it is a {A}...' result = protect_uppercase(string) expected = '{A}, m{A}gnificient, it is a {A}...' self.assertEqual(result, expected)
def test_lowercase(self): string = 'a' result = protect_uppercase(string) expected = 'a' self.assertEqual(result, expected)
def test_uppercase(self): string = 'An upPer Case A' result = protect_uppercase(string) expected = '{A}n up{P}er {C}ase {A}' self.assertEqual(result, expected)