pcooksey / bibtex-js

BibTeX-js can parse a BibTeX-file and render it as part of an HTML file. This way, you can easily add a list of publications to your private homepage or display a list of recommended publications for a seminar. The way the entries are display can be customized using a simple template system and CSS.
MIT License
270 stars 68 forks source link

Author list handling when changing author display format #53

Closed mhaeussermann closed 4 years ago

mhaeussermann commented 4 years ago

I've noticed some issues with the "bibtex_generate_author" feature. When changing the author display format from the default "First Last" to "Last, First Initial", the generated list of authors will output as "First Initial, Last,", sorting by the initial of the first name. In cases with middle names, the list outputs "First Initial, Last, Middle Name(s) Initial(s)".

pcooksey commented 4 years ago

Sorry about that. The bibtex_generate_author is still a rather new feature and hasn't seen too much usage from the public. Thanks for letting me know. I've committed a change on the develop branch that I think should fix this issue. Let me know.

mhaeussermann commented 4 years ago

Thank you for the quick response! Will test the fix as soon as possible!

mhaeussermann commented 4 years ago

I tested the fix and am happy to say that it works like a charm. There's just one small hickup I noticed with names starting with unicode characters. Last names starting with Ö, Č, Š are sorted after Z and not after O, C and S. Maybe using .localeCompare() for sorting might solve this?

pcooksey commented 4 years ago

Great! Okay, I should have a fix for this soon. I just don't have enough time before work to do all the testing and adding extra options. I'll reply back when I have it all working.

mhaeussermann commented 4 years ago

No rush! Thank you for your support and work on the project!

pcooksey commented 4 years ago

Okay, the sorting should be fixed in develop (755f03b33626e0134719de37105f0ac3923f53d7). I wanted to make sure it could be extendable so I made it fully supports the localeCompare function.

<select class="bibtex_search bibtex_generate_author"
            search="author" bibtex_sort_language="sv">
      <option value="">Search Author</option>
</select>

<select class="bibtex_search bibtex_generate_title"
            search="title" bibtex_sort_options="numeric: true">
      <option value="">Search Title</option>
</select>

bibtex_sort_language can set the language preference. bibtex_sort_options supports any option that localeCompare takes provided in a comma separated list of variable:value

Of course you don't need to set any of these extra attributes if you just want the default behavior.

mhaeussermann commented 4 years ago

I can confirm that the sorting does work as expected! Closing the issue now.