Bug: tilde in "\~" is parsed as space

Issue #64 resolved
Former user created an issue

There seems to be a bug in pybtex/bibtex/utils.py in split_tex_string(), where a name such as 'Brand\~{a}o' gets incorrectly split because of the ~ character. Here, the ~ is part of the escape sequence \~ and is not a space.

I'm using pybtex to parse bibtex files (and it's really useful, thanks!). Here's an example of erroneous behavior:

>>> from pybtex.database import Person
>>> Person('Brand\~ao, F')
Person(u'Brand\\ ao, F')

I'm proposing a patch which fixes this (attached).

Comments (2)

  1. Andrey Golovizin

    Turns out it's more complicated than that. :)

    BibTeX does split the name at \~ and counts both parts of 'Brand\~{a}o' as last names:

    >>> from pybtex.tests import run_bibtex
    >>> p = run_bibtex.parse_name(r'Brand\~{a}o, F')
    >>> print p.first(), p.middle(), p.prelast(), p.last()
    >>> ['F'] [] [] ['Brand\\', '{a}o']
    

    Then it joins them back again with ~ when outputting the .bbl file, so the output looks OK.

    Pybtex currently thinks that 'Brand\' is a von name:

    >>> from pybtex.tests import run_bibtex
    >>> p = Person(r'Brand\~{a}o, F')
    >>> print p.first(), p.middle(), p.prelast(), p.last()
    >>> ['F'] [] ['Brand\\'] ['{a}o']
    
  2. Log in to comment