@danielhaim/titlecaser 1.2.49 → 1.2.53
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/README.md +3 -1
- package/package.json +1 -1
- package/src/TitleCaser.js +4 -1
- package/src/TitleCaserConsts.js +39 -2
package/README.md
CHANGED
|
@@ -13,7 +13,9 @@ Transform any text to proper title case format using popular style guides such a
|
|
|
13
13
|
## Table of Contents
|
|
14
14
|
|
|
15
15
|
- [TitleCaser](#titlecaser)
|
|
16
|
-
* [Demo](
|
|
16
|
+
* [Demo](https://danielhaim1.github.io/TitleCaser/)
|
|
17
|
+
* [CodePen Demo 1](https://codepen.io/danielhaim/pen/oNQgjBv)
|
|
18
|
+
* [CodePen Demo 2](https://codepen.io/danielhaim/pen/oNPGzKw)
|
|
17
19
|
* [Table of Contents](#table-of-contents)
|
|
18
20
|
* [Introduction](#introduction)
|
|
19
21
|
* [Key Features:](#key-features)
|
package/package.json
CHANGED
package/src/TitleCaser.js
CHANGED
|
@@ -122,7 +122,7 @@ export class TitleCaser {
|
|
|
122
122
|
case TitleCaserUtils.hasNumbers ( word ):
|
|
123
123
|
// If the word has numbers, return the correct casing.
|
|
124
124
|
return word;
|
|
125
|
-
|
|
125
|
+
default:
|
|
126
126
|
// Default to returning the word with the correct casing.
|
|
127
127
|
return word.charAt ( 0 )
|
|
128
128
|
.toUpperCase () + word.slice ( 1 )
|
|
@@ -144,6 +144,9 @@ export class TitleCaser {
|
|
|
144
144
|
// Replace the nl2br placeholder with <br> tags.
|
|
145
145
|
inputString = inputString.replace(/nl2br/gi, "<br />");
|
|
146
146
|
|
|
147
|
+
// BEFORE WE RETURN THE STRING
|
|
148
|
+
// CHECK THE LAST WORD AND IF IT IS INTENTIONALLY UPPERCASED, IF IT IS, RETURN THE STRING.
|
|
149
|
+
|
|
147
150
|
// Return the string.
|
|
148
151
|
return inputString;
|
|
149
152
|
} catch ( error ) {
|
package/src/TitleCaserConsts.js
CHANGED
|
@@ -9,7 +9,40 @@ export const correctTitleCasingList = [
|
|
|
9
9
|
'MobX', 'SCSS', 'TypeScript', 'Vue.js', '.NET', 'ASP', 'ASPX',
|
|
10
10
|
'MySQL', 'PHP', 'PostgresQL', 'Python', 'SQL', 'GraphQL',
|
|
11
11
|
'HTML5',
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
// Countries
|
|
14
|
+
'Afghanistan', 'Albania', 'Algeria', 'Andorra', 'Angola', 'Antigua and Barbuda',
|
|
15
|
+
'Argentina', 'Armenia', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas',
|
|
16
|
+
'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin',
|
|
17
|
+
'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Brazil', 'Brunei',
|
|
18
|
+
'Bulgaria', 'Burkina Faso', 'Burundi', 'Cabo Verde', 'Cambodia', 'Cameroon',
|
|
19
|
+
'Canada', 'Central African Republic', 'Chad', 'Chile', 'China', 'Colombia',
|
|
20
|
+
'Comoros', 'Congo', 'Costa Rica', 'Cote d\'Ivoire', 'Croatia', 'Cuba',
|
|
21
|
+
'Cyprus', 'Czech Republic', 'Denmark', 'Djibouti', 'Dominica',
|
|
22
|
+
'Dominican Republic', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea',
|
|
23
|
+
'Eritrea', 'Estonia', 'Eswatini', 'Ethiopia', 'Fiji', 'Finland', 'France',
|
|
24
|
+
'Gabon', 'Gambia', 'Georgia', 'Germany', 'Ghana', 'Greece', 'Grenada',
|
|
25
|
+
'Guatemala', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Honduras', 'Hungary',
|
|
26
|
+
'Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Ireland', 'Israel', 'Italy',
|
|
27
|
+
'Jamaica', 'Japan', 'Jordan', 'Kazakhstan', 'Kenya', 'Kiribati', 'Korea',
|
|
28
|
+
'Kosovo', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lebanon', 'Lesotho',
|
|
29
|
+
'Liberia', 'Libya', 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Madagascar',
|
|
30
|
+
'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands',
|
|
31
|
+
'Mauritania', 'Mauritius', 'Mexico', 'Micronesia', 'Moldova', 'Monaco',
|
|
32
|
+
'Mongolia', 'Montenegro', 'Morocco', 'Mozambique', 'Myanmar', 'Namibia',
|
|
33
|
+
'Nauru', 'Nepal', 'Netherlands', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria',
|
|
34
|
+
'North Macedonia', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Panama', 'Papua New Guinea',
|
|
35
|
+
'Paraguay', 'Peru', 'Philippines', 'Poland', 'Portugal', 'Qatar', 'Romania',
|
|
36
|
+
'Russia', 'Rwanda', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Vincent and the Grenadines',
|
|
37
|
+
'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia',
|
|
38
|
+
'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia', 'Slovenia', 'Solomon Islands',
|
|
39
|
+
'Somalia', 'South Africa', 'South Korea', 'South Sudan', 'Spain', 'Sri Lanka', 'Sudan',
|
|
40
|
+
'Suriname', 'Sweden', 'Switzerland', 'Syria', 'Taiwan', 'Tajikistan', 'Tanzania',
|
|
41
|
+
'Thailand', 'Timor-Leste', 'Togo', 'Tonga', 'Trinidad and Tobago', 'Tunisia',
|
|
42
|
+
'Turkey', 'Turkmenistan', 'Tuvalu', 'Uganda', 'Ukraine', 'United Arab Emirates',
|
|
43
|
+
'United Kingdom', 'United States', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Vatican City',
|
|
44
|
+
'Venezuela', 'Vietnam', 'Yemen', 'Zambia', 'Zimbabwe',
|
|
45
|
+
|
|
13
46
|
// Acronyms/Abbreviations
|
|
14
47
|
'API', 'APIs', 'ASCII', 'CI', 'CircleCI', 'CLI', 'DLL', 'DNS',
|
|
15
48
|
'EC2', 'FTP', 'HTTP', 'HTTPs', 'ICMP', 'IDE', 'IP', 'ISP',
|
|
@@ -78,7 +111,7 @@ export const correctTitleCasingList = [
|
|
|
78
111
|
'ProTools', 'QuickTime', 'AdWords', 'AdSense', 'TikTok', 'Slack', 'Trello',
|
|
79
112
|
'Zoom', 'Twitch', 'Snapchat', 'WhatsApp', 'Telegram', 'Discord', 'Reddit',
|
|
80
113
|
'Quora', 'StackOverflow', 'StackExchange', 'Coca-Cola',
|
|
81
|
-
'AWS', 'GCP', 'VMware', 'CVS', 'ESL', 'EE', 'CW', 'EE',
|
|
114
|
+
'AWS', 'GCP', 'VMware', 'CVS', 'ESL', 'EE', 'CW', 'EE', 'ITV',
|
|
82
115
|
|
|
83
116
|
// Sports
|
|
84
117
|
'NBA', 'NCAA', 'NFL', 'WWE', 'WWF', 'FIFA',
|
|
@@ -100,6 +133,9 @@ export const correctTitleCasingList = [
|
|
|
100
133
|
|
|
101
134
|
// Commercial
|
|
102
135
|
'Ltd.', 'Co.', 'Inc.', 'St.', 'Ave.', 'Bldg.', 'No.',
|
|
136
|
+
|
|
137
|
+
// Other
|
|
138
|
+
'×', 'x', 'TV', 'IRL', 'UK'
|
|
103
139
|
];
|
|
104
140
|
|
|
105
141
|
export const wordReplacementsList = [
|
|
@@ -126,6 +162,7 @@ export const wordReplacementsList = [
|
|
|
126
162
|
{ 't.b.d': 'TBD' },
|
|
127
163
|
{ 'vuejs': 'Vue.js' },
|
|
128
164
|
{ 'phd': 'ph.d.' },
|
|
165
|
+
{ 'x': '×' },
|
|
129
166
|
];
|
|
130
167
|
|
|
131
168
|
// ! TODO
|