program: ## Short ship — anthology-aware version ## ───────────────────────────────────────── ## Column settings: ## Column heading : Cover ship tags ## Lookup name : short_ships ## Column type : Column built from other columns, behaves like tags ## ## Reads the saved #all_slashes list, removes repeated relationships, ## and uses the first two different ships for the cover. ## ## If an older fic has no #all_slashes value, tries #ship instead. ## Calibre may have alphabetised that older column. ## ## To add a ship, copy one elif block in the translation table. ## Relationship participant order must match the saved AO3 value. # Shows up to 2 different ships from #all_slashes. ## Read the saved ship list, remove repeats, and take the first two. ordered_unique = list_remove_duplicates(field('#all_slashes'), ','); selected = sublist(ordered_unique, 0, 2, ','); result = ''; ## ── For older fics without an #all_slashes value ────────────────── if !selected then ships_raw = field('#ship'); if contains(ships_raw, '/', '1', '') then fallback = re(ships_raw, '^(?:[^/,]+,\s*)*([^,]+/[^,]+)(?:,.*)?$', '\1'); if contains(fallback, '/', '1', '') && !contains(fallback, ',', '1', '') then selected = fallback fi fi fi; ## ── Translate each selected relationship ────────────────────────── for ship in selected separator ',': ship_value = re(ship, '^\s+|\s+$', ''); translated = ''; if contains(ship_value, '(?i)^(?:Sherlock Holmes/John Watson|John/Sherlock|Sherlock/John)$', '1', '') then translated = 'Johnlock' elif contains(ship_value, '(?i)^(?:Shane Hollander/Ilya Rozanov)$', '1', '') then translated = 'Hollanov' ## Add your ships above this line. else translated = re(ship_value, '(?i)([^/]+)/([^/]+)', '\1/\2') fi; if translated then result = list_join(', ', result, ',', translated, ',') fi rof; if !result then return 'Gen' else return result fi