Skip to content

Commit

Permalink
MOS:PHIL compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed Jun 8, 2024
1 parent cab6c76 commit 1371dca
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/PagasaParserWikipediaFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,26 @@ export default class PagasaParserWikipediaFormatter extends PagasaParserFormatte
if (redirects[a1] == a2)
return `[[${a2}]]`;

return `[[${redirects[a1]}|${a2 ?? a1}]]`;
let name = a2 ?? a1;

// MOS:PHIL; https://w.wiki/AKWS
// If the title includes "city", use the page name as the title,
// removing disambiguators. This will automatically convert:
// * "Baguio City" to "Baguio"
// * "Science City of Muñoz" to "Muñoz"
// * "Isabela, Basilan" to "Isabela"
// This should exclude titles like:
// * Quezon City
// * Angeles City
// This should never change the redirect target.
if ( /\bcity\b/gi.test(name) ) {
name = redirects[a1].replace(
/^.*City of|(,.+)|(\s\([^)]+\)+)/g,
""
);
}

return `[[${redirects[a1]}|${name}]]`;
});

return wikitext;
Expand Down

0 comments on commit 1371dca

Please sign in to comment.