Skip to content

Commit 4c8228f

Browse files
rault-afavna
andauthored
refactor: make regexp for flavor text updater more generic (#1014)
[skip publish] --------- Co-authored-by: Jeroen Claassens <[email protected]>
1 parent 19ae3ce commit 4c8228f

File tree

1 file changed

+7
-61
lines changed

1 file changed

+7
-61
lines changed

scripts/data-gen-scripts/scripted-updaters/flavor-text-updater/get-text-content.ts

Lines changed: 7 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -23,74 +23,21 @@ export function getTextContent(bit1: string) {
2323
.replace(/'''Version 1\.0:''' .+1.2:''' (.+)/, '$1')
2424
.replace(/'''Version 1\.0:''' .+1\.1:''' (.+)/, '$1')
2525
.replace(/'''Version 1\.0:''' .+1\.2:''' (.+)/, '$1')
26-
.replaceAll('{{tt|*|Pokédex entry only found in Pokémon HOME.}}', '')
27-
.replaceAll('{{tt|*|Pokédex entry only found in Pokémon HOME}}', '')
28-
.replaceAll('{{tt|*|In Ver 1.0, Tyranitar uses its entry from LeafGreen}}', '')
29-
.replaceAll('{{tt|*|Used for both genders in-game}}', '')
26+
.replaceAll(/\{\{tt\|\*\|(?:[\p{Letter}\d\p{Punctuation}\s]+?)\}\}/gu, '')
3027
.replaceAll('}}\t', '')
3128
.replaceAll('’', "'")
3229
.replaceAll('−', '-')
3330
.replaceAll('“', '"')
3431
.replaceAll('”', '"')
3532
.replaceAll(' <!--error in game--> ', ' ')
3633
.replaceAll('<!-- period is missing -->', '.')
37-
.replaceAll(`{{tt|–75<!--U+2013 EN DASH in-game--> degrees Fahrenheit|−60 degrees Celsius}}`, '-75 degrees Fahrenheit')
38-
.replaceAll(`{{tt|–75<!--U+2013 EN DASH in-game--> degrees Fahrenheit|-60 degrees Celsius}}`, '-75 degrees Fahrenheit')
39-
.replaceAll(`{{tt|–58<!--U+2013 EN DASH in-game--> degrees Fahrenheit|−50 degrees Celsius}}`, '-58 degrees Fahrenheit')
40-
.replaceAll(`{{tt|–58<!--U+2013 EN DASH in-game--> degrees Fahrenheit|-50 degrees Celsius}}`, '-58 degrees Fahrenheit')
41-
.replaceAll(`{{tt|–240<!--U+2013 EN DASH in-game--> degrees Fahrenheit|−150 degrees Celsius}}`, '-240 degrees Fahrenheit')
42-
.replaceAll(`{{tt|–240<!--U+2013 EN DASH in-game--> degrees Fahrenheit|-150 degrees Celsius}}`, '-240 degrees Fahrenheit')
34+
.replaceAll(/\{\{tt\|(\d+)<!--U\+2013 EN DASH in-game--> degrees Fahrenheit\|(?:-|)\d+ degrees Celsius\}\}/g, '-$1 degrees Fahrenheit')
4335
.replaceAll(`{{tt|this|''the'' in Ruby v1.0}}`, 'this')
4436
.replaceAll(`{{tt|Bug/Grass Pokémon|''BUG POKéMON'' in R/S v1.0}}`, 'Bug/Grass Pokémon')
45-
.replaceAll('{{tt|*|Unused entry}}', '')
46-
.replaceAll('[[alien]]', 'alien')
47-
.replaceAll('[[Alola]]', 'Alola')
48-
.replaceAll('[[Apricorn]]', 'Apricorn')
49-
.replaceAll('[[Berry|Berries]]', 'Berries')
50-
.replaceAll('[[Black Augurite|extremely rare ore]]', 'extremely rare ore')
51-
.replaceAll('[[Diamond Domain|kingdom of jewels]]', 'kingdom of jewels')
52-
.replaceAll('[[Distortion World|world]]', 'world')
53-
.replaceAll('[[Double Slap (move)|DoubleSlap]]', 'DoubleSlap')
54-
.replaceAll('[[Dynamax]]', 'Dynamax')
55-
.replaceAll('[[evolution]]', 'evolution')
56-
.replaceAll('[[Evolution|becomes]]', 'becomes')
57-
.replaceAll('[[Evolution|evolve]]', 'evolve')
58-
.replaceAll('[[Evolution|evolved]]', 'evolved')
59-
.replaceAll('[[Galar]]', 'Galar')
60-
.replaceAll('[[Galar|homeland]]', 'homeland')
61-
.replaceAll('[[Gladion|boy]]', 'boy')
62-
.replaceAll('[[Gladion|the boy who evolved it into this form]]', 'the boy who evolved it into this form')
63-
.replaceAll('[[Hisui]]', 'Hisui')
64-
.replaceAll('[[Hisui|much harsher environments]]', 'much harsher environments')
65-
.replaceAll('[[Kitakami|a new land]]', 'a new land')
66-
.replaceAll('[[legendary Pokémon]]', 'legendary Pokémon')
67-
.replaceAll('[[Mega Evolution|a phenomenon that occurs in a certain region]]', 'a phenomenon that occurs in a certain region')
68-
.replaceAll('[[Moon Stone|moon stone]]', 'moon stone')
69-
.replaceAll('[[move]]', 'move')
70-
.replaceAll('[[Mr. Fuji|a certain scientist]]', 'a certain scientist')
71-
.replaceAll('[[Old Amber|amber]]', 'amber')
72-
.replaceAll('[[Paldea]]', 'Paldea')
73-
.replaceAll('[[Poké Ball]]', 'Poké Ball')
74-
.replaceAll('[[Pokégear]]', 'Pokégear')
75-
.replaceAll('[[Pokégear|Pokégear]]', 'Pokégear')
76-
.replaceAll('[[Pokégear|é<sc>gear</sc>]]', 'Pokégear')
77-
.replaceAll('[[Pokégear|Poké<sc>gear</sc>]]', 'Pokégear')
78-
.replaceAll('[[Pokémon Trainer|Trainer]]', 'Trainer')
79-
.replaceAll('[[Pokémon world|ours]]', 'ours')
80-
.replaceAll('[[Professor Laventon|my]]', 'my')
81-
.replaceAll('[[Pupitar (Pokémon)|a pupa]]', 'a pupa')
82-
.replaceAll('[[region]]', 'region')
83-
.replaceAll('[[regional form]]', 'regional form')
84-
.replaceAll('[[Scarlet Book|an expedition journal]]', 'an expedition journal')
85-
.replaceAll('[[Scarlet Book|old expedition journal]]', 'old expedition journal.')
86-
.replaceAll('[[Sinnoh myths|mythology]]', 'mythology')
87-
.replaceAll('[[Sinnoh myths|myths]]', 'myths')
88-
.replaceAll('[[Sinnoh]]', 'Sinnoh')
89-
.replaceAll('[[Time travel|travel at will through the past and future]]', 'travel at will through the past and future')
90-
.replaceAll('[[type]]', 'type')
91-
.replaceAll('[[Ultra Beast]]', 'Ultra Beast')
92-
.replaceAll('[[Violet Book|certain expedition journal.]]', 'certain expedition journal.')
93-
.replaceAll('[[Violet Book|old book]]', 'old book')
37+
.replaceAll(
38+
/(?:\[\[(?<pokegearContent>Pokégear)(?:\|[\p{Letter}\p{Other_Punctuation}\s()<>]+)?\]\])|(?:\[\[(?:[\p{Letter}\p{Other_Punctuation}\s()<>]+\|)?(?<generalContent>[\p{Letter}\p{Other_Punctuation}\s()<>]+)\]\])/gu,
39+
'$<pokegearContent>$<generalContent>'
40+
)
9441
.replaceAll('{{OBP|Pokémon|species}}', 'Pokémon')
9542
.replaceAll('{{p|Type: Null}}', 'Type: Null')
9643
.replaceAll('{{ScBall}}', 'Poké Ball')
@@ -99,6 +46,5 @@ export function getTextContent(bit1: string) {
9946
.replaceAll('lower-back{{sup/4|HG}}/lower back{{sup/4|SS}}', 'lower-back')
10047
.replaceAll('the{{sup/3|R}}/this{{sup/3|S}}', 'this')
10148
.replaceAll('a <!--typo exists in-game--> ', '')
102-
.replaceAll('<sc>Berries</sc>', 'Berries')
103-
.replaceAll("[[Dimension#Palkia's world|spatial dimension]]", 'spatial dimension');
49+
.replaceAll('<sc>Berries</sc>', 'Berries');
10450
}

0 commit comments

Comments
 (0)