@massimo-cassandro/minimo 1.40.2 → 1.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -0
- package/package.json +1 -1
- package/src/utilities/better-text-with-places.js +509 -0
- package/src/utilities/better-text.js +12 -1
package/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
|
|
1
2
|
// utilities
|
|
2
3
|
export { betterText } from './src/utilities/better-text.js';
|
|
4
|
+
export { betterTextWithPlaces } from './src/utilities/better-text-with-places.js';
|
|
3
5
|
export { classnames, classnamesNull } from './src/utilities/classnames.js';
|
|
4
6
|
export { createId } from './src/utilities/create-id.js';
|
|
5
7
|
export { disableBtnsOnSubmit } from './src/utilities/disable-btns-on-submit.js';
|
package/package.json
CHANGED
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/*! minimo - Better Text with places */
|
|
3
|
+
|
|
4
|
+
import { betterText, NBSP_AFTER_PARTICLE_REGEX } from './better-text.js';
|
|
5
|
+
|
|
6
|
+
const places = [
|
|
7
|
+
// EUROPA
|
|
8
|
+
'Europa',
|
|
9
|
+
|
|
10
|
+
'Italia', 'Roma',
|
|
11
|
+
// città
|
|
12
|
+
'Milano', 'Napoli', 'Torino', 'Palermo', 'Bologna', 'Firenze', 'Venezia', 'Genova', 'Bari', 'Catania',
|
|
13
|
+
'Verona', 'Padova', 'Trieste', 'Pisa', 'Siena', 'Cagliari', 'Parma', 'Modena', 'Bergamo', 'Brescia',
|
|
14
|
+
'Trento', 'Bolzano', 'Aosta', 'Perugia', 'Assisi', 'Ancona', 'Rimini', 'Ravenna', 'Lucca', 'Matera',
|
|
15
|
+
'Taranto', 'Siracusa', 'Messina', 'Lecce', 'Cuneo',
|
|
16
|
+
// regioni
|
|
17
|
+
'Sicilia', 'Sardegna', 'Toscana', 'Lombardia', 'Piemonte', 'Veneto', 'Puglia', 'Calabria', 'Umbria',
|
|
18
|
+
'Lazio', 'Campania', 'Liguria', 'Abruzzo', 'Friuli-Venezia Giulia', 'Trentino-Alto Adige',
|
|
19
|
+
'Emilia-Romagna', 'Basilicata', 'Molise', 'Valle d’Aosta',
|
|
20
|
+
// fiumi
|
|
21
|
+
'Po', 'Adige', 'Tevere', 'Arno',
|
|
22
|
+
// monti
|
|
23
|
+
'Monte Bianco', 'Monte Rosa', 'Cervino', 'Etna', 'Vesuvio', 'Gran Sasso',
|
|
24
|
+
// località
|
|
25
|
+
'Costiera Amalfitana', 'Cinque Terre', 'Pompei', 'Dolomiti', 'Val d’Orcia', 'Capri', 'Isola di Capri',
|
|
26
|
+
'Lago di Como', 'Salento',
|
|
27
|
+
|
|
28
|
+
'Francia', 'Parigi',
|
|
29
|
+
// città
|
|
30
|
+
'Marsiglia', 'Lione', 'Tolosa', 'Nizza', 'Nantes', 'Strasburgo', 'Bordeaux', 'Lilla', 'Cannes', 'Avignone',
|
|
31
|
+
// fiumi
|
|
32
|
+
'Senna', 'Loira', 'Rodano', 'Garonna',
|
|
33
|
+
// monti
|
|
34
|
+
'Barre des Écrins', 'Pic du Midi de Bigorre',
|
|
35
|
+
// località
|
|
36
|
+
'Mont Saint-Michel', 'Costa Azzurra', 'Valle della Loira', 'Chamonix', 'Versailles', 'Camargue',
|
|
37
|
+
'Corsica', 'Normandia', 'Bretagna', 'Provenza', 'Alsazia',
|
|
38
|
+
|
|
39
|
+
'Germania', 'Berlino',
|
|
40
|
+
// città
|
|
41
|
+
'Monaco di Baviera', 'Francoforte sul Meno', 'Amburgo', 'Colonia', 'Stoccarda', 'Dresda', 'Lipsia',
|
|
42
|
+
'Norimberga', 'Düsseldorf', 'Hannover', 'Brema', 'Heidelberg',
|
|
43
|
+
// fiumi
|
|
44
|
+
'Reno', 'Danubio', 'Elba', 'Meno', 'Weser',
|
|
45
|
+
// monti
|
|
46
|
+
'Zugspitze', 'Watzmann', 'Feldberg',
|
|
47
|
+
// località
|
|
48
|
+
'Castello di Neuschwanstein', 'Foresta Nera', 'Valle del Reno', 'Isola di Rügen', 'Rothenburg ob der Tauber',
|
|
49
|
+
'Baviera',
|
|
50
|
+
|
|
51
|
+
'Spagna', 'Madrid',
|
|
52
|
+
// città
|
|
53
|
+
'Barcellona', 'Valencia', 'Siviglia', 'Saragozza', 'Malaga', 'Bilbao', 'Granada', 'San Sebastián',
|
|
54
|
+
'Santiago de Compostela', 'Toledo', 'Cordova',
|
|
55
|
+
// fiumi
|
|
56
|
+
'Tago', 'Ebro', 'Duero', 'Guadalquivir', 'Guadiana',
|
|
57
|
+
// monti
|
|
58
|
+
'Mulhacén', 'Pico Aneto', 'Teide',
|
|
59
|
+
// località
|
|
60
|
+
'Alhambra di Granada', 'Sagrada Família', 'Caminito del Rey', 'Ibiza', 'Ronda', 'Costa del Sol',
|
|
61
|
+
'Maiorca', 'Minorca', 'Tenerife', 'Lanzarote', 'Fuerteventura', 'Gran Canaria', 'Isole Canarie',
|
|
62
|
+
'Isole Baleari', 'Catalogna', 'Andalusia',
|
|
63
|
+
|
|
64
|
+
'Gran Bretagna', 'Regno Unito', 'Londra',
|
|
65
|
+
// città
|
|
66
|
+
'Birmingham', 'Manchester', 'Glasgow', 'Edimburgo', 'Liverpool', 'Cardiff', 'Belfast', 'Oxford',
|
|
67
|
+
'Cambridge', 'Bristol', 'Leeds',
|
|
68
|
+
// fiumi
|
|
69
|
+
'Tamigi', 'Severn', 'Trent', 'Clyde',
|
|
70
|
+
// monti
|
|
71
|
+
'Ben Nevis', 'Scafell Pike', 'Snowdon',
|
|
72
|
+
// località
|
|
73
|
+
'Stonehenge', 'Loch Ness', 'Giant\'s Causeway', 'Cotswolds', 'Highlands scozzesi', 'Windsor',
|
|
74
|
+
'Isola di Skye', 'Inghilterra', 'Scozia', 'Galles', 'Irlanda del Nord',
|
|
75
|
+
|
|
76
|
+
'Grecia', 'Atene',
|
|
77
|
+
// città
|
|
78
|
+
'Salonicco', 'Patrasso', 'Candia', 'Larissa',
|
|
79
|
+
// fiumi
|
|
80
|
+
'Aliakmon', 'Achelous', 'Peneus',
|
|
81
|
+
// monti
|
|
82
|
+
'Monte Olimpo', 'Monte Parnasso', 'Monte Athos',
|
|
83
|
+
// località
|
|
84
|
+
'Meteora', 'Santorini', 'Mykonos', 'Delfi', 'Olimpia', 'Cnosso', 'Santorini Caldera', 'Creta', 'Rodi', 'Corfù',
|
|
85
|
+
|
|
86
|
+
'Svizzera', 'Berna',
|
|
87
|
+
// città
|
|
88
|
+
'Zurigo', 'Ginevra', 'Basilea', 'Losanna', 'Lucerna', 'Lugano',
|
|
89
|
+
// fiumi
|
|
90
|
+
'Aare', 'Ticino',
|
|
91
|
+
// monti
|
|
92
|
+
'Dufourspitze', 'Eiger', 'Jungfrau',
|
|
93
|
+
// località
|
|
94
|
+
'Zermatt', 'St. Moritz', 'Grindelwald', 'Cascate del Reno', 'Interlaken', 'Davos', 'Alpi Svizzere',
|
|
95
|
+
|
|
96
|
+
'Portogallo', 'Lisbona', 'Oporto', 'Madeira', 'Azzorre', 'Sintra', 'Algarve',
|
|
97
|
+
'Paesi Bassi', 'Amsterdam', 'Rotterdam', 'L’Aia', 'Utrecht',
|
|
98
|
+
'Belgio', 'Bruxelles', 'Anversa', 'Bruges',
|
|
99
|
+
'Austria', 'Vienna', 'Salisburgo', 'Innsbruck', 'Graz', 'Hallstatt',
|
|
100
|
+
'Polonia', 'Varsavia', 'Cracovia', 'Danzica', 'Breslavia',
|
|
101
|
+
'Svezia', 'Stoccolma', 'Göteborg', 'Malmö',
|
|
102
|
+
'Norvegia', 'Oslo', 'Bergen', 'Tromsø', 'Fiordi Norvegesi',
|
|
103
|
+
'Danimarca', 'Copenaghen',
|
|
104
|
+
'Finlandia', 'Helsinki',
|
|
105
|
+
'Irlanda', 'Dublino', 'Galway',
|
|
106
|
+
'Repubblica Ceca', 'Praga', 'Brno',
|
|
107
|
+
'Ungheria', 'Budapest',
|
|
108
|
+
'Romania', 'Bucarest', 'Transilvania',
|
|
109
|
+
'Croazia', 'Zagabria', 'Spalato', 'Dubrovnik', 'Zara', 'Plitvice Lakes',
|
|
110
|
+
'Turchia', 'Ankara', 'Istanbul', 'Smirne', 'Antalya', 'Cappadocia',
|
|
111
|
+
'Ucraina', 'Kiev', 'Kyiv', 'Odessa', 'Leopoli',
|
|
112
|
+
'Islanda', 'Reykjavik',
|
|
113
|
+
'Lussemburgo', 'Liechtenstein', 'Principato di Monaco',
|
|
114
|
+
'Malta', 'La Valletta',
|
|
115
|
+
'Cipro', 'Nicosia',
|
|
116
|
+
'Estonia', 'Tallinn',
|
|
117
|
+
'Lettonia', 'Riga',
|
|
118
|
+
'Lituania', 'Vilnius',
|
|
119
|
+
'Bielorussia', 'Minsk',
|
|
120
|
+
'Moldavia', 'Chisinau',
|
|
121
|
+
'Serbia', 'Belgrado',
|
|
122
|
+
'Bosnia ed Erzegovina', 'Sarajevo',
|
|
123
|
+
'Montenegro', 'Podgorica',
|
|
124
|
+
'Albania', 'Tirana',
|
|
125
|
+
'Macedonia del Nord', 'Skopje',
|
|
126
|
+
'Kosovo', 'Pristina',
|
|
127
|
+
'Slovenia', 'Lubiana', 'Bled',
|
|
128
|
+
'Slovacchia', 'Bratislava',
|
|
129
|
+
'Bulgaria', 'Sofia',
|
|
130
|
+
'San Marino', 'Città del Vaticano', 'Andorra',
|
|
131
|
+
'Russia', 'Mosca', 'San Pietroburgo',
|
|
132
|
+
'Georgia', 'Tbilisi',
|
|
133
|
+
'Armenia', 'Erevan',
|
|
134
|
+
'Azerbaigian', 'Baku',
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
// AMERICA DEL NORD
|
|
138
|
+
'America del Nord',
|
|
139
|
+
|
|
140
|
+
'Stati Uniti', 'Washington',
|
|
141
|
+
// città
|
|
142
|
+
'New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix', 'Miami', 'San Francisco', 'Las Vegas',
|
|
143
|
+
'Boston', 'Seattle', 'San Diego', 'Dallas', 'Atlanta', 'New Orleans', 'Filadelfia', 'Denver',
|
|
144
|
+
'Orlando', 'Detroit', 'Honolulu',
|
|
145
|
+
// stati
|
|
146
|
+
'Alaska', 'Hawaii', 'Texas', 'Florida', 'California', 'Nevada', 'Arizona',
|
|
147
|
+
// fiumi
|
|
148
|
+
'Mississippi', 'Missouri', 'Colorado', 'Rio Grande', 'Hudson',
|
|
149
|
+
// monti
|
|
150
|
+
'Denali', 'Monte Whitney', 'Monte Rainier', 'Monte Elbert',
|
|
151
|
+
// località
|
|
152
|
+
'Grand Canyon', 'Parco di Yellowstone', 'Yosemite', 'Monument Valley', 'Cascate del Niagara', 'Key West',
|
|
153
|
+
|
|
154
|
+
'Canada', 'Ottawa',
|
|
155
|
+
// città
|
|
156
|
+
'Toronto', 'Montreal', 'Vancouver', 'Calgary', 'Edmonton', 'Québec',
|
|
157
|
+
// province
|
|
158
|
+
'Nuova Scozia', 'Terranova', 'Manitoba', 'Saskatchewan', 'Ontario',
|
|
159
|
+
// fiumi
|
|
160
|
+
'San Lorenzo', 'Mackenzie', 'Yukon', 'Fraser',
|
|
161
|
+
// monti
|
|
162
|
+
'Monte Logan', 'Monte Robson', 'Monte Columbia',
|
|
163
|
+
// località
|
|
164
|
+
'Parco Nazionale di Banff', 'Lago Louise', 'Whistler', 'Capilano Suspension Bridge',
|
|
165
|
+
|
|
166
|
+
'Messico', 'Città del Messico',
|
|
167
|
+
// città
|
|
168
|
+
'Guadalajara', 'Monterrey', 'Puebla', 'Tijuana', 'Cancún',
|
|
169
|
+
// fiumi
|
|
170
|
+
'Usumacinta', 'Grijalva',
|
|
171
|
+
// monti
|
|
172
|
+
'Pico de Orizaba', 'Popocatépetl', 'Iztaccíhuatl',
|
|
173
|
+
// località
|
|
174
|
+
'Chichén Itzá', 'Teotihuacan', 'Tulum', 'Cabo San Lucas', 'Oaxaca',
|
|
175
|
+
|
|
176
|
+
// altri paesi dell'America del Nord, Centrale e Caraibi
|
|
177
|
+
'Cuba', 'L’Avana', 'Varadero',
|
|
178
|
+
'Giamaica', 'Kingston',
|
|
179
|
+
'Costa Rica', 'San José', 'Monteverde Cloud Forest',
|
|
180
|
+
'Panama', 'Città di Panama', 'San Blas Islands',
|
|
181
|
+
'Repubblica Dominicana', 'Santo Domingo', 'Punta Cana',
|
|
182
|
+
'Guatemala', 'Honduras', 'El Salvador', 'Nicaragua', 'Belize',
|
|
183
|
+
'Haiti', 'Porto Rico', 'Bahamas', 'Nassau', 'Barbados', 'Trinidad e Tobago', 'Martinica', 'Guadalupa',
|
|
184
|
+
'Bermuda', 'Bermuda Beaches',
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
// AMERICA DEL SUD
|
|
188
|
+
'America del Sud',
|
|
189
|
+
|
|
190
|
+
'Brasile', 'Brasilia',
|
|
191
|
+
// città
|
|
192
|
+
'San Paolo', 'Rio de Janeiro', 'Salvador', 'Fortaleza', 'Belo Horizonte',
|
|
193
|
+
// fiumi
|
|
194
|
+
'Rio delle Amazzoni', 'Paraná', 'São Francisco', 'Tocantins',
|
|
195
|
+
// monti
|
|
196
|
+
'Pico da Neblina', 'Pico 3 de Março', 'Pico da Bandeira',
|
|
197
|
+
// località
|
|
198
|
+
'Cristo Redentore', 'Cascate dell\'Iguazú', 'Foresta Amazzonica', 'Lençóis Maranhenses', 'Fernando de Noronha',
|
|
199
|
+
|
|
200
|
+
'Argentina', 'Buenos Aires',
|
|
201
|
+
// città
|
|
202
|
+
'Córdoba', 'Rosario', 'Mendoza', 'La Plata', 'San Carlos de Bariloche',
|
|
203
|
+
// fiumi
|
|
204
|
+
'Uruguay', 'Río de la Plata', 'Rio Negro',
|
|
205
|
+
// monti
|
|
206
|
+
'Aconcagua', 'Fitz Roy', 'Monte Pissis',
|
|
207
|
+
// località
|
|
208
|
+
'Ghiacciaio Perito Moreno', 'Patagonia', 'Ushuaia', 'Quebrada de Humahuaca',
|
|
209
|
+
|
|
210
|
+
'Perù', 'Lima',
|
|
211
|
+
// città
|
|
212
|
+
'Arequipa', 'Trujillo', 'Chiclayo', 'Cusco', 'Iquitos', 'Cuzco',
|
|
213
|
+
// fiumi
|
|
214
|
+
'Ucayali', 'Marañón',
|
|
215
|
+
// monti
|
|
216
|
+
'Huascarán', 'Yerupajá', 'Ausangate',
|
|
217
|
+
// località
|
|
218
|
+
'Machu Picchu', 'Valle Sacra degli Inca', 'Lago Titicaca', 'Linee di Nazca', 'Vinicunca',
|
|
219
|
+
|
|
220
|
+
// altri paesi dell'America del Sud
|
|
221
|
+
'Cile', 'Santiago del Cile', 'Valparaíso', 'Isola di Pasqua', 'Torres del Paine', 'Atacama Desert',
|
|
222
|
+
'Colombia', 'Bogotà', 'Medellín', 'Cartagena Old Town',
|
|
223
|
+
'Ecuador', 'Quito', 'Guayaquil', 'Galapagos Islands',
|
|
224
|
+
'Uruguay', 'Montevideo',
|
|
225
|
+
'Bolivia', 'La Paz', 'Cochabamba', 'Sucre', 'Salar de Uyuni',
|
|
226
|
+
'Venezuela', 'Caracas',
|
|
227
|
+
'Paraguay', 'Asunción',
|
|
228
|
+
'Guyana', 'Suriname',
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
// ASIA
|
|
232
|
+
'Asia',
|
|
233
|
+
|
|
234
|
+
'Giappone', 'Tokyo',
|
|
235
|
+
// città
|
|
236
|
+
'Yokohama', 'Osaka', 'Nagoya', 'Sapporo', 'Kyoto', 'Fukuoka', 'Hiroshima', 'Nagasaki',
|
|
237
|
+
// fiumi
|
|
238
|
+
'Shinano', 'Tone', 'Ishikari',
|
|
239
|
+
// monti
|
|
240
|
+
'Monte Fuji', 'Monte Kita', 'Monte Hotaka',
|
|
241
|
+
// località
|
|
242
|
+
'Fushimi Inari-taisha', 'Miyajima', 'Nara', 'Takayama', 'Shirakawa-go', 'Okinawa', 'Hokkaido',
|
|
243
|
+
|
|
244
|
+
'Cina', 'Pechino',
|
|
245
|
+
// città
|
|
246
|
+
'Shanghai', 'Guangzhou', 'Shenzhen', 'Chengdu', 'Chongqing', 'Xi\'an', 'Hong Kong', 'Macao', 'Lhasa',
|
|
247
|
+
// fiumi
|
|
248
|
+
'Fiume Azzurro', 'Fiume Giallo', 'Fiume delle Perle',
|
|
249
|
+
// monti
|
|
250
|
+
'Huangshan', 'Monte Tai', 'K2',
|
|
251
|
+
// località
|
|
252
|
+
'Grande Muraglia Cinese', 'Città Proibita', 'Esercito di Terracotta', 'Guilin', 'Zhangjiajie', 'Tibet',
|
|
253
|
+
|
|
254
|
+
'India', 'Nuova Delhi',
|
|
255
|
+
// città
|
|
256
|
+
'Mumbai', 'Bangalore', 'Hyderabad', 'Ahmedabad', 'Calcutta', 'Jaipur', 'Delhi', 'Chennai',
|
|
257
|
+
// fiumi
|
|
258
|
+
'Gange', 'Indo', 'Brahmaputra', 'Godavari',
|
|
259
|
+
// monti
|
|
260
|
+
'Kangchenjunga', 'Nanda Devi', 'Kamet',
|
|
261
|
+
// località
|
|
262
|
+
'Taj Mahal', 'Taj Mahal Complex', 'Varanasi', 'Backwaters del Kerala', 'Khajuraho', 'Kerala', 'Goa',
|
|
263
|
+
|
|
264
|
+
'Nepal', 'Kathmandu',
|
|
265
|
+
// città
|
|
266
|
+
'Pokhara', 'Lalitpur', 'Biratnagar',
|
|
267
|
+
// fiumi
|
|
268
|
+
'Kosi', 'Gandaki', 'Karnali',
|
|
269
|
+
// monti
|
|
270
|
+
'Everest', 'Lhotse', 'Makalu', 'Cho Oyu', 'Annapurna',
|
|
271
|
+
// località
|
|
272
|
+
'Piazza Durbar', 'Campo Base dell\'Everest', 'Lago Phewa', 'Parco di Chitwan',
|
|
273
|
+
|
|
274
|
+
// altri paesi asiatici
|
|
275
|
+
'Corea del Sud', 'Seoul', 'Busan', 'Jeju Island',
|
|
276
|
+
'Thailandia', 'Bangkok', 'Phuket', 'Chiang Mai',
|
|
277
|
+
'Vietnam', 'Hanoi', 'Ho Chi Minh', 'Halong Bay',
|
|
278
|
+
'Indonesia', 'Giacarta', 'Bali', 'Borobudur',
|
|
279
|
+
'Filippine', 'Manila',
|
|
280
|
+
'Malaysia', 'Kuala Lumpur',
|
|
281
|
+
'Singapour', 'Singapore',
|
|
282
|
+
'Emirati Arabi Uniti', 'Abu Dhabi', 'Dubai',
|
|
283
|
+
'Arabia Saudita', 'Riad',
|
|
284
|
+
'Israele', 'Gerusalemme',
|
|
285
|
+
'Giordania', 'Amman', 'Petra',
|
|
286
|
+
'Kazakistan', 'Astana',
|
|
287
|
+
'Uzbekistan', 'Tashkent', 'Samarcanda',
|
|
288
|
+
'Mongolia', 'Ulan Bator',
|
|
289
|
+
'Corea del Nord', 'Pyongyang',
|
|
290
|
+
'Taiwan', 'Taipei',
|
|
291
|
+
'Cambogia', 'Phnom Penh', 'Angkor Wat',
|
|
292
|
+
'Laos', 'Vientiane',
|
|
293
|
+
'Myanmar', 'Bagan',
|
|
294
|
+
'Sri Lanka', 'Colombo',
|
|
295
|
+
'Bangladesh', 'Dacca',
|
|
296
|
+
'Pakistan', 'Islamabad', 'Karachi',
|
|
297
|
+
'Afghanistan', 'Kabul',
|
|
298
|
+
'Bhutan', 'Thimphu',
|
|
299
|
+
'Maldive', 'Maldivian Atolls',
|
|
300
|
+
'Brunei',
|
|
301
|
+
'Iran', 'Teheran',
|
|
302
|
+
'Iraq', 'Baghdad',
|
|
303
|
+
'Siria', 'Damasco',
|
|
304
|
+
'Libano', 'Beirut',
|
|
305
|
+
'Kuwait', 'Qatar', 'Doha',
|
|
306
|
+
'Oman', 'Mascate',
|
|
307
|
+
'Bahrein', 'Yemen',
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
// AFRICA
|
|
311
|
+
'Africa',
|
|
312
|
+
|
|
313
|
+
'Egitto', 'Il Cairo',
|
|
314
|
+
// città
|
|
315
|
+
'Alessandria', 'Giza', 'Sharm el-Sheikh', 'Luxor', 'Aswan',
|
|
316
|
+
// fiumi
|
|
317
|
+
'Nilo',
|
|
318
|
+
// monti
|
|
319
|
+
'Monte Caterina', 'Monte Sinai',
|
|
320
|
+
// località
|
|
321
|
+
'Piramidi di Giza', 'Valle dei Re', 'Tempio di Abu Simbel', 'Karnak',
|
|
322
|
+
|
|
323
|
+
'Tanzania', 'Dodoma',
|
|
324
|
+
// città
|
|
325
|
+
'Dar es Salaam', 'Mwanza', 'Arusha', 'Zanzibar City',
|
|
326
|
+
// fiumi
|
|
327
|
+
'Rufiji', 'Ruvuma', 'Pangani',
|
|
328
|
+
// monti
|
|
329
|
+
'Kilimangiaro', 'Monte Meru',
|
|
330
|
+
// località
|
|
331
|
+
'Parco del Serengeti', 'Cratere di Ngorongoro', 'Zanzibar',
|
|
332
|
+
|
|
333
|
+
'Sudafrica', 'Pretoria',
|
|
334
|
+
// città
|
|
335
|
+
'Città del Capo', 'Johannesburg', 'Durban', 'Gqeberha',
|
|
336
|
+
// fiumi
|
|
337
|
+
'Orange', 'Limpopo', 'Vaal',
|
|
338
|
+
// monti
|
|
339
|
+
'Table Mountain', 'Mafadi',
|
|
340
|
+
// località
|
|
341
|
+
'Parco Nazionale Kruger', 'Capo di Buona Speranza', 'Garden Route', 'Robben Island',
|
|
342
|
+
|
|
343
|
+
// altri paesi africani
|
|
344
|
+
'Marocco', 'Rabat', 'Marrakech', 'Casablanca', 'Fes', 'Tangeri', 'Chefchaouen',
|
|
345
|
+
'Tunisia', 'Tunisi',
|
|
346
|
+
'Kenya', 'Nairobi',
|
|
347
|
+
'Senegal', 'Dakar',
|
|
348
|
+
'Madagascar', 'Antananarivo',
|
|
349
|
+
'Mauritius', 'Port Louis', 'Le Morne Brabant',
|
|
350
|
+
'Etiopia', 'Addis Abeba',
|
|
351
|
+
'Algeria', 'Algeri',
|
|
352
|
+
'Libia', 'Tripoli',
|
|
353
|
+
'Nigeria', 'Abuja', 'Lagos',
|
|
354
|
+
'Ghana', 'Accra',
|
|
355
|
+
'Costa d’Avorio', 'Camerun',
|
|
356
|
+
'Uganda', 'Kampala',
|
|
357
|
+
'Ruanda', 'Kigali',
|
|
358
|
+
'Mozambico', 'Maputo',
|
|
359
|
+
'Zimbabwe', 'Harare', 'Victoria Falls',
|
|
360
|
+
'Zambia', 'Lusaka',
|
|
361
|
+
'Namibia', 'Windhoek',
|
|
362
|
+
'Botswana', 'Gaborone', 'Okavango Delta',
|
|
363
|
+
'Angola', 'Luanda',
|
|
364
|
+
'Sudan', 'Khartum',
|
|
365
|
+
'Seychelles', 'Praslin Island',
|
|
366
|
+
'Capo Verde',
|
|
367
|
+
'Congo', 'Kinshasa',
|
|
368
|
+
'Somalia', 'Mogadiscio',
|
|
369
|
+
'Eritrea', 'Asmara',
|
|
370
|
+
'Gambia', 'Niger', 'Ciad', 'Mauritania', 'Malawi', 'Lesotho', 'Eswatini', 'Gabon', 'Togo', 'Benin',
|
|
371
|
+
'Burkina Faso', 'Sierra Leone', 'Liberia', 'Guinea', 'Gibuti',
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
// OCEANIA
|
|
375
|
+
'Oceania',
|
|
376
|
+
|
|
377
|
+
'Australia', 'Canberra',
|
|
378
|
+
// città
|
|
379
|
+
'Sydney', 'Melbourne', 'Brisbane', 'Perth', 'Adelaide', 'Hobart', 'Gold Coast', 'Cairns', 'Darwin',
|
|
380
|
+
// fiumi
|
|
381
|
+
'Murray', 'Darling', 'Murrumbidgee',
|
|
382
|
+
// monti
|
|
383
|
+
'Monte Kosciuszko', 'Mawson Peak',
|
|
384
|
+
// località
|
|
385
|
+
'Grande Barriera Corallina', 'Uluru', 'Opera House di Sydney', 'Twelve Apostles', 'Whitsunday Islands',
|
|
386
|
+
'Tasmania',
|
|
387
|
+
|
|
388
|
+
'Nuova Zelanda', 'Wellington',
|
|
389
|
+
// città
|
|
390
|
+
'Auckland', 'Christchurch', 'Hamilton', 'Dunedin', 'Queenstown',
|
|
391
|
+
// fiumi
|
|
392
|
+
'Waikato', 'Clutha', 'Whanganui',
|
|
393
|
+
// monti
|
|
394
|
+
'Aoraki / Monte Cook', 'Monte Aspiring', 'Monte Ruapehu',
|
|
395
|
+
// località
|
|
396
|
+
'Milford Sound', 'Hobbiton Movie Set', 'Rotorua', 'Waitomo Glowworm Caves', 'Aoraki / Mount Cook Area',
|
|
397
|
+
'Matamata',
|
|
398
|
+
|
|
399
|
+
// altri paesi dell'Oceania
|
|
400
|
+
'Fiji', 'Suva',
|
|
401
|
+
'Polinesia Francese', 'Papeete', 'Tahiti', 'Bora Bora',
|
|
402
|
+
'Papua Nuova Guinea', 'Port Moresby',
|
|
403
|
+
'Samoa', 'Tonga', 'Vanuatu', 'Nuova Caledonia', 'Isole Cook', 'Isole Salomone',
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
// --------------------
|
|
407
|
+
// places not tied to a single country (seas, oceans, regions, polar areas)
|
|
408
|
+
'Mar Mediterraneo', 'Mediterraneo', 'Mar Adriatico', 'Mar Tirreno', 'Mar Ionio', 'Mar Ligure',
|
|
409
|
+
'Mar Nero', 'Mar Baltico', 'Mare del Nord', 'Mar Rosso', 'Mar Morto', 'Mar dei Caraibi', 'Caraibi',
|
|
410
|
+
'Oceano Atlantico', 'Oceano Pacifico', 'Oceano Indiano',
|
|
411
|
+
'Artide', 'Polo Nord', 'Antartide', 'Polo Sud',
|
|
412
|
+
'Groenlandia', 'Lapponia', 'Siberia',
|
|
413
|
+
'Sahara', 'Kalahari', 'Namib',
|
|
414
|
+
'Ande', 'Amazzonia', 'Terra del Fuoco'
|
|
415
|
+
];
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Key used to match a place regardless of case, spacing and apostrophe style
|
|
420
|
+
* @param {string} str
|
|
421
|
+
* @returns {string}
|
|
422
|
+
*/
|
|
423
|
+
const placeKey = str => str.toLowerCase().replace(/[ \u00A0]+/g, ' ').replace(/['‘’]/g, '’');
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Builds the matcher for a list of places: a single regex (longest places first, so that
|
|
427
|
+
* e.g. "Lago di Como" wins over a shorter overlapping name) and a key → canonical form map.
|
|
428
|
+
* The canonical form uses the typographic apostrophe and non-breaking spaces after particles,
|
|
429
|
+
* consistently with betterText().
|
|
430
|
+
*
|
|
431
|
+
* @param {string[]} list - places list
|
|
432
|
+
* @returns {{regex: RegExp, canonical: Map<string, string>} | null} null if the list is empty
|
|
433
|
+
*/
|
|
434
|
+
function buildPlacesMatcher(list) {
|
|
435
|
+
const canonical = new Map();
|
|
436
|
+
|
|
437
|
+
list.filter(Boolean).forEach(place => {
|
|
438
|
+
const key = placeKey(place);
|
|
439
|
+
if (!canonical.has(key)) {
|
|
440
|
+
canonical.set(
|
|
441
|
+
key,
|
|
442
|
+
place.trim()
|
|
443
|
+
.replace(/'/g, '’')
|
|
444
|
+
.replace(NBSP_AFTER_PARTICLE_REGEX, match => match.replace(/ +/g, '\u00A0'))
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
if (!canonical.size) {
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
const patterns = [...canonical.values()]
|
|
454
|
+
.sort((a, b) => b.length - a.length)
|
|
455
|
+
.map(place => place
|
|
456
|
+
.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&')
|
|
457
|
+
.replace(/[ \u00A0]+/g, '[ \\u00A0]+')
|
|
458
|
+
.replace(/’/g, '[\'’‘]')
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
return {
|
|
462
|
+
// custom boundaries instead of \b, which doesn't work with accented edge letters (e.g. "Perù")
|
|
463
|
+
regex: new RegExp(`(?<![\\p{L}\\p{N}])(?:${patterns.join('|')})(?![\\p{L}\\p{N}])`, 'giu'),
|
|
464
|
+
canonical
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
const defaultMatcher = buildPlacesMatcher(places);
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Version of betterText() that also normalizes the occurrences of known places
|
|
472
|
+
* (countries, cities, rivers, mountains, tourist locations) found in the text:
|
|
473
|
+
* matching is case-insensitive and tolerant to spacing and apostrophe style, and every
|
|
474
|
+
* match is replaced by the canonical form listed in `places` (casing, typographic
|
|
475
|
+
* apostrophe, non-breaking spaces after particles).
|
|
476
|
+
* Places replacement runs after betterText(), so it takes precedence over the casing
|
|
477
|
+
* enforced on particles and custom words.
|
|
478
|
+
*
|
|
479
|
+
* NOTE: places that are also common words (e.g. "Meno", "Po", "Reno") are capitalized
|
|
480
|
+
* wherever they appear.
|
|
481
|
+
*
|
|
482
|
+
* @param {string} str - input string to process
|
|
483
|
+
* @param {string[]} [custom_words] - list of words whose exact casing must be preserved (e.g. `['iPhone', 'macOS']`) (default: [])
|
|
484
|
+
* @param {string[]} [extra_places] - additional places, merged with the built-in list (default: [])
|
|
485
|
+
* @returns {string} processed string, or empty string if input is falsy
|
|
486
|
+
*
|
|
487
|
+
* @example
|
|
488
|
+
* betterTextWithPlaces("vacanza a new york e nel lago di como ,l'avana");
|
|
489
|
+
* // → "vacanza a New York e nel Lago di Como, L’Avana"
|
|
490
|
+
*
|
|
491
|
+
* betterTextWithPlaces('gita a monte cervino', ['iPhone'], ['Monte Cervino']);
|
|
492
|
+
* // → 'gita a Monte Cervino'
|
|
493
|
+
*/
|
|
494
|
+
export function betterTextWithPlaces(str, custom_words = [], extra_places = []) {
|
|
495
|
+
|
|
496
|
+
str = betterText(str, custom_words);
|
|
497
|
+
|
|
498
|
+
if (!str) {
|
|
499
|
+
return str;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const matcher = extra_places.length
|
|
503
|
+
? buildPlacesMatcher([...places, ...extra_places])
|
|
504
|
+
: defaultMatcher;
|
|
505
|
+
|
|
506
|
+
return matcher
|
|
507
|
+
? str.replace(matcher.regex, match => matcher.canonical.get(placeKey(match)) ?? match)
|
|
508
|
+
: str;
|
|
509
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
/*! minimo - Better Text */
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
// Italian particles/articles (plus a few English and topographic terms) whose casing is
|
|
5
6
|
// enforced and after which spaces are turned into non-breaking spaces. Hoisted to module
|
|
6
7
|
// scope with the regexes/lookup built from it below, since none of this depends on the
|
|
@@ -29,7 +30,7 @@ const PARTICELLE = [
|
|
|
29
30
|
];
|
|
30
31
|
|
|
31
32
|
// matches a particle followed by one-or-more spaces, to be turned into non-breaking spaces
|
|
32
|
-
const NBSP_AFTER_PARTICLE_REGEX =
|
|
33
|
+
export const NBSP_AFTER_PARTICLE_REGEX =new RegExp('\\b(' + PARTICELLE.join('|') + ')\\b +', 'gmi');
|
|
33
34
|
|
|
34
35
|
// matches any particle regardless of case, to enforce its exact casing in a single pass
|
|
35
36
|
const PARTICLE_CASING_REGEX = new RegExp('\\b(' + PARTICELLE.join('|') + ')\\b', 'gmi');
|
|
@@ -59,6 +60,10 @@ export function betterText(str, custom_words = []) {
|
|
|
59
60
|
str = str.replace(/ +(,|;|\.|:|!|\?)/g, '$1');
|
|
60
61
|
str = str.replace(/(,|;|\.|:|!|\?)(?!$) +/g, '$1 ');
|
|
61
62
|
|
|
63
|
+
// add the missing space after , ; ! ? when directly followed by a letter or a quote;
|
|
64
|
+
// digits are skipped on purpose (decimals like 1,5), as are . and : (abbreviations, times, URLs)
|
|
65
|
+
str = str.replace(/([,;!?])(?=[\p{L}"'“‘])/gu, '$1 ');
|
|
66
|
+
|
|
62
67
|
// collapse multiple spaces and tabs (including non-breaking spaces)
|
|
63
68
|
str = str.replace(/[ \t\u00A0]+/g, ' ');
|
|
64
69
|
|
|
@@ -86,6 +91,12 @@ export function betterText(str, custom_words = []) {
|
|
|
86
91
|
: exact;
|
|
87
92
|
});
|
|
88
93
|
|
|
94
|
+
// capitalize the first letter after ! ? and ellipsis (... or …), optionally after an opening quote;
|
|
95
|
+
// runs after the particle casing so that a capital is not undone for particles like "e" or "di"
|
|
96
|
+
str = str.replace(/([!?]|\.{3}|…) +([“‘]?)(\p{Ll})/gu, (_match, punct, quote, letter) =>
|
|
97
|
+
`${punct} ${quote}${letter.toUpperCase()}`
|
|
98
|
+
);
|
|
99
|
+
|
|
89
100
|
if(custom_words.length) {
|
|
90
101
|
custom_words.forEach(item => {
|
|
91
102
|
str = str.replace(new RegExp(`\\b${item}\\b`, 'gi'), item);
|