04-01-2025, 01:07 PM
|
#827
|
Connoisseur
Posts: 66
Karma: 10
Join Date: Nov 2023
Device: Kindle Oasis
|
Quote:
Originally Posted by chaley
I think this does what you want. To make a valid hierarchical item, in authors it replaces periods and commas, and in series it replaces periods. If you have commas in series names then you must replace those as well.
Code:
program:
def first_letter(x):
return strcat('[', substr(x, 0, 1), ']')
fed;
# Replace periods with unicode "One Dot Leader" (․)
period = '․';
# Replace commas with unicode "Small Comma" (﹐)
comma = '﹐';
if $series then
series = strcat('.', first_letter($series), '.', re($series, '\.', period))
else
series = '.Standalone'
fi;
sep = '';
result = '';
for aut in 'authors':
result = strcat(result, sep, first_letter(aut), '.', re(re(aut, '\.', period), ',', comma), series);
sep = ','
rof;
result
|
 
|
|
|