View Single Post
Old 12-27-2020, 05:29 PM   #12
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,452
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Here's what I wanted to do:

Tags: Fiction.Cultures & Regions.Canada, Fiction.Social issues.Prejudice and Racism
Results: Fiction, Canada, Prejudice and Racism

Unfortunately the template instead gave me Fiction, Cultures & Regions, Social Issues.
TBH this is approaching absurd. Why don't you set up your tags the way you want instead of using all this automation to mess with it? That way you control what you have without all the fuss.

The above notwithstanding, this might do what you want.
Code:
program:
	g = field('#genre');
	stripped_hierarchies = list_re_group(g, ',', '.',
			'^(Fanfiction|Documentation and Manuals)($|\..*$)',
			'{$}', '');
	split_hierarchies = re(stripped_hierarchies, '\.', ',');
	split_hierarchies = list_difference(
			split_hierarchies,
			'Cultures & Regions, Social Issues',
			',');
	cleaned = list_union('', split_hierarchies, ',');
	sorted = list_sort(cleaned, 0, ',')

Last edited by chaley; 12-27-2020 at 05:33 PM.
chaley is offline   Reply With Quote