Does this produce the right answer? I added the show and ao3tags_pair variables so I could run the template.
Code:
program:
show = $#show
# show = 'ABC, JKL, GHI';
show1 = '^ABC$' inlist show && '^GHI$' inlist show;
show2 = '^DEF$' inlist show && '^GHI$' inlist show;
show3 = '^ABC$' inlist show && '^JKL$' inlist show;
output = '';
ao3tags_pair = $#ao3tags_pair
# ao3tags_pair = 'Alex / Liv, Jo / Maggy, JoJo';
for item in ao3tags_pair:
ni = '';
if show1 then
if item == "Alex / Liv" then
ni = "Alexandra / Olivia"
fi
fi;
if show2 then
if item == "Alex / Liv" then
ni = "Alexander / Olivia"
fi
fi;
if show3 then
if item == "Jo / Maggy" then
ni = "Josefine / Maggie"
elif item == "JoJo" then
ni = "Josefine / Joe"
fi
fi;
if ni then
output = output & ',' & ni
else
output = output & ',' & item
fi
rof;
output = list_sort(list_remove_duplicates(output, ','), 0, ',')