@danielhaim/titlecaser 1.2.64 → 1.3.0
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/LICENSE +21 -201
- package/README.md +36 -29
- package/index.js +2 -8
- package/package.json +9 -8
- package/src/TitleCaserConsts.js +3 -1
package/LICENSE
CHANGED
|
@@ -1,201 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2023 Daniel Haim
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Daniel Haim [https://danielhaim.com]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
TitleCaser
|
|
2
|
+
==========
|
|
2
3
|
|
|
3
4
|
[](https://www.npmjs.com/package/@danielhaim/titlecaser)
|
|
4
5
|
[](https://www.npmjs.com/package/@danielhaim/titlecaser)
|
|
@@ -6,12 +7,8 @@
|
|
|
6
7
|
|
|
7
8
|
Transform any text to proper title case format using popular style guides such as APA, AP, Chicago, NYT, Wikipedia, and British. Customize options to achieve greater flexibility and consistency.
|
|
8
9
|
|
|
9
|
-
## Demo
|
|
10
|
-
|
|
11
10
|
<a target="_blank" href="https://danielhaim1.github.io/TitleCaser/"><img src="https://raw.githubusercontent.com/danielhaim1/TitleCaser/main/docs/assets/demo.png" width="100%" height="auto" alt="TitleCaser Demo"></a>
|
|
12
11
|
|
|
13
|
-
## Table of Contents
|
|
14
|
-
|
|
15
12
|
- [TitleCaser](#titlecaser)
|
|
16
13
|
* [Demo](https://danielhaim1.github.io/TitleCaser/)
|
|
17
14
|
* [CodePen Demo 1](https://codepen.io/danielhaim/pen/oNQgjBv)
|
|
@@ -35,7 +32,8 @@ Transform any text to proper title case format using popular style guides such a
|
|
|
35
32
|
* [Resources](#resources)
|
|
36
33
|
* [Report Bugs](#report-bugs)
|
|
37
34
|
|
|
38
|
-
|
|
35
|
+
Overview
|
|
36
|
+
--------
|
|
39
37
|
|
|
40
38
|
The comprehensive Language Conventions and Style Library is specifically designed to assist web content developers in adhering to the latest style guides and English language conventions. This all-inclusive library has various features, including support for numerous style guides such as AP, APA, Chicago, NY Times, Wikipedia, and British styles and customizable preferences to tailor to individual needs. TitleCaser is a component of this library, and LCSL is set to be open-sourced by the end of 2023
|
|
41
39
|
|
|
@@ -45,7 +43,7 @@ The module has been designed to handle various capitalization scenarios, includi
|
|
|
45
43
|
|
|
46
44
|
Whether you're developing web content for a major news organization or simply looking to improve your writing skills, this module is an essential tool that can help ensure your work is accurate, consistent, and conforms to the latest style guidelines.
|
|
47
45
|
|
|
48
|
-
|
|
46
|
+
### Key Features: ###
|
|
49
47
|
|
|
50
48
|
- Support for popular style guides and customizable preferences
|
|
51
49
|
- Advanced capitalization handling for suffixes, prefixes, hyphenated words, and reserved words
|
|
@@ -55,14 +53,16 @@ Command-line interface for building, testing, and minimizing the module
|
|
|
55
53
|
- Pre-defined word lists for articles, conjunctions, prepositions, and non-capitalized words in titles
|
|
56
54
|
- Exclusion of common phrases from title capitalization
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
Get Started
|
|
57
|
+
-----------
|
|
58
|
+
|
|
59
59
|
You can install this module via npm:
|
|
60
60
|
|
|
61
61
|
```bash
|
|
62
|
-
|
|
62
|
+
npm i @danielhaim/titlecaser
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
### Usage ###
|
|
66
66
|
|
|
67
67
|
The package can be imported and used in both Node.js and browser environments using the following syntax:
|
|
68
68
|
|
|
@@ -81,7 +81,7 @@ const output = titleCaser.toTitleCase(input);
|
|
|
81
81
|
console.log(output); // 'The Book of Life'
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
### Usage in the Browser ###
|
|
85
85
|
|
|
86
86
|
The function can also be used in a browser environment by including the `TitleCaser.amd.js` script in your HTML file:
|
|
87
87
|
|
|
@@ -103,7 +103,7 @@ const output = input.toTitleCase(options);
|
|
|
103
103
|
console.log(output); // The Future of DevOps: The Next Era
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
### Example 2
|
|
106
|
+
### Example 2 ###
|
|
107
107
|
|
|
108
108
|
```html
|
|
109
109
|
<h2>nodejs development on aws: an in-depth tutorial on server-side javascript deployment</h2>
|
|
@@ -131,7 +131,8 @@ function applyTitleCaseToH2Elements(options = { style: "apa" }) {
|
|
|
131
131
|
applyTitleCaseToH2Elements();
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
Options
|
|
135
|
+
-------
|
|
135
136
|
|
|
136
137
|
The `{options}` parameter is an object that contains the settings for the conversion process.
|
|
137
138
|
|
|
@@ -143,7 +144,8 @@ The `{options}` parameter is an object that contains the settings for the conver
|
|
|
143
144
|
- `wordReplacementsList` is a map of terms that will be replaced during the title case conversion process.
|
|
144
145
|
- `smartQuotes` boolean value that determines whether quotes should be replaced with smart quotes.
|
|
145
146
|
|
|
146
|
-
|
|
147
|
+
Methods
|
|
148
|
+
-------
|
|
147
149
|
|
|
148
150
|
- `setReplaceTerms(terms)`: Updates the `wordReplacementsList` with new term-replacement pairs. It accepts an array of objects, each containing a single key-value pair representing the term and its replacement.
|
|
149
151
|
- `removeReplaceTerm(term)`: Removes a replaced term from the `wordReplacementsList` array in the option object of the `TitleCaser` instance. Throws an error if the term is not found in the array, otherwise removes it from the array and updates the option object.
|
|
@@ -152,11 +154,12 @@ The `{options}` parameter is an object that contains the settings for the conver
|
|
|
152
154
|
- `setStyle(style: string)`: Sets the style option in the object of the TitleCaser instance. The method takes a string argument style that specifies the style to use for the title casing. If the argument is not a string, the method throws a TypeError. Otherwise, it updates the style option in the object.
|
|
153
155
|
- `smartQuotes(smartQuotes: boolean)`: Specifies whether to replace straight quotes with smart quotes during title casing. Provide a boolean argument smartQuotes to enable or disable this feature.
|
|
154
156
|
|
|
155
|
-
|
|
157
|
+
Examples
|
|
158
|
+
--------
|
|
156
159
|
|
|
157
160
|
The example below demonstrates how to use the TitleCaser class to convert a string to title case with custom options.
|
|
158
161
|
|
|
159
|
-
### Customizing Word Replacements Method
|
|
162
|
+
### Customizing Word Replacements Method ###
|
|
160
163
|
|
|
161
164
|
In the example below, we create a new instance of the `TitleCaser` class with the `APA` style option. We then set multiple replacement terms using two separate calls to the `setReplaceTerms()` method. Descriptive variable names are used for the input string and expected output. We call `toTitleCase()` to convert the input string to a title case.
|
|
162
165
|
|
|
@@ -184,7 +187,7 @@ const expectedOutput = "Hello World, Replace Me!";
|
|
|
184
187
|
const outputString = titleCaser.toTitleCase(inputString);
|
|
185
188
|
```
|
|
186
189
|
|
|
187
|
-
### Customizing TitleCaser
|
|
190
|
+
### Customizing TitleCaser ###
|
|
188
191
|
|
|
189
192
|
The example below demonstrates how to use the TitleCaser class to convert a string to a title case with specific settings.
|
|
190
193
|
|
|
@@ -214,7 +217,7 @@ const expectedOutput = "The Basics of Node.js Development with MongoDB";
|
|
|
214
217
|
const actualOutput = titleCaser.toTitleCase(input);
|
|
215
218
|
```
|
|
216
219
|
|
|
217
|
-
### TitleCaser with Default Word Replacement
|
|
220
|
+
### TitleCaser with Default Word Replacement ###
|
|
218
221
|
|
|
219
222
|
The example below demonstrates how to use the TitleCaser class to convert a string to a title case with AP style formatting, including hyphenated words and word/brand replacement.
|
|
220
223
|
|
|
@@ -234,7 +237,7 @@ const expectedOutput = 'Node.js Development on AWS: An In-depth Tutorial on Serv
|
|
|
234
237
|
const actualOutput = titleCaser.toTitleCase(input);
|
|
235
238
|
```
|
|
236
239
|
|
|
237
|
-
### TitleCaser with Possessive Noun and a Colon
|
|
240
|
+
### TitleCaser with Possessive Noun and a Colon ###
|
|
238
241
|
|
|
239
242
|
The example below demonstrates how to use the TitleCaser class to convert a string to title case with AP style formatting, including a possessive noun and a colon.
|
|
240
243
|
|
|
@@ -254,7 +257,7 @@ const expectedOutput = "The iPhone's Impact on Modern Communication: A Socioling
|
|
|
254
257
|
const actualOutput = titleCaser.toTitleCase(input);
|
|
255
258
|
```
|
|
256
259
|
|
|
257
|
-
### TitleCaser with Smart Quotes
|
|
260
|
+
### TitleCaser with Smart Quotes ###
|
|
258
261
|
|
|
259
262
|
The example below demonstrates how to use the TitleCaser with smart quotes.
|
|
260
263
|
|
|
@@ -277,19 +280,21 @@ const expectedOutput = '“Never Underestimate the Power O’ Persistence,”';
|
|
|
277
280
|
const actualOutput = titleCaser.toTitleCase(input);
|
|
278
281
|
```
|
|
279
282
|
|
|
280
|
-
|
|
283
|
+
Build Process
|
|
284
|
+
-------------
|
|
281
285
|
|
|
282
286
|
```bash
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
+
npm run build-package
|
|
288
|
+
npm run build-docs
|
|
289
|
+
npm run copy-package-to-docs
|
|
290
|
+
npm run test
|
|
287
291
|
```
|
|
288
292
|
|
|
289
|
-
|
|
293
|
+
Test
|
|
294
|
+
----
|
|
290
295
|
|
|
291
296
|
```bash
|
|
292
|
-
|
|
297
|
+
npm run test
|
|
293
298
|
```
|
|
294
299
|
|
|
295
300
|
```bash
|
|
@@ -355,7 +360,8 @@ Test Reserved Words
|
|
|
355
360
|
✓ Untrimmed white spaces
|
|
356
361
|
```
|
|
357
362
|
|
|
358
|
-
|
|
363
|
+
Resources
|
|
364
|
+
---------
|
|
359
365
|
|
|
360
366
|
Useful materials for improving your knowledge of writing and language style guides. These resources include various books and manuals, such as the Publication Manual of the American Psychological Association, the Chicago Manual of Style, and the AP Stylebook, which are widely recognized as authoritative sources on grammar, punctuation, and capitalization rules.
|
|
361
367
|
|
|
@@ -368,7 +374,8 @@ Useful materials for improving your knowledge of writing and language style guid
|
|
|
368
374
|
- [Wikipedia: Letter case](https://chat.openai.com/chat/643828ec-d4b5-4f21-b035-62946dd2cec3#:~:text=Wikipedia%3A%20Letter%20case)
|
|
369
375
|
- [Wikipedia:Manual of Style/Titles of works](https://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Titles_of_works#Capital_letters)
|
|
370
376
|
|
|
371
|
-
|
|
377
|
+
Report Bugs
|
|
378
|
+
-----------
|
|
372
379
|
|
|
373
380
|
If you encounter any bugs or issues while using the library or the demo page, please report them by opening a new issue in the repository's issue tracker.
|
|
374
381
|
|
package/index.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
// src/index.js
|
|
2
|
-
|
|
3
|
-
// Import the TitleCaser class from the file src/TitleCaser.js.
|
|
4
1
|
import { TitleCaser } from './src/TitleCaser.js';
|
|
5
2
|
|
|
6
|
-
// Add a new method to the String prototype. This method will be available
|
|
7
|
-
// to all string objects. This is the method that will be used to convert
|
|
8
|
-
// a string to title case.
|
|
9
3
|
if ( String.prototype.toTitleCase === undefined ) {
|
|
10
4
|
String.prototype.toTitleCase = function ( options ) {
|
|
11
5
|
const titleCaser = new TitleCaser ( options );
|
|
@@ -13,12 +7,12 @@ if ( String.prototype.toTitleCase === undefined ) {
|
|
|
13
7
|
};
|
|
14
8
|
}
|
|
15
9
|
|
|
16
|
-
//
|
|
10
|
+
// Export for Node.js environment
|
|
17
11
|
if ( typeof module === 'object' && module.exports ) {
|
|
18
12
|
module.exports = { TitleCaser };
|
|
19
13
|
}
|
|
20
14
|
|
|
21
|
-
//
|
|
15
|
+
// Export for web environment
|
|
22
16
|
if ( typeof window !== 'undefined' && window.document ) {
|
|
23
17
|
window.TitleCaser = TitleCaser;
|
|
24
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielhaim/titlecaser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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",
|
|
@@ -44,11 +44,12 @@
|
|
|
44
44
|
],
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build-docs": "cd docs && bundle install && bundle exec jekyll build",
|
|
47
|
-
"build": "npx webpack --mode production",
|
|
48
|
-
"copy-package-to-docs": "cp -R dist/ docs/assets/js",
|
|
47
|
+
"build": "npx webpack --mode production && cp -R dist/ docs/assets/js",
|
|
49
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
|
+
"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
|
+
"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",
|
|
50
51
|
"test": "jest",
|
|
51
|
-
"tree": "tree -a -I 'node_modules|.git'"
|
|
52
|
+
"tree": "tree -a -I 'node_modules|.git|.DS_Store'"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@babel/cli": "^7.21.5",
|
|
@@ -62,15 +63,15 @@
|
|
|
62
63
|
"babel-jest": "^29.5.0",
|
|
63
64
|
"babel-loader": "^9.1.2",
|
|
64
65
|
"esbuild-jest": "^0.5.0",
|
|
65
|
-
"exports-loader": "^
|
|
66
|
+
"exports-loader": "^5.0.0",
|
|
66
67
|
"jest": "^29.7.0",
|
|
67
68
|
"jest-environment-jsdom": "^29.5.0",
|
|
68
69
|
"jest-environment-puppeteer": "^9.0.0",
|
|
69
70
|
"jest-puppeteer": "^9.0.0",
|
|
70
|
-
"puppeteer": "^21.
|
|
71
|
-
"puppeteer-core": "^21.
|
|
71
|
+
"puppeteer": "^21.9.0",
|
|
72
|
+
"puppeteer-core": "^21.9.0",
|
|
72
73
|
"terser-webpack-plugin": "^5.3.9",
|
|
73
|
-
"webpack": "^5.
|
|
74
|
+
"webpack": "^5.90.0",
|
|
74
75
|
"webpack-cli": "^5.1.4",
|
|
75
76
|
"webpack-node-externals": "^3.0.0"
|
|
76
77
|
},
|
package/src/TitleCaserConsts.js
CHANGED
|
@@ -134,6 +134,8 @@ export const titleCaseDefaultOptionsList = Object.freeze({
|
|
|
134
134
|
export const ignoredWordList = [];
|
|
135
135
|
export const correctPhraseCasingList = {
|
|
136
136
|
'the cybersmile foundation': 'The Cybersmile Foundation',
|
|
137
|
-
'co. by colgate': 'CO. by Colgate'
|
|
137
|
+
'co. by colgate': 'CO. by Colgate',
|
|
138
|
+
"on & off": 'On & Off',
|
|
139
|
+
"on and off": 'On and Off'
|
|
138
140
|
};
|
|
139
141
|
|