pubs / pubs

Your bibliography on the command line
GNU Lesser General Public License v3.0
271 stars 32 forks source link

Problems with latex to unicode #188

Open benureau opened 5 years ago

benureau commented 5 years ago

@omangin: That was fast. This bibtex fails to be listed:

@incollection{Smith2019,
 author = {Smith, John},
 title = {A Title},
 editor = {Smith, John},
}

This is due to the editor field. Remove it (even in a much more complex bibtex entry), and that works.

 § pubs add smith2019.bib
error: 'dict' object has no attribute 'replace'
Traceback (most recent call last):
  File "/Users/self/.venvs/pubsenv/bin/pubs", line 11, in <module>
    load_entry_point('pubs', 'console_scripts', 'pubs')()
  File "/Users/self/Volumes/ResearchSync/projects/pubs/pubs/pubs_cmd.py", line 103, in execute
    if not uis.get_ui().handle_exception(e):
  File "/Users/self/Volumes/ResearchSync/projects/pubs/pubs/pubs_cmd.py", line 100, in execute
    args.func(conf, args)
  File "/Users/self/Volumes/ResearchSync/projects/pubs/pubs/commands/add_cmd.py", line 150, in command
    ui.message('added to pubs:\n{}'.format(pretty.paper_oneliner(p)))
  File "/Users/self/Volumes/ResearchSync/projects/pubs/pubs/pretty.py", line 67, in paper_oneliner
    bibdesc = bib_oneliner(p.get_unicode_bibdata())
  File "/Users/self/Volumes/ResearchSync/projects/pubs/pubs/paper.py", line 109, in get_unicode_bibdata
    return convert_to_unicode(self.bibdata)
  File "/Users/self/.venvs/pubsenv/lib/python3.7/site-packages/bibtexparser/customization.py", line 501, in convert_to_unicode
    latex_to_unicode(x) for x in record[val]
  File "/Users/self/.venvs/pubsenv/lib/python3.7/site-packages/bibtexparser/customization.py", line 501, in <listcomp>
    latex_to_unicode(x) for x in record[val]
  File "/Users/self/.venvs/pubsenv/lib/python3.7/site-packages/bibtexparser/latexenc.py", line 72, in latex_to_unicode
    string = string.replace("{", "").replace("}", "")
AttributeError: 'dict' object has no attribute 'replace'
omangin commented 5 years ago

Indeed. I was already looking at this. The issue is that the editor customization from bibtexparser is not consistent to the author one and not compatible with the latex_to_unicode. That makes this fail as soon as there is an editor in a paper, which is unfortunately not in the test usecases.

omangin commented 5 years ago

As a quickfix we can do something like the following in the endecoder:

bibdata["editor"] = [["name"] e in bibdata["editor"]]

I will report that to bibtexparser and we can add the above as a temporary fix.

benureau commented 5 years ago

Ok. If you want to add a quickfix to master, do it. I can't work on this this immediate moment.

omangin commented 5 years ago

OK

omangin commented 5 years ago

See https://github.com/sciunto-org/python-bibtexparser/issues/229 for the upstream issue.