View Single Post
Old 10-28-2023, 07:24 AM   #5
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by AstroCalibre View Post
theduck, thanks for your ansewer!
I hoped that it could be done without changing the ordering of the authors (I want to leave it in the form "Asimov, Isaac"), by modifying, for example, the template in Generate cover.
This footer template works for me
Code:
program:
# Show at most two authors, on separate lines.
authors = '';
for aut in sublist($authors, 0, 2, ' & ') separator '&':
	aut = swap_around_comma(aut);
	authors = list_join(' & ', authors, ' & ', aut, ' & ')
rof;
authors = list_re(authors, ' &amp; ', '(.+)', '<b>\1');
authors = re(authors, ' &amp; ', '<br>');
re(authors, '&amp;&amp;', '&amp;')
Quote:
Alternatively, I tried to do this: I created a custom column (#myauthors) and manually inserted the authors' names into it in the form that I want (e.g. Isaac Asimov & Arthur Clarke). Then I edit the template in Generate cover replacing the word "authors" with "#myauthors". It works but I was wondering if it is possible to create a custom column that generates automatically the names of the authors, without comma between surname and name, with surname and name inverted, and separated by an ampersand.
Do what the above template does to generate the author list in the custom column. Something like this:
Code:
program:
authors = '';
for aut in $authors separator '&':
	aut = swap_around_comma(aut);
	authors = list_join(' & ', authors, ' & ', aut, ' & ')
rof;
authors
EDIT: Here are simpler versions of the above templates that use list_re_group() instead of a for loop.

Cover template:
Code:
program:
# Show at most two authors, on separate lines.
authors = list_re_group($authors, ' &amp; ', '.', '(.*)', 'program: swap_around_comma($)');
num = count(authors, ' &amp; ');
authors = sublist(authors, 0, 2, ' &amp; ');
authors = list_re(authors, ' &amp; ', '(.+)', '<b>\1');
authors = re(authors, ' &amp; ', '<br>');
re(authors, '&amp;&amp;', '&amp;')
Custom column template:
Code:
program:
list_re_group($authors, ' & ', '.', '(.*)', 'program: swap_around_comma($)')

Last edited by chaley; 10-28-2023 at 11:31 AM. Reason: Added simpler templates
chaley is offline   Reply With Quote