View Single Post
Old 04-25-2022, 10:59 AM   #8
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,471
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
FYI: Here is a mostly equivalent template to the one in post #1, using the new list_join() function. It is much simpler. Not to say it is simple, but simpler.
Code:
program:
	globals(serial_number='N4181B5019336');

	if serial_number == 'N4181B1027108' then
		return list_join(
			':@:', 
			list_re($#cbhtags, ',', '^(.*)$', 'CBH Tags: \1'), ',', 
			list_re($authors, '&', '(^.).*', 'Authors: \1'), '&')
	fi;
	if serial_number == 'N4181B5019336' then
		return list_join(
			':@:', 
			list_re($#dthtags, ',', '^(.*)$', 'DTH Tags: \1'), ',',
			list_re($authors, '&', '(^.*)', 'Authors: \1'), '&')
	fi
On my Kobo I have collections "Author: X" where X is the first letter of the last name of the author. On my wife's device the author is fully spelled out.

The second 'if' block shows why comma can't be the separator. We both like to see authors in LN, FN format. The full author names contain commas and would be split into two collection items. Why not use the standard Kobo author list? Neither of us like that list because it isn't sorted by the first letter you see on the line. I have to scan the line for the last name to figure out where I am.

The pattern for an unmodified calibre column is:
Code:
program:
	return list_join(':@:', $column_name, ',')
To return 'tags' and 'publisher' it would be
Code:
program:
	return list_join(':@:', $tags, ',', $publisher, ',')
chaley is offline   Reply With Quote