@danielhaim/titlecaser 1.6.0 → 1.6.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielhaim/titlecaser",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Converts a string to title case with multiple style options, ability to ignore certain words, and handle acronyms",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"title case",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"package.json"
|
|
44
44
|
],
|
|
45
45
|
"scripts": {
|
|
46
|
-
"build-docs": "cd docs && bundle install && bundle exec jekyll build",
|
|
47
46
|
"build": "npx webpack --mode production && cp -R dist/ docs/assets/js",
|
|
47
|
+
"build-docs": "cd docs && bundle install && bundle exec jekyll build",
|
|
48
48
|
"release": "npm version patch && npm run build && git add -A && git commit -m 'Release: v$(node -p \"require('./package.json').version\")' && git push && npm publish",
|
|
49
49
|
"release-major": "npm version major && npm run build && git add -A && git commit -m 'Major Release: v$(node -p \"require('./package.json').version\")' && git push && npm publish",
|
|
50
50
|
"release-minor": "npm version minor && npm run build && git add -A && git commit -m 'Minor Release: v$(node -p \"require('./package.json').version\")' && git push && npm publish",
|
package/src/TitleCaserConsts.js
CHANGED
|
@@ -68,6 +68,7 @@ export const wordReplacementsList = [
|
|
|
68
68
|
{ "a.s.a.p": "ASAP" },
|
|
69
69
|
{ "f.a.q": "FAQ" },
|
|
70
70
|
{ "f.a.q.s": "FAQs" },
|
|
71
|
+
{ "FAQS": "FAQs" },
|
|
71
72
|
{ "f.y.i": "FYI" },
|
|
72
73
|
{ "d.i.y": "DIY" },
|
|
73
74
|
{ "t.b.d": "TBD" },
|
|
@@ -80,7 +81,7 @@ export const wordReplacementsList = [
|
|
|
80
81
|
{ "reactjs": "React" },
|
|
81
82
|
{ "react.js": "React" },
|
|
82
83
|
{ "cyber-security": "Cybersecurity" },
|
|
83
|
-
// { 'twitter': '𝕏' }
|
|
84
|
+
// { 'twitter': 'Twitter, formerly known as 𝕏' }
|
|
84
85
|
];
|
|
85
86
|
|
|
86
87
|
export const titleCaseStylesList = Object.freeze({
|
package/src/TitleCaserUtils.js
CHANGED
|
@@ -219,9 +219,14 @@ export class TitleCaserUtils {
|
|
|
219
219
|
return /[A-Z]/.test(word.slice(1));
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
const hasUppercase = /[A-Z]/.test(word.slice(1));
|
|
223
|
+
const hasLowercase = /[a-z]/.test(word.slice(1));
|
|
224
|
+
|
|
225
|
+
return hasUppercase && hasLowercase;
|
|
223
226
|
}
|
|
224
227
|
|
|
228
|
+
// Check if a word is an acronym
|
|
229
|
+
// (i.e. 'the', 'to', 'within')
|
|
225
230
|
static isAcronym(word, prevWord, nextWord) {
|
|
226
231
|
try {
|
|
227
232
|
if (typeof word !== "string") {
|
|
@@ -539,6 +544,7 @@ export class TitleCaserUtils {
|
|
|
539
544
|
});
|
|
540
545
|
}
|
|
541
546
|
|
|
547
|
+
// Check if there's an unescaped special character
|
|
542
548
|
static unescapeSpecialCharacters(str) {
|
|
543
549
|
return str.replace(/&|<|>|"|'/g, function (match) {
|
|
544
550
|
switch (match) {
|