Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make regexp for flavor text updater more generic #1014

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,74 +23,21 @@ export function getTextContent(bit1: string) {
.replace(/'''Version 1\.0:''' .+1.2:''' (.+)/, '$1')
.replace(/'''Version 1\.0:''' .+1\.1:''' (.+)/, '$1')
.replace(/'''Version 1\.0:''' .+1\.2:''' (.+)/, '$1')
.replaceAll('{{tt|*|Pokédex entry only found in Pokémon HOME.}}', '')
.replaceAll('{{tt|*|Pokédex entry only found in Pokémon HOME}}', '')
.replaceAll('{{tt|*|In Ver 1.0, Tyranitar uses its entry from LeafGreen}}', '')
.replaceAll('{{tt|*|Used for both genders in-game}}', '')
.replaceAll(/\{\{tt\|\*\|(?:[\p{Letter}\d\p{Punctuation}\s]+?)\}\}/gu, '')
.replaceAll('}}\t', '')
.replaceAll('’', "'")
.replaceAll('−', '-')
.replaceAll('“', '"')
.replaceAll('”', '"')
.replaceAll(' <!--error in game--> ', ' ')
.replaceAll('<!-- period is missing -->', '.')
.replaceAll(`{{tt|–75<!--U+2013 EN DASH in-game--> degrees Fahrenheit|−60 degrees Celsius}}`, '-75 degrees Fahrenheit')
.replaceAll(`{{tt|–75<!--U+2013 EN DASH in-game--> degrees Fahrenheit|-60 degrees Celsius}}`, '-75 degrees Fahrenheit')
.replaceAll(`{{tt|–58<!--U+2013 EN DASH in-game--> degrees Fahrenheit|−50 degrees Celsius}}`, '-58 degrees Fahrenheit')
.replaceAll(`{{tt|–58<!--U+2013 EN DASH in-game--> degrees Fahrenheit|-50 degrees Celsius}}`, '-58 degrees Fahrenheit')
.replaceAll(`{{tt|–240<!--U+2013 EN DASH in-game--> degrees Fahrenheit|−150 degrees Celsius}}`, '-240 degrees Fahrenheit')
.replaceAll(`{{tt|–240<!--U+2013 EN DASH in-game--> degrees Fahrenheit|-150 degrees Celsius}}`, '-240 degrees Fahrenheit')
.replaceAll(/\{\{tt\|–(\d+)<!--U\+2013 EN DASH in-game--> degrees Fahrenheit\|(?:-|−)\d+ degrees Celsius\}\}/g, '-$1 degrees Fahrenheit')
.replaceAll(`{{tt|this|''the'' in Ruby v1.0}}`, 'this')
.replaceAll(`{{tt|Bug/Grass Pokémon|''BUG POKéMON'' in R/S v1.0}}`, 'Bug/Grass Pokémon')
.replaceAll('{{tt|*|Unused entry}}', '')
.replaceAll('[[alien]]', 'alien')
.replaceAll('[[Alola]]', 'Alola')
.replaceAll('[[Apricorn]]', 'Apricorn')
.replaceAll('[[Berry|Berries]]', 'Berries')
.replaceAll('[[Black Augurite|extremely rare ore]]', 'extremely rare ore')
.replaceAll('[[Diamond Domain|kingdom of jewels]]', 'kingdom of jewels')
.replaceAll('[[Distortion World|world]]', 'world')
.replaceAll('[[Double Slap (move)|DoubleSlap]]', 'DoubleSlap')
.replaceAll('[[Dynamax]]', 'Dynamax')
.replaceAll('[[evolution]]', 'evolution')
.replaceAll('[[Evolution|becomes]]', 'becomes')
.replaceAll('[[Evolution|evolve]]', 'evolve')
.replaceAll('[[Evolution|evolved]]', 'evolved')
.replaceAll('[[Galar]]', 'Galar')
.replaceAll('[[Galar|homeland]]', 'homeland')
.replaceAll('[[Gladion|boy]]', 'boy')
.replaceAll('[[Gladion|the boy who evolved it into this form]]', 'the boy who evolved it into this form')
.replaceAll('[[Hisui]]', 'Hisui')
.replaceAll('[[Hisui|much harsher environments]]', 'much harsher environments')
.replaceAll('[[Kitakami|a new land]]', 'a new land')
.replaceAll('[[legendary Pokémon]]', 'legendary Pokémon')
.replaceAll('[[Mega Evolution|a phenomenon that occurs in a certain region]]', 'a phenomenon that occurs in a certain region')
.replaceAll('[[Moon Stone|moon stone]]', 'moon stone')
.replaceAll('[[move]]', 'move')
.replaceAll('[[Mr. Fuji|a certain scientist]]', 'a certain scientist')
.replaceAll('[[Old Amber|amber]]', 'amber')
.replaceAll('[[Paldea]]', 'Paldea')
.replaceAll('[[Poké Ball]]', 'Poké Ball')
.replaceAll('[[Pokégear]]', 'Pokégear')
.replaceAll('[[Pokégear|Pokégear]]', 'Pokégear')
.replaceAll('[[Pokégear|é<sc>gear</sc>]]', 'Pokégear')
.replaceAll('[[Pokégear|Poké<sc>gear</sc>]]', 'Pokégear')
.replaceAll('[[Pokémon Trainer|Trainer]]', 'Trainer')
.replaceAll('[[Pokémon world|ours]]', 'ours')
.replaceAll('[[Professor Laventon|my]]', 'my')
.replaceAll('[[Pupitar (Pokémon)|a pupa]]', 'a pupa')
.replaceAll('[[region]]', 'region')
.replaceAll('[[regional form]]', 'regional form')
.replaceAll('[[Scarlet Book|an expedition journal]]', 'an expedition journal')
.replaceAll('[[Scarlet Book|old expedition journal]]', 'old expedition journal.')
.replaceAll('[[Sinnoh myths|mythology]]', 'mythology')
.replaceAll('[[Sinnoh myths|myths]]', 'myths')
.replaceAll('[[Sinnoh]]', 'Sinnoh')
.replaceAll('[[Time travel|travel at will through the past and future]]', 'travel at will through the past and future')
.replaceAll('[[type]]', 'type')
.replaceAll('[[Ultra Beast]]', 'Ultra Beast')
.replaceAll('[[Violet Book|certain expedition journal.]]', 'certain expedition journal.')
.replaceAll('[[Violet Book|old book]]', 'old book')
.replaceAll(
/(?:\[\[(?<pokegearContent>Pokégear)(?:\|[\p{Letter}\p{Other_Punctuation}\s()<>]+)?\]\])|(?:\[\[(?:[\p{Letter}\p{Other_Punctuation}\s()<>]+\|)?(?<generalContent>[\p{Letter}\p{Other_Punctuation}\s()<>]+)\]\])/gu,
'$<pokegearContent>$<generalContent>'
)
.replaceAll('{{OBP|Pokémon|species}}', 'Pokémon')
.replaceAll('{{p|Type: Null}}', 'Type: Null')
.replaceAll('{{ScBall}}', 'Poké Ball')
Expand All @@ -99,6 +46,5 @@ export function getTextContent(bit1: string) {
.replaceAll('lower-back{{sup/4|HG}}/lower back{{sup/4|SS}}', 'lower-back')
.replaceAll('the{{sup/3|R}}/this{{sup/3|S}}', 'this')
.replaceAll('a <!--typo exists in-game--> ', '')
.replaceAll('<sc>Berries</sc>', 'Berries')
.replaceAll("[[Dimension#Palkia's world|spatial dimension]]", 'spatial dimension');
.replaceAll('<sc>Berries</sc>', 'Berries');
}
Loading