Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I have a book, and I have a last name like Passerin d'Entrèves then the author is not rendered #3597

Open
mjy opened this issue Oct 18, 2023 · 7 comments

Comments

@mjy
Copy link
Member

mjy commented Oct 18, 2023

  • Updating to include a space like Passerin d' Entrèves renders the author in the book.
@typophyllum
Copy link

typophyllum commented Oct 25, 2023

Thanks. I was struggling with solving this. Nonetheless a bug, since the space is orthographically incorrect.

@kleintom
Copy link
Contributor

kleintom commented Jan 2, 2024

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):

after_save :set_cached

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.

def to_citeproc(normalize_names = true)
b = to_bibtex
::TaxonWorks::Vendor::BibtexRuby.namecase_bibtex_entry(b) if normalize_names

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.

@kleintom
Copy link
Contributor

kleintom commented Jan 2, 2024

There's already an issue in the bibtex-ruby repository for parsing this kind of name: inukshuk/bibtex-ruby#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.

@proceps
Copy link
Contributor

proceps commented Jan 2, 2024

the only way it works now if you put the name like 'Passerin d' Entrèves, Alessandro' with an extra space...

@proceps
Copy link
Contributor

proceps commented Dec 4, 2024

    def self.namecase_bibtex_entry(bibtex_entry)
      bibtex_entry.parse_names
      bibtex_entry.names.each do |n|
        n.first = NameCase(n.first) if n.first
        n.last = NameCase(n.last) if n.last
        n.prefix = NameCase(n.prefix) if n.prefix
        n.suffix = NameCase(n.suffix) if n.suffix
      end
      bibtex_entry
    end

This code fails. The first line bibtex_entry.parse_names The bibtex parser which we use does not recognize the provided format "d'Acier"

@mjy
Copy link
Member Author

mjy commented Dec 4, 2024

Yes, as @kleintom notes this falls all the way back to namae and the parser. Ideally we work with their code-bases to add the fixes, instead of hacking a work-around here.

1 similar comment
@mjy
Copy link
Member Author

mjy commented Dec 4, 2024

Yes, as @kleintom notes this falls all the way back to namae and the parser. Ideally we work with their code-bases to add the fixes, instead of hacking a work-around here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants