Quote:
Originally Posted by Phssthpok
I beg to differ. It's exactly as complicated as it needs to be to do the job I want it to do. Your suggestion was inadequate for the reasons I stated above.
My solution does what I want, it's fully debugged, and I don't need any help with that. There is no need for you to be offended simply because I choose to do things a different way to you. Maybe you're OK with having authors listed under "Jr" and "II" and "(ed.), but I'm not.
|
Electing not to invest further help in somebody who is perceived as not accepting my help is not taking offense, it's just making sensible use of my time. :P When I had replied beforehand, you had not yet illustrated the problems with those names with suffices. So likewise, there is no need for you to be offended simply because I was having trouble understanding where my previous suggestion failed to meet your needs. Your explanation was exactly what I was after; I can empathize with wanting author names parsed properly by your Kobo even though I don't
yet have any Jr's or III's or similar names in my library.
If I test your proposed solution:
Code:
{author_sort:'re(list_re($, '&', '^([^,]*)(,(.*))?$', '\3 \1'),'&',', ')'}
with an author whose name is like, “Joe Schmoe, MD” and whose author_sort is set to “Schmoe, Joe, MD”, then it comes out as: “Joe, MD Schmoe”. While this looks odd I guess it will almost your needs since the last name should be detected properly.
However it will still have a spurious comma in there, which will result in splitting your authors where you don't want it to (“Joe, MD Schmoe” will result in two authors: “Joe”, and “MD Schmoe”) – and I think I can help you with this. Simply add an extra re() call to replace commas with something that looks comma-like to you but is treated differently by the software – previously I had used @ as a placeholder, but now that I do a quick search, my first suggestion is Unicode codepoint 0x2e32, “TURNED COMMA”. Here is a turned comma and then a regular comma, for the sake of comparison:
So my refinement to what you've arrived at (which I agree, seems to (very nearly!) capture your desired logic efficiently enough

) is the following:
Code:
{author_sort:'re(re(list_re($, '&', '^([^,]*)(,(.*))?$', '\3 \1'), ',', '⸲'),'&',', ')'}
For a book with authors like “Joe Schmoe, MD & Aesop” (where I have paid attention to tweak Joe's author_sort to be like “Schmoe, Joe, MD”), this template transforms them into: “Joe⸲ MD Schmoe, Aesop” (the first comma is that TURNED COMMA so your Kobo will detect this as two authors: “Joe⸲ MD Schmoe”, and “Aesop”). I've also tested the template on books with single authors and it works fine for them, as well. But I invite you to test it further, given the size of your collection. Edge cases love to sneak in.
Hope that helps more, and good luck!