author | ymh <ymh.work@gmail.com> |
Mon, 08 Sep 2025 19:44:41 +0200 | |
changeset 23 | 417f20492bf7 |
parent 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1 |
/******/ (() => { // webpackBootstrap |
19 | 2 |
/******/ "use strict"; |
3 |
/******/ // The require scope |
|
4 |
/******/ var __webpack_require__ = {}; |
|
5 |
/******/ |
|
6 |
/************************************************************************/ |
|
7 |
/******/ /* webpack/runtime/define property getters */ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
8 |
/******/ (() => { |
19 | 9 |
/******/ // define getter functions for harmony exports |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
10 |
/******/ __webpack_require__.d = (exports, definition) => { |
19 | 11 |
/******/ for(var key in definition) { |
12 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
|
13 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
|
14 |
/******/ } |
|
15 |
/******/ } |
|
9 | 16 |
/******/ }; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
17 |
/******/ })(); |
19 | 18 |
/******/ |
19 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
20 |
/******/ (() => { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
21 |
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
22 |
/******/ })(); |
19 | 23 |
/******/ |
24 |
/******/ /* webpack/runtime/make namespace object */ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
25 |
/******/ (() => { |
19 | 26 |
/******/ // define __esModule on exports |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
27 |
/******/ __webpack_require__.r = (exports) => { |
19 | 28 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
29 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
30 |
/******/ } |
|
31 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
32 |
/******/ }; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
33 |
/******/ })(); |
19 | 34 |
/******/ |
9 | 35 |
/************************************************************************/ |
19 | 36 |
var __webpack_exports__ = {}; |
16 | 37 |
// ESM COMPAT FLAG |
9 | 38 |
__webpack_require__.r(__webpack_exports__); |
39 |
||
16 | 40 |
// EXPORTS |
19 | 41 |
__webpack_require__.d(__webpack_exports__, { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
42 |
count: () => (/* binding */ count) |
19 | 43 |
}); |
16 | 44 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
45 |
;// ./node_modules/@wordpress/wordcount/build-module/defaultSettings.js |
18 | 46 |
/** @typedef {import('./index').WPWordCountStrategy} WPWordCountStrategy */ |
47 |
||
48 |
/** @typedef {Partial<{type: WPWordCountStrategy, shortcodes: string[]}>} WPWordCountL10n */ |
|
49 |
||
50 |
/** |
|
51 |
* @typedef WPWordCountSettingsFields |
|
52 |
* @property {RegExp} HTMLRegExp Regular expression that matches HTML tags |
|
53 |
* @property {RegExp} HTMLcommentRegExp Regular expression that matches HTML comments |
|
54 |
* @property {RegExp} spaceRegExp Regular expression that matches spaces in HTML |
|
55 |
* @property {RegExp} HTMLEntityRegExp Regular expression that matches HTML entities |
|
56 |
* @property {RegExp} connectorRegExp Regular expression that matches word connectors, like em-dash |
|
57 |
* @property {RegExp} removeRegExp Regular expression that matches various characters to be removed when counting |
|
58 |
* @property {RegExp} astralRegExp Regular expression that matches astral UTF-16 code points |
|
59 |
* @property {RegExp} wordsRegExp Regular expression that matches words |
|
60 |
* @property {RegExp} characters_excluding_spacesRegExp Regular expression that matches characters excluding spaces |
|
61 |
* @property {RegExp} characters_including_spacesRegExp Regular expression that matches characters including spaces |
|
62 |
* @property {RegExp} shortcodesRegExp Regular expression that matches WordPress shortcodes |
|
63 |
* @property {string[]} shortcodes List of all shortcodes |
|
64 |
* @property {WPWordCountStrategy} type Describes what and how are we counting |
|
65 |
* @property {WPWordCountL10n} l10n Object with human translations |
|
66 |
*/ |
|
67 |
||
68 |
/** |
|
69 |
* Lower-level settings for word counting that can be overridden. |
|
70 |
* |
|
71 |
* @typedef {Partial<WPWordCountSettingsFields>} WPWordCountUserSettings |
|
72 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
73 |
|
18 | 74 |
// Disable reason: JSDoc linter doesn't seem to parse the union (`&`) correctly: https://github.com/jsdoc/jsdoc/issues/1285 |
75 |
/* eslint-disable jsdoc/valid-types */ |
|
76 |
/** |
|
77 |
* Word counting settings that include non-optional values we set if missing |
|
78 |
* |
|
79 |
* @typedef {WPWordCountUserSettings & typeof defaultSettings} WPWordCountDefaultSettings |
|
80 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
81 |
/* eslint-enable jsdoc/valid-types */ |
18 | 82 |
|
83 |
const defaultSettings = { |
|
9 | 84 |
HTMLRegExp: /<\/?[a-z][^>]*?>/gi, |
85 |
HTMLcommentRegExp: /<!--[\s\S]*?-->/g, |
|
86 |
spaceRegExp: / | /gi, |
|
87 |
HTMLEntityRegExp: /&\S+?;/g, |
|
19 | 88 |
// \u2014 = em-dash. |
9 | 89 |
connectorRegExp: /--|\u2014/g, |
90 |
// Characters to be removed from input text. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
91 |
removeRegExp: new RegExp(['[', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
92 |
// Basic Latin (extract) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
93 |
'\u0021-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
94 |
// Latin-1 Supplement (extract) |
18 | 95 |
'\u0080-\u00BF\u00D7\u00F7', |
9 | 96 |
/* |
97 |
* The following range consists of: |
|
98 |
* General Punctuation |
|
99 |
* Superscripts and Subscripts |
|
100 |
* Currency Symbols |
|
101 |
* Combining Diacritical Marks for Symbols |
|
102 |
* Letterlike Symbols |
|
103 |
* Number Forms |
|
104 |
* Arrows |
|
105 |
* Mathematical Operators |
|
106 |
* Miscellaneous Technical |
|
107 |
* Control Pictures |
|
108 |
* Optical Character Recognition |
|
109 |
* Enclosed Alphanumerics |
|
110 |
* Box Drawing |
|
111 |
* Block Elements |
|
112 |
* Geometric Shapes |
|
113 |
* Miscellaneous Symbols |
|
114 |
* Dingbats |
|
115 |
* Miscellaneous Mathematical Symbols-A |
|
116 |
* Supplemental Arrows-A |
|
117 |
* Braille Patterns |
|
118 |
* Supplemental Arrows-B |
|
119 |
* Miscellaneous Mathematical Symbols-B |
|
120 |
* Supplemental Mathematical Operators |
|
121 |
* Miscellaneous Symbols and Arrows |
|
122 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
123 |
'\u2000-\u2BFF', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
124 |
// Supplemental Punctuation. |
18 | 125 |
'\u2E00-\u2E7F', ']'].join(''), 'g'), |
9 | 126 |
// Remove UTF-16 surrogate points, see https://en.wikipedia.org/wiki/UTF-16#U.2BD800_to_U.2BDFFF |
127 |
astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, |
|
128 |
wordsRegExp: /\S\s+/g, |
|
129 |
characters_excluding_spacesRegExp: /\S/g, |
|
130 |
/* |
|
131 |
* Match anything that is not a formatting character, excluding: |
|
132 |
* \f = form feed |
|
133 |
* \n = new line |
|
134 |
* \r = carriage return |
|
135 |
* \t = tab |
|
136 |
* \v = vertical tab |
|
137 |
* \u00AD = soft hyphen |
|
138 |
* \u2028 = line separator |
|
139 |
* \u2029 = paragraph separator |
|
140 |
*/ |
|
141 |
characters_including_spacesRegExp: /[^\f\n\r\t\v\u00AD\u2028\u2029]/g, |
|
142 |
l10n: { |
|
143 |
type: 'words' |
|
144 |
} |
|
145 |
}; |
|
146 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
147 |
;// ./node_modules/@wordpress/wordcount/build-module/stripTags.js |
9 | 148 |
/** |
149 |
* Replaces items matched in the regex with new line |
|
150 |
* |
|
18 | 151 |
* @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
152 |
* @param {string} text The string being counted. |
|
9 | 153 |
* |
154 |
* @return {string} The manipulated text. |
|
155 |
*/ |
|
16 | 156 |
function stripTags(settings, text) { |
18 | 157 |
return text.replace(settings.HTMLRegExp, '\n'); |
16 | 158 |
} |
9 | 159 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
160 |
;// ./node_modules/@wordpress/wordcount/build-module/transposeAstralsToCountableChar.js |
9 | 161 |
/** |
162 |
* Replaces items matched in the regex with character. |
|
163 |
* |
|
18 | 164 |
* @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
165 |
* @param {string} text The string being counted. |
|
9 | 166 |
* |
167 |
* @return {string} The manipulated text. |
|
168 |
*/ |
|
16 | 169 |
function transposeAstralsToCountableChar(settings, text) { |
18 | 170 |
return text.replace(settings.astralRegExp, 'a'); |
16 | 171 |
} |
9 | 172 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
173 |
;// ./node_modules/@wordpress/wordcount/build-module/stripHTMLEntities.js |
9 | 174 |
/** |
175 |
* Removes items matched in the regex. |
|
176 |
* |
|
18 | 177 |
* @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
178 |
* @param {string} text The string being counted. |
|
9 | 179 |
* |
180 |
* @return {string} The manipulated text. |
|
181 |
*/ |
|
16 | 182 |
function stripHTMLEntities(settings, text) { |
18 | 183 |
return text.replace(settings.HTMLEntityRegExp, ''); |
16 | 184 |
} |
9 | 185 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
186 |
;// ./node_modules/@wordpress/wordcount/build-module/stripConnectors.js |
9 | 187 |
/** |
188 |
* Replaces items matched in the regex with spaces. |
|
189 |
* |
|
18 | 190 |
* @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
191 |
* @param {string} text The string being counted. |
|
9 | 192 |
* |
193 |
* @return {string} The manipulated text. |
|
194 |
*/ |
|
16 | 195 |
function stripConnectors(settings, text) { |
18 | 196 |
return text.replace(settings.connectorRegExp, ' '); |
16 | 197 |
} |
9 | 198 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
199 |
;// ./node_modules/@wordpress/wordcount/build-module/stripRemovables.js |
9 | 200 |
/** |
201 |
* Removes items matched in the regex. |
|
202 |
* |
|
18 | 203 |
* @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
204 |
* @param {string} text The string being counted. |
|
9 | 205 |
* |
206 |
* @return {string} The manipulated text. |
|
207 |
*/ |
|
16 | 208 |
function stripRemovables(settings, text) { |
18 | 209 |
return text.replace(settings.removeRegExp, ''); |
16 | 210 |
} |
9 | 211 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
212 |
;// ./node_modules/@wordpress/wordcount/build-module/stripHTMLComments.js |
9 | 213 |
/** |
214 |
* Removes items matched in the regex. |
|
215 |
* |
|
18 | 216 |
* @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
217 |
* @param {string} text The string being counted. |
|
9 | 218 |
* |
219 |
* @return {string} The manipulated text. |
|
220 |
*/ |
|
16 | 221 |
function stripHTMLComments(settings, text) { |
18 | 222 |
return text.replace(settings.HTMLcommentRegExp, ''); |
16 | 223 |
} |
9 | 224 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
225 |
;// ./node_modules/@wordpress/wordcount/build-module/stripShortcodes.js |
9 | 226 |
/** |
227 |
* Replaces items matched in the regex with a new line. |
|
228 |
* |
|
18 | 229 |
* @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
230 |
* @param {string} text The string being counted. |
|
9 | 231 |
* |
232 |
* @return {string} The manipulated text. |
|
233 |
*/ |
|
16 | 234 |
function stripShortcodes(settings, text) { |
9 | 235 |
if (settings.shortcodesRegExp) { |
236 |
return text.replace(settings.shortcodesRegExp, '\n'); |
|
237 |
} |
|
238 |
return text; |
|
16 | 239 |
} |
9 | 240 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
241 |
;// ./node_modules/@wordpress/wordcount/build-module/stripSpaces.js |
9 | 242 |
/** |
243 |
* Replaces items matched in the regex with spaces. |
|
244 |
* |
|
18 | 245 |
* @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
246 |
* @param {string} text The string being counted. |
|
9 | 247 |
* |
248 |
* @return {string} The manipulated text. |
|
249 |
*/ |
|
16 | 250 |
function stripSpaces(settings, text) { |
18 | 251 |
return text.replace(settings.spaceRegExp, ' '); |
16 | 252 |
} |
9 | 253 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
254 |
;// ./node_modules/@wordpress/wordcount/build-module/transposeHTMLEntitiesToCountableChars.js |
9 | 255 |
/** |
256 |
* Replaces items matched in the regex with a single character. |
|
257 |
* |
|
18 | 258 |
* @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
259 |
* @param {string} text The string being counted. |
|
9 | 260 |
* |
261 |
* @return {string} The manipulated text. |
|
262 |
*/ |
|
16 | 263 |
function transposeHTMLEntitiesToCountableChars(settings, text) { |
18 | 264 |
return text.replace(settings.HTMLEntityRegExp, 'a'); |
16 | 265 |
} |
9 | 266 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
267 |
;// ./node_modules/@wordpress/wordcount/build-module/index.js |
9 | 268 |
/** |
269 |
* Internal dependencies |
|
270 |
*/ |
|
271 |
||
272 |
||
273 |
||
274 |
||
275 |
||
276 |
||
277 |
||
278 |
||
279 |
||
280 |
||
281 |
||
282 |
/** |
|
18 | 283 |
* @typedef {import('./defaultSettings').WPWordCountDefaultSettings} WPWordCountSettings |
284 |
* @typedef {import('./defaultSettings').WPWordCountUserSettings} WPWordCountUserSettings |
|
285 |
*/ |
|
286 |
||
287 |
/** |
|
288 |
* Possible ways of counting. |
|
289 |
* |
|
290 |
* @typedef {'words'|'characters_excluding_spaces'|'characters_including_spaces'} WPWordCountStrategy |
|
291 |
*/ |
|
292 |
||
293 |
/** |
|
9 | 294 |
* Private function to manage the settings. |
295 |
* |
|
18 | 296 |
* @param {WPWordCountStrategy} type The type of count to be done. |
297 |
* @param {WPWordCountUserSettings} userSettings Custom settings for the count. |
|
9 | 298 |
* |
18 | 299 |
* @return {WPWordCountSettings} The combined settings object to be used. |
9 | 300 |
*/ |
301 |
function loadSettings(type, userSettings) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
302 |
var _settings$l10n$shortc; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
303 |
const settings = Object.assign({}, defaultSettings, userSettings); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
304 |
settings.shortcodes = (_settings$l10n$shortc = settings.l10n?.shortcodes) !== null && _settings$l10n$shortc !== void 0 ? _settings$l10n$shortc : []; |
9 | 305 |
if (settings.shortcodes && settings.shortcodes.length) { |
306 |
settings.shortcodesRegExp = new RegExp('\\[\\/?(?:' + settings.shortcodes.join('|') + ')[^\\]]*?\\]', 'g'); |
|
307 |
} |
|
18 | 308 |
settings.type = type; |
9 | 309 |
if (settings.type !== 'characters_excluding_spaces' && settings.type !== 'characters_including_spaces') { |
310 |
settings.type = 'words'; |
|
311 |
} |
|
312 |
return settings; |
|
313 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
314 |
|
9 | 315 |
/** |
18 | 316 |
* Count the words in text |
9 | 317 |
* |
18 | 318 |
* @param {string} text The text being processed |
319 |
* @param {RegExp} regex The regular expression pattern being matched |
|
320 |
* @param {WPWordCountSettings} settings Settings object containing regular expressions for each strip function |
|
9 | 321 |
* |
18 | 322 |
* @return {number} Count of words. |
9 | 323 |
*/ |
18 | 324 |
function countWords(text, regex, settings) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
325 |
var _text$match$length; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
326 |
text = [stripTags.bind(null, settings), stripHTMLComments.bind(null, settings), stripShortcodes.bind(null, settings), stripSpaces.bind(null, settings), stripHTMLEntities.bind(null, settings), stripConnectors.bind(null, settings), stripRemovables.bind(null, settings)].reduce((result, fn) => fn(result), text); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
327 |
text = text + '\n'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
328 |
return (_text$match$length = text.match(regex)?.length) !== null && _text$match$length !== void 0 ? _text$match$length : 0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
329 |
} |
18 | 330 |
|
9 | 331 |
/** |
18 | 332 |
* Count the characters in text |
9 | 333 |
* |
18 | 334 |
* @param {string} text The text being processed |
335 |
* @param {RegExp} regex The regular expression pattern being matched |
|
336 |
* @param {WPWordCountSettings} settings Settings object containing regular expressions for each strip function |
|
9 | 337 |
* |
18 | 338 |
* @return {number} Count of characters. |
9 | 339 |
*/ |
18 | 340 |
function countCharacters(text, regex, settings) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
341 |
var _text$match$length2; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
342 |
text = [stripTags.bind(null, settings), stripHTMLComments.bind(null, settings), stripShortcodes.bind(null, settings), transposeAstralsToCountableChar.bind(null, settings), stripSpaces.bind(null, settings), transposeHTMLEntitiesToCountableChars.bind(null, settings)].reduce((result, fn) => fn(result), text); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
343 |
text = text + '\n'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
344 |
return (_text$match$length2 = text.match(regex)?.length) !== null && _text$match$length2 !== void 0 ? _text$match$length2 : 0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
345 |
} |
18 | 346 |
|
9 | 347 |
/** |
348 |
* Count some words. |
|
349 |
* |
|
18 | 350 |
* @param {string} text The text being processed |
351 |
* @param {WPWordCountStrategy} type The type of count. Accepts 'words', 'characters_excluding_spaces', or 'characters_including_spaces'. |
|
352 |
* @param {WPWordCountUserSettings} userSettings Custom settings object. |
|
9 | 353 |
* |
354 |
* @example |
|
355 |
* ```js |
|
356 |
* import { count } from '@wordpress/wordcount'; |
|
357 |
* const numberOfWords = count( 'Words to count', 'words', {} ) |
|
358 |
* ``` |
|
359 |
* |
|
16 | 360 |
* @return {number} The word or character count. |
9 | 361 |
*/ |
362 |
function count(text, type, userSettings) { |
|
18 | 363 |
const settings = loadSettings(type, userSettings); |
364 |
let matchRegExp; |
|
365 |
switch (settings.type) { |
|
366 |
case 'words': |
|
367 |
matchRegExp = settings.wordsRegExp; |
|
368 |
return countWords(text, matchRegExp, settings); |
|
369 |
case 'characters_including_spaces': |
|
370 |
matchRegExp = settings.characters_including_spacesRegExp; |
|
371 |
return countCharacters(text, matchRegExp, settings); |
|
372 |
case 'characters_excluding_spaces': |
|
373 |
matchRegExp = settings.characters_excluding_spacesRegExp; |
|
374 |
return countCharacters(text, matchRegExp, settings); |
|
375 |
default: |
|
376 |
return 0; |
|
9 | 377 |
} |
378 |
} |
|
379 |
||
19 | 380 |
(window.wp = window.wp || {}).wordcount = __webpack_exports__; |
381 |
/******/ })() |
|
382 |
; |