taxonworks
taxonworks copied to clipboard
When I have a book, and I have a last name like `Passerin d'Entrèves` then the author is not rendered
- Updating to include a space like
Passerin d' Entrèves
renders the author in the book.
Thanks. I was struggling with solving this. Nonetheless a bug, since the space is orthographically incorrect.
I'm new to this so take it all with a grain of salt, but this is what I'm seeing - corrections welcome!
For a new user like me: I see the missing name in the list of sources in the Source Hub task, and also in the New Source task you get to by clicking on a source in the Source Hub list.
Both of those source descriptions with the missing author are being pulled from the cached
field of the corresponding row of the Sources table. The cached field gets set by a call to set_cached
when the source gets saved (by clicking Save in the New Source task for example): https://github.com/SpeciesFileGroup/taxonworks/blob/190d33aba7659b368eaeabf438f047be58aaffee/app/models/source.rb#L224
set_cached
for a book is defined in models/source/bibtex.rb - it calls get_cached
, which calls cached_string
, which calls render_with_style
.
render_with_style
calls to_citeproc
, which calls ::TaxonWorks::Vendor::BibtexRuby.namecase_bibtex_entry
since the default parameter normalize_names
is true.
https://github.com/SpeciesFileGroup/taxonworks/blob/190d33aba7659b368eaeabf438f047be58aaffee/app/models/source/bibtex.rb#L802-L804
namecase_bibtex_entry
calls parse_names
from the bibtex-ruby gem, and that's where the author name "Passerin d'Entrèves, Alessandro" fails to parse. At that point the author of the BibTeX::Entry object that was passed into parse is set to the empty string; that empty author gets passed back up the call chain and cached
gets set without an author.
There's already an issue in the bibtex-ruby repository for parsing this kind of name: https://github.com/inukshuk/bibtex-ruby/issues/149 You can test in irb:
irb(main):001> require 'bibtex'
=> true
irb(main):002> book = BibTeX::Entry.new
=> #<BibTeX::Entry >
irb(main):003> book.author = "Passerin d'Entrèves, Alessandro"
=> "Passerin d'Entrèves, Alessandro"
irb(main):004> book.parse_names
=> #<BibTeX::Entry author = >
irb(main):005> book.author = "Passerin Entrèves, Alessandro" # Remove the "d'"
=> "Passerin Entrèves, Alessandro"
irb(main):006> book.parse_names
=> #<BibTeX::Entry author = Passerin Entrèves, Alessandro> # That name was parsed
irb(main):008> book.author = "Passerin d'Entrèves En, Alessandro" # A third capitalized family name works too
=> "Passerin d'Entrèves En, Alessandro"
irb(main):009> book.parse_names
=> #<BibTeX::Entry author = Passerin d'Entrèves En, Alessandro>
I tried the namae package as inukshuk suggested and had the same issue, "Passerin d'Entrèves, Alessandro" fails to parse.
the only way it works now if you put the name like 'Passerin d' Entrèves, Alessandro' with an extra space...