string-remove-widows 3.0.6 → 3.0.12

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-2021 Roy Revelt and other contributors
3
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -26,18 +26,17 @@
26
26
 
27
27
  ## Install
28
28
 
29
- This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
29
+ The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `2.1.0`.
30
30
 
31
31
  ```bash
32
32
  npm i string-remove-widows
33
33
  ```
34
34
 
35
- If you need a legacy version which works with `require`, use version 2.1.0
36
-
37
35
  ## Quick Take
38
36
 
39
37
  ```js
40
38
  import { strict as assert } from "assert";
39
+
41
40
  import { removeWidows } from "string-remove-widows";
42
41
 
43
42
  const { ranges, res } = removeWidows("Some text with many words on one line.");
@@ -50,7 +49,7 @@ assert.equal(res, "Some text with many words on one line.");
50
49
 
51
50
  ## Documentation
52
51
 
53
- Please [visit codsen.com](https://codsen.com/os/string-remove-widows/) for a full description of the API, examples and even a test <a href="https://codsen.com/os/string-remove-widows/play">playground</a>.
52
+ Please [visit codsen.com](https://codsen.com/os/string-remove-widows/) for a full description of the API and even a test <a href="https://codsen.com/os/string-remove-widows/play">playground</a>.
54
53
 
55
54
  ## Contributing
56
55
 
@@ -60,6 +59,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
60
59
 
61
60
  MIT License
62
61
 
63
- Copyright (c) 2010-2021 Roy Revelt and other contributors
62
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
64
63
 
65
64
  <img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
@@ -1,588 +1,15 @@
1
1
  /**
2
2
  * @name string-remove-widows
3
3
  * @fileoverview Helps to prevent widow words in a text
4
- * @version 3.0.6
4
+ * @version 3.0.12
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-remove-widows/}
8
8
  */
9
9
 
10
- import { matchRightIncl } from 'string-match-left-right';
11
- import { left, right } from 'string-left-right';
12
- import { Ranges } from 'ranges-push';
13
- import { rApply } from 'ranges-apply';
14
-
15
- var version$1 = "3.0.6";
16
-
17
- const rawnbsp = "\u00A0";
18
- const encodedNbspHtml = "&nbsp;";
19
- const encodedNbspCss = "\\00A0";
20
- const encodedNbspJs = "\\u00A0";
21
- const rawNdash = "\u2013";
22
- const encodedNdashHtml = "&ndash;";
23
- const encodedNdashCss = "\\2013";
24
- const encodedNdashJs = "\\u2013";
25
- const rawMdash = "\u2014";
26
- const encodedMdashHtml = "&mdash;";
27
- const encodedMdashCss = "\\2014";
28
- const encodedMdashJs = "\\u2014";
29
- const headsAndTailsJinja = [
30
- {
31
- heads: "{{",
32
- tails: "}}",
33
- },
34
- {
35
- heads: ["{% if", "{%- if"],
36
- tails: ["{% endif", "{%- endif"],
37
- },
38
- {
39
- heads: ["{% for", "{%- for"],
40
- tails: ["{% endfor", "{%- endfor"],
41
- },
42
- {
43
- heads: ["{%", "{%-"],
44
- tails: ["%}", "-%}"],
45
- },
46
- {
47
- heads: "{#",
48
- tails: "#}",
49
- },
50
- ];
51
- const headsAndTailsHugo = [
52
- {
53
- heads: "{{",
54
- tails: "}}",
55
- },
56
- ];
57
- const headsAndTailsHexo = [
58
- {
59
- heads: ["<%", "<%=", "<%-"],
60
- tails: ["%>", "=%>", "-%>"],
61
- },
62
- ];
63
- const knownHTMLTags = [
64
- "abbr",
65
- "address",
66
- "area",
67
- "article",
68
- "aside",
69
- "audio",
70
- "base",
71
- "bdi",
72
- "bdo",
73
- "blockquote",
74
- "body",
75
- "br",
76
- "button",
77
- "canvas",
78
- "caption",
79
- "center",
80
- "cite",
81
- "code",
82
- "col",
83
- "colgroup",
84
- "data",
85
- "datalist",
86
- "dd",
87
- "del",
88
- "details",
89
- "dfn",
90
- "dialog",
91
- "div",
92
- "dl",
93
- "doctype",
94
- "dt",
95
- "em",
96
- "embed",
97
- "fieldset",
98
- "figcaption",
99
- "figure",
100
- "footer",
101
- "form",
102
- "h1",
103
- "h2",
104
- "h3",
105
- "h4",
106
- "h5",
107
- "h6",
108
- "head",
109
- "header",
110
- "hgroup",
111
- "hr",
112
- "html",
113
- "iframe",
114
- "img",
115
- "input",
116
- "ins",
117
- "kbd",
118
- "keygen",
119
- "label",
120
- "legend",
121
- "li",
122
- "link",
123
- "main",
124
- "map",
125
- "mark",
126
- "math",
127
- "menu",
128
- "menuitem",
129
- "meta",
130
- "meter",
131
- "nav",
132
- "noscript",
133
- "object",
134
- "ol",
135
- "optgroup",
136
- "option",
137
- "output",
138
- "param",
139
- "picture",
140
- "pre",
141
- "progress",
142
- "rb",
143
- "rp",
144
- "rt",
145
- "rtc",
146
- "ruby",
147
- "samp",
148
- "script",
149
- "section",
150
- "select",
151
- "slot",
152
- "small",
153
- "source",
154
- "span",
155
- "strong",
156
- "style",
157
- "sub",
158
- "summary",
159
- "sup",
160
- "svg",
161
- "table",
162
- "tbody",
163
- "td",
164
- "template",
165
- "textarea",
166
- "tfoot",
167
- "th",
168
- "thead",
169
- "time",
170
- "title",
171
- "tr",
172
- "track",
173
- "ul",
174
- "var",
175
- "video",
176
- "wbr",
177
- "xml",
178
- ];
179
-
180
- const version = version$1;
181
- const defaults = {
182
- removeWidowPreventionMeasures: false,
183
- convertEntities: true,
184
- targetLanguage: "html",
185
- UKPostcodes: false,
186
- hyphens: true,
187
- minWordCount: 4,
188
- minCharCount: 5,
189
- ignore: [],
190
- reportProgressFunc: null,
191
- reportProgressFuncFrom: 0,
192
- reportProgressFuncTo: 100,
193
- tagRanges: [],
194
- };
195
- function removeWidows(str, originalOpts) {
196
- const start = Date.now();
197
- if (typeof str !== "string") {
198
- if (str === undefined) {
199
- throw new Error("string-remove-widows: [THROW_ID_01] the first input argument is completely missing! It should be given as string.");
200
- }
201
- else {
202
- throw new Error(`string-remove-widows: [THROW_ID_02] the first input argument must be string! It was given as "${typeof str}", equal to:\n${JSON.stringify(str, null, 4)}`);
203
- }
204
- }
205
- if (originalOpts && typeof originalOpts !== "object") {
206
- throw new Error(`string-remove-widows: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof originalOpts}, equal to ${JSON.stringify(originalOpts, null, 4)}`);
207
- }
208
- const isArr = Array.isArray;
209
- const len = str.length;
210
- const rangesArr = new Ranges({ mergeType: 2 });
211
- const punctuationCharsToConsiderWidowIssue = ["."];
212
- const postcodeRegexFront = /[A-Z]{1,2}[0-9][0-9A-Z]?$/;
213
- const postcodeRegexEnd = /^[0-9][A-Z]{2}/;
214
- const leavePercForLastStage = 0.06;
215
- let currentPercentageDone;
216
- let lastPercentage = 0;
217
- let wordCount = 0;
218
- let charCount = 0;
219
- let secondToLastWhitespaceStartedAt;
220
- let secondToLastWhitespaceEndedAt;
221
- let lastWhitespaceStartedAt;
222
- let lastWhitespaceEndedAt;
223
- let lastEncodedNbspStartedAt;
224
- let lastEncodedNbspEndedAt;
225
- let doNothingUntil;
226
- let bumpWordCountAt;
227
- const opts = { ...defaults, ...originalOpts };
228
- const whatWasDone = {
229
- removeWidows: false,
230
- convertEntities: false,
231
- };
232
- if (!opts.ignore ||
233
- (!isArr(opts.ignore) && typeof opts.ignore !== "string")) {
234
- opts.ignore = [];
235
- }
236
- else {
237
- if (typeof opts.ignore === "string") {
238
- opts.ignore = [opts.ignore];
239
- }
240
- if (opts.ignore.includes("all")) {
241
- opts.ignore = opts.ignore.concat(headsAndTailsJinja.concat(headsAndTailsHexo));
242
- }
243
- else if (opts.ignore.some((val) => typeof val === "string")) {
244
- let temp = [];
245
- opts.ignore = opts.ignore.filter((val) => {
246
- if (typeof val === "string" && val.length) {
247
- if (["nunjucks", "jinja", "liquid"].includes(val.trim().toLowerCase())) {
248
- temp = temp.concat(headsAndTailsJinja);
249
- }
250
- else if (["hugo"].includes(val.trim().toLowerCase())) {
251
- temp = temp.concat(headsAndTailsHugo);
252
- }
253
- else if (["hexo"].includes(val.trim().toLowerCase())) {
254
- temp = temp.concat(headsAndTailsHexo);
255
- }
256
- return false;
257
- }
258
- if (typeof val === "object") {
259
- return true;
260
- }
261
- });
262
- if (temp.length) {
263
- opts.ignore = opts.ignore.concat(temp);
264
- }
265
- }
266
- }
267
- let ceil;
268
- if (opts.reportProgressFunc) {
269
- ceil = Math.floor(opts.reportProgressFuncTo -
270
- (opts.reportProgressFuncTo - opts.reportProgressFuncFrom) *
271
- leavePercForLastStage -
272
- opts.reportProgressFuncFrom);
273
- }
274
- function push(finalStart, finalEnd) {
275
- let finalWhatToInsert = rawnbsp;
276
- if (opts.removeWidowPreventionMeasures) {
277
- finalWhatToInsert = " ";
278
- }
279
- else if (opts.convertEntities) {
280
- finalWhatToInsert = encodedNbspHtml;
281
- if (typeof opts.targetLanguage === "string") {
282
- if (opts.targetLanguage.trim().toLowerCase() === "css") {
283
- finalWhatToInsert = encodedNbspCss;
284
- }
285
- else if (opts.targetLanguage.trim().toLowerCase() === "js") {
286
- finalWhatToInsert = encodedNbspJs;
287
- }
288
- }
289
- }
290
- if (str.slice(finalStart, finalEnd) !== finalWhatToInsert) {
291
- rangesArr.push(finalStart, finalEnd, finalWhatToInsert);
292
- }
293
- }
294
- function resetAll() {
295
- wordCount = 0;
296
- charCount = 0;
297
- secondToLastWhitespaceStartedAt = undefined;
298
- secondToLastWhitespaceEndedAt = undefined;
299
- lastWhitespaceStartedAt = undefined;
300
- lastWhitespaceEndedAt = undefined;
301
- lastEncodedNbspStartedAt = undefined;
302
- lastEncodedNbspEndedAt = undefined;
303
- }
304
- resetAll();
305
- for (let i = 0; i <= len; i++) {
306
- if (!doNothingUntil && isArr(opts.ignore) && opts.ignore.length) {
307
- opts.ignore.some((valObj, y) => {
308
- if ((isArr(valObj.heads) &&
309
- valObj.heads.some((oneOfHeads) => str.startsWith(oneOfHeads, i))) ||
310
- (typeof valObj.heads === "string" && str.startsWith(valObj.heads, i))) {
311
- wordCount += 1;
312
- doNothingUntil = opts.ignore[y].tails;
313
- return true;
314
- }
315
- });
316
- }
317
- if (!doNothingUntil && bumpWordCountAt && bumpWordCountAt === i) {
318
- wordCount += 1;
319
- bumpWordCountAt = undefined;
320
- }
321
- if (typeof opts.reportProgressFunc === "function") {
322
- currentPercentageDone =
323
- opts.reportProgressFuncFrom + Math.floor((i / len) * (ceil || 1));
324
- if (currentPercentageDone !== lastPercentage) {
325
- lastPercentage = currentPercentageDone;
326
- opts.reportProgressFunc(currentPercentageDone);
327
- }
328
- }
329
- if (!doNothingUntil &&
330
- i &&
331
- str[i] &&
332
- str[i].trim() &&
333
- (!str[i - 1] || (str[i - 1] && !str[i - 1].trim()))) {
334
- lastWhitespaceEndedAt = i;
335
- }
336
- if (!doNothingUntil && str[i] && str[i].trim()) {
337
- charCount += 1;
338
- }
339
- if (!doNothingUntil &&
340
- opts.hyphens &&
341
- (`-${rawMdash}${rawNdash}`.includes(str[i]) ||
342
- str.startsWith(encodedNdashHtml, i) ||
343
- str.startsWith(encodedNdashCss, i) ||
344
- str.startsWith(encodedNdashJs, i) ||
345
- str.startsWith(encodedMdashHtml, i) ||
346
- str.startsWith(encodedMdashCss, i) ||
347
- str.startsWith(encodedMdashJs, i)) &&
348
- str[i + 1] &&
349
- (!str[i + 1].trim() || str[i] === "&")) {
350
- if (str[i - 1] && !str[i - 1].trim() && str[left(str, i)]) {
351
- push(left(str, i) + 1, i);
352
- whatWasDone.removeWidows = true;
353
- }
354
- }
355
- if (!doNothingUntil &&
356
- (str.startsWith("&nbsp;", i) || str.startsWith("&#160;", i))) {
357
- lastEncodedNbspStartedAt = i;
358
- lastEncodedNbspEndedAt = i + 6;
359
- if (str[i + 6] && str[i + 6].trim()) {
360
- bumpWordCountAt = i + 6;
361
- }
362
- if (!opts.convertEntities) {
363
- rangesArr.push(i, i + 6, rawnbsp);
364
- whatWasDone.convertEntities = true;
365
- }
366
- else if (opts.targetLanguage === "css" ||
367
- opts.targetLanguage === "js") {
368
- rangesArr.push(i, i + 6, opts.targetLanguage === "css" ? encodedNbspCss : encodedNbspJs);
369
- whatWasDone.convertEntities = true;
370
- }
371
- }
372
- if (!doNothingUntil &&
373
- str[i + 4] &&
374
- str[i] === "\\" &&
375
- str[i + 1] === "0" &&
376
- str[i + 2] === "0" &&
377
- str[i + 3].toUpperCase() === "A" &&
378
- str[i + 4] === "0") {
379
- lastEncodedNbspStartedAt = i;
380
- lastEncodedNbspEndedAt = i + 5;
381
- if (str[i + 5] && str[i + 5].trim()) {
382
- bumpWordCountAt = i + 5;
383
- }
384
- if (!opts.convertEntities) {
385
- rangesArr.push(i, i + 5, rawnbsp);
386
- whatWasDone.convertEntities = true;
387
- }
388
- else if (opts.targetLanguage === "html" ||
389
- opts.targetLanguage === "js") {
390
- rangesArr.push(i, i + 5, opts.targetLanguage === "html" ? encodedNbspHtml : encodedNbspJs);
391
- whatWasDone.convertEntities = true;
392
- }
393
- }
394
- if (!doNothingUntil &&
395
- str[i] === "\\" &&
396
- str[i + 1] &&
397
- str[i + 1].toLowerCase() === "u" &&
398
- str[i + 2] === "0" &&
399
- str[i + 3] === "0" &&
400
- str[i + 4] &&
401
- str[i + 4].toUpperCase() === "A" &&
402
- str[i + 5] === "0") {
403
- lastEncodedNbspStartedAt = i;
404
- lastEncodedNbspEndedAt = i + 6;
405
- if (str[i + 6] && str[i + 6].trim()) {
406
- bumpWordCountAt = i + 6;
407
- }
408
- if (!opts.convertEntities) {
409
- rangesArr.push(i, i + 6, rawnbsp);
410
- }
411
- else if (opts.targetLanguage === "html" ||
412
- opts.targetLanguage === "css") {
413
- rangesArr.push(i, i + 6, opts.targetLanguage === "html" ? encodedNbspHtml : encodedNbspCss);
414
- }
415
- }
416
- if (!doNothingUntil && str[i] === rawnbsp) {
417
- lastEncodedNbspStartedAt = i;
418
- lastEncodedNbspEndedAt = i + 1;
419
- if (opts.convertEntities) {
420
- rangesArr.push(i, i + 1, opts.targetLanguage === "css"
421
- ? encodedNbspCss
422
- : opts.targetLanguage === "js"
423
- ? encodedNbspJs
424
- : encodedNbspHtml);
425
- }
426
- }
427
- if (!doNothingUntil &&
428
- str[i] &&
429
- str[i].trim() &&
430
- (!str[i - 1] || !str[i - 1].trim())) {
431
- wordCount += 1;
432
- }
433
- if (!doNothingUntil &&
434
- (!str[i] ||
435
- `\r\n`.includes(str[i]) ||
436
- ((str[i] === "\n" ||
437
- str[i] === "\r" ||
438
- (str[i] === "\r" && str[i + 1] === "\n")) &&
439
- left(str, i) &&
440
- punctuationCharsToConsiderWidowIssue.includes(str[left(str, i)])))) {
441
- if ((!opts.minWordCount || wordCount >= opts.minWordCount) &&
442
- (!opts.minCharCount || charCount >= opts.minCharCount)) {
443
- let finalStart;
444
- let finalEnd;
445
- if (lastWhitespaceStartedAt !== undefined &&
446
- lastWhitespaceEndedAt !== undefined &&
447
- lastEncodedNbspStartedAt !== undefined &&
448
- lastEncodedNbspEndedAt !== undefined) {
449
- if (lastWhitespaceStartedAt > lastEncodedNbspStartedAt) {
450
- finalStart = lastWhitespaceStartedAt;
451
- finalEnd = lastWhitespaceEndedAt;
452
- }
453
- else {
454
- finalStart = lastEncodedNbspStartedAt;
455
- finalEnd = lastEncodedNbspEndedAt;
456
- }
457
- }
458
- else if (lastWhitespaceStartedAt !== undefined &&
459
- lastWhitespaceEndedAt !== undefined) {
460
- finalStart = lastWhitespaceStartedAt;
461
- finalEnd = lastWhitespaceEndedAt;
462
- }
463
- else if (lastEncodedNbspStartedAt !== undefined &&
464
- lastEncodedNbspEndedAt !== undefined) {
465
- finalStart = lastEncodedNbspStartedAt;
466
- finalEnd = lastEncodedNbspEndedAt;
467
- }
468
- if (!(finalStart && finalEnd) &&
469
- secondToLastWhitespaceStartedAt &&
470
- secondToLastWhitespaceEndedAt) {
471
- finalStart = secondToLastWhitespaceStartedAt;
472
- finalEnd = secondToLastWhitespaceEndedAt;
473
- }
474
- if (finalStart && finalEnd) {
475
- push(finalStart, finalEnd);
476
- whatWasDone.removeWidows = true;
477
- }
478
- }
479
- resetAll();
480
- }
481
- if (opts.UKPostcodes &&
482
- str[i] &&
483
- !str[i].trim() &&
484
- str[i - 1] &&
485
- str[i - 1].trim() &&
486
- postcodeRegexFront.test(str.slice(0, i)) &&
487
- str[right(str, i)] &&
488
- postcodeRegexEnd.test(str.slice(right(str, i)))) {
489
- push(i, right(str, i));
490
- whatWasDone.removeWidows = true;
491
- }
492
- if (!doNothingUntil &&
493
- str[i] &&
494
- !str[i].trim() &&
495
- str[i - 1] &&
496
- str[i - 1].trim() &&
497
- (lastWhitespaceStartedAt === undefined ||
498
- (str[lastWhitespaceStartedAt - 1] &&
499
- str[lastWhitespaceStartedAt - 1].trim())) &&
500
- !"/>".includes(str[right(str, i)]) &&
501
- !str.slice(0, i).trim().endsWith("br") &&
502
- !str.slice(0, i).trim().endsWith("hr") &&
503
- !(str.slice(0, i).endsWith("<") &&
504
- knownHTMLTags.some((tag) => str.startsWith(tag, right(str, i))))) {
505
- secondToLastWhitespaceStartedAt = lastWhitespaceStartedAt;
506
- secondToLastWhitespaceEndedAt = lastWhitespaceEndedAt;
507
- lastWhitespaceStartedAt = i;
508
- lastWhitespaceEndedAt = undefined;
509
- if (lastEncodedNbspStartedAt !== undefined ||
510
- lastEncodedNbspEndedAt !== undefined) {
511
- lastEncodedNbspStartedAt = undefined;
512
- lastEncodedNbspEndedAt = undefined;
513
- }
514
- }
515
- let tempTailFinding;
516
- if (doNothingUntil) {
517
- if (typeof doNothingUntil === "string" &&
518
- (!doNothingUntil.length || str.startsWith(doNothingUntil, i))) {
519
- doNothingUntil = undefined;
520
- }
521
- else if (isArr(doNothingUntil) &&
522
- (!doNothingUntil.length ||
523
- doNothingUntil.some((val) => {
524
- if (str.startsWith(val, i)) {
525
- tempTailFinding = val;
526
- return true;
527
- }
528
- }))) {
529
- doNothingUntil = undefined;
530
- i += tempTailFinding.length;
531
- if (isArr(opts.ignore) && opts.ignore.length && str[i + 1]) {
532
- opts.ignore.some((oneOfHeadsTailsObjs) => {
533
- return matchRightIncl(str, i, oneOfHeadsTailsObjs.tails, {
534
- trimBeforeMatching: true,
535
- cb: (_char, _theRemainderOfTheString, index) => {
536
- if (index) {
537
- i = index - 1;
538
- if (str[i + 1] && str[i + 1].trim()) {
539
- wordCount += 1;
540
- }
541
- }
542
- return true;
543
- },
544
- });
545
- });
546
- }
547
- }
548
- }
549
- if (str[i] && `\r\n`.includes(str[i])) {
550
- wordCount = 0;
551
- charCount = 0;
552
- }
553
- if (isArr(opts.tagRanges) &&
554
- opts.tagRanges.length &&
555
- opts.tagRanges.some((rangeArr) => {
556
- if (i >= rangeArr[0] && i <= rangeArr[1] && rangeArr[1] - 1 > i) {
557
- i = rangeArr[1] - 1;
558
- return true;
559
- }
560
- })) ;
561
- }
562
- rApply(str, rangesArr.current())
563
- .split("")
564
- .forEach((key, i) => {
565
- });
566
- return {
567
- res: rApply(str, rangesArr.current(), opts.reportProgressFunc
568
- ? (incomingPerc) => {
569
- currentPercentageDone = Math.floor((opts.reportProgressFuncTo - opts.reportProgressFuncFrom) *
570
- (1 - leavePercForLastStage) +
571
- (incomingPerc / 100) *
572
- (opts.reportProgressFuncTo - opts.reportProgressFuncFrom) *
573
- leavePercForLastStage);
574
- if (currentPercentageDone !== lastPercentage) {
575
- lastPercentage = currentPercentageDone;
576
- opts.reportProgressFunc(currentPercentageDone);
577
- }
578
- }
579
- : undefined),
580
- ranges: rangesArr.current(),
581
- log: {
582
- timeTakenInMilliseconds: Date.now() - start,
583
- },
584
- whatWasDone,
585
- };
586
- }
587
-
588
- export { defaults, removeWidows, version };
10
+ import{matchRightIncl as ee}from"string-match-left-right";import{left as N,right as D}from"string-left-right";import{Ranges as te}from"ranges-push";import{rApply as K}from"ranges-apply";var M="3.0.12";var h="\xA0",E="&nbsp;",S="\\00A0",w="\\u00A0",O="\u2013",J="&ndash;",U="\\2013",x="\\u2013",k="\u2014",I="&mdash;",B="\\2014",_="\\u2014",v=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],q=[{heads:"{{",tails:"}}"}],P=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],G=["abbr","address","area","article","aside","audio","base","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","param","picture","pre","progress","rb","rp","rt","rtc","ruby","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","var","video","wbr","xml"];var $e=M,ne={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};function ce(t,f){let Z=Date.now();if(typeof t!="string")throw t===void 0?new Error("string-remove-widows: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`string-remove-widows: [THROW_ID_02] the first input argument must be string! It was given as "${typeof t}", equal to:
11
+ ${JSON.stringify(t,null,4)}`);if(f&&typeof f!="object")throw new Error(`string-remove-widows: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof f}, equal to ${JSON.stringify(f,null,4)}`);let b=Array.isArray,L=t.length,a=new te({mergeType:2}),Y=["."],z=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,Q=/^[0-9][A-Z]{2}/,V=.06,$,A=0,g=0,W=0,y,T,d,c,r,u,s,p,n={...ne,...f},m={removeWidows:!1,convertEntities:!1};if(!n.ignore||!b(n.ignore)&&typeof n.ignore!="string")n.ignore=[];else if(typeof n.ignore=="string"&&(n.ignore=[n.ignore]),n.ignore.includes("all"))n.ignore=n.ignore.concat(v.concat(P));else if(n.ignore.some(e=>typeof e=="string")){let e=[];n.ignore=n.ignore.filter(i=>typeof i=="string"&&i.length?(["nunjucks","jinja","liquid"].includes(i.trim().toLowerCase())?e=e.concat(v):["hugo"].includes(i.trim().toLowerCase())?e=e.concat(q):["hexo"].includes(i.trim().toLowerCase())&&(e=e.concat(P)),!1):typeof i=="object"),e.length&&(n.ignore=n.ignore.concat(e))}let H;n.reportProgressFunc&&(H=Math.floor(n.reportProgressFuncTo-(n.reportProgressFuncTo-n.reportProgressFuncFrom)*V-n.reportProgressFuncFrom));function C(e,i){let o=h;n.removeWidowPreventionMeasures?o=" ":n.convertEntities&&(o=E,typeof n.targetLanguage=="string"&&(n.targetLanguage.trim().toLowerCase()==="css"?o=S:n.targetLanguage.trim().toLowerCase()==="js"&&(o=w))),t.slice(e,i)!==o&&a.push(e,i,o)}function F(){g=0,W=0,y=void 0,T=void 0,d=void 0,c=void 0,r=void 0,u=void 0}F();for(let e=0;e<=L;e++){if(!s&&b(n.ignore)&&n.ignore.length&&n.ignore.some((o,l)=>{if(b(o.heads)&&o.heads.some(R=>t.startsWith(R,e))||typeof o.heads=="string"&&t.startsWith(o.heads,e))return g+=1,s=n.ignore[l].tails,!0}),!s&&p&&p===e&&(g+=1,p=void 0),typeof n.reportProgressFunc=="function"&&($=n.reportProgressFuncFrom+Math.floor(e/L*(H||1)),$!==A&&(A=$,n.reportProgressFunc($))),!s&&e&&t[e]&&t[e].trim()&&(!t[e-1]||t[e-1]&&!t[e-1].trim())&&(c=e),!s&&t[e]&&t[e].trim()&&(W+=1),!s&&n.hyphens&&(`-${k}${O}`.includes(t[e])||t.startsWith(J,e)||t.startsWith(U,e)||t.startsWith(x,e)||t.startsWith(I,e)||t.startsWith(B,e)||t.startsWith(_,e))&&t[e+1]&&(!t[e+1].trim()||t[e]==="&")&&t[e-1]&&!t[e-1].trim()&&t[N(t,e)]&&(C(N(t,e)+1,e),m.removeWidows=!0),!s&&(t.startsWith("&nbsp;",e)||t.startsWith("&#160;",e))&&(r=e,u=e+6,t[e+6]&&t[e+6].trim()&&(p=e+6),n.convertEntities?(n.targetLanguage==="css"||n.targetLanguage==="js")&&(a.push(e,e+6,n.targetLanguage==="css"?S:w),m.convertEntities=!0):(a.push(e,e+6,h),m.convertEntities=!0)),!s&&t[e+4]&&t[e]==="\\"&&t[e+1]==="0"&&t[e+2]==="0"&&t[e+3].toUpperCase()==="A"&&t[e+4]==="0"&&(r=e,u=e+5,t[e+5]&&t[e+5].trim()&&(p=e+5),n.convertEntities?(n.targetLanguage==="html"||n.targetLanguage==="js")&&(a.push(e,e+5,n.targetLanguage==="html"?E:w),m.convertEntities=!0):(a.push(e,e+5,h),m.convertEntities=!0)),!s&&t[e]==="\\"&&t[e+1]&&t[e+1].toLowerCase()==="u"&&t[e+2]==="0"&&t[e+3]==="0"&&t[e+4]&&t[e+4].toUpperCase()==="A"&&t[e+5]==="0"&&(r=e,u=e+6,t[e+6]&&t[e+6].trim()&&(p=e+6),n.convertEntities?(n.targetLanguage==="html"||n.targetLanguage==="css")&&a.push(e,e+6,n.targetLanguage==="html"?E:S):a.push(e,e+6,h)),!s&&t[e]===h&&(r=e,u=e+1,n.convertEntities&&a.push(e,e+1,n.targetLanguage==="css"?S:n.targetLanguage==="js"?w:E)),!s&&t[e]&&t[e].trim()&&(!t[e-1]||!t[e-1].trim())&&(g+=1),!s&&(!t[e]||`\r
12
+ `.includes(t[e])||(t[e]===`
13
+ `||t[e]==="\r"||t[e]==="\r"&&t[e+1]===`
14
+ `)&&N(t,e)&&Y.includes(t[N(t,e)]))){if((!n.minWordCount||g>=n.minWordCount)&&(!n.minCharCount||W>=n.minCharCount)){let o,l;d!==void 0&&c!==void 0&&r!==void 0&&u!==void 0?d>r?(o=d,l=c):(o=r,l=u):d!==void 0&&c!==void 0?(o=d,l=c):r!==void 0&&u!==void 0&&(o=r,l=u),!(o&&l)&&y&&T&&(o=y,l=T),o&&l&&(C(o,l),m.removeWidows=!0)}F()}n.UKPostcodes&&t[e]&&!t[e].trim()&&t[e-1]&&t[e-1].trim()&&z.test(t.slice(0,e))&&t[D(t,e)]&&Q.test(t.slice(D(t,e)))&&(C(e,D(t,e)),m.removeWidows=!0),!s&&t[e]&&!t[e].trim()&&t[e-1]&&t[e-1].trim()&&(d===void 0||t[d-1]&&t[d-1].trim())&&!"/>".includes(t[D(t,e)])&&!t.slice(0,e).trim().endsWith("br")&&!t.slice(0,e).trim().endsWith("hr")&&!(t.slice(0,e).endsWith("<")&&G.some(o=>t.startsWith(o,D(t,e))))&&(y=d,T=c,d=e,c=void 0,(r!==void 0||u!==void 0)&&(r=void 0,u=void 0));let i;s&&(typeof s=="string"&&(!s.length||t.startsWith(s,e))?s=void 0:b(s)&&(!s.length||s.some(o=>{if(t.startsWith(o,e))return i=o,!0}))&&(s=void 0,e+=i.length,b(n.ignore)&&n.ignore.length&&t[e+1]&&n.ignore.some(o=>ee(t,e,o.tails,{trimBeforeMatching:!0,cb:(l,R,j)=>(j&&(e=j-1,t[e+1]&&t[e+1].trim()&&(g+=1)),!0)})))),t[e]&&`\r
15
+ `.includes(t[e])&&(g=0,W=0),b(n.tagRanges)&&n.tagRanges.length&&n.tagRanges.some(o=>{if(e>=o[0]&&e<=o[1]&&o[1]-1>e)return e=o[1]-1,!0})}return K(t,a.current()).split("").forEach((e,i)=>{}),{res:K(t,a.current(),n.reportProgressFunc?e=>{$=Math.floor((n.reportProgressFuncTo-n.reportProgressFuncFrom)*(1-V)+e/100*(n.reportProgressFuncTo-n.reportProgressFuncFrom)*V),$!==A&&(A=$,n.reportProgressFunc($))}:void 0),ranges:a.current(),log:{timeTakenInMilliseconds:Date.now()-Z},whatWasDone:m}}export{ne as defaults,ce as removeWidows,$e as version};
@@ -1,76 +1,94 @@
1
1
  /**
2
2
  * @name string-remove-widows
3
3
  * @fileoverview Helps to prevent widow words in a text
4
- * @version 3.0.6
4
+ * @version 3.0.12
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-remove-widows/}
8
8
  */
9
9
 
10
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).stringRemoveWidows={})}(this,(function(t){"use strict";
10
+ var stringRemoveWidows=(()=>{var rr=Object.create;var k=Object.defineProperty;var nr=Object.getOwnPropertyDescriptor;var or=Object.getOwnPropertyNames,xe=Object.getOwnPropertySymbols,sr=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty,ir=Object.prototype.propertyIsEnumerable;var ge=(e,t,r)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,T=(e,t)=>{for(var r in t||(t={}))Le.call(t,r)&&ge(e,r,t[r]);if(xe)for(var r of xe(t))ir.call(t,r)&&ge(e,r,t[r]);return e};var He=e=>k(e,"__esModule",{value:!0});var Ve=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ar=(e,t)=>{for(var r in t)k(e,r,{get:t[r],enumerable:!0})},Fe=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of or(t))!Le.call(e,u)&&(r||u!=="default")&&k(e,u,{get:()=>t[u],enumerable:!(o=nr(t,u))||o.enumerable});return e},Pe=(e,t)=>Fe(He(k(e!=null?rr(sr(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),ur=(e=>(t,r)=>e&&e.get(t)||(r=Fe(He({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var fe=(e,t,r)=>(ge(e,typeof t!="symbol"?t+"":t,r),r);var Ze=Ve((mo,Ke)=>{var fr="[object Object]";function hr(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function dr(e,t){return function(r){return e(t(r))}}var mr=Function.prototype,qe=Object.prototype,Ge=mr.toString,pr=qe.hasOwnProperty,$r=Ge.call(Object),br=qe.toString,yr=dr(Object.getPrototypeOf,Object);function wr(e){return!!e&&typeof e=="object"}function Er(e){if(!wr(e)||br.call(e)!=fr||hr(e))return!1;var t=yr(e);if(t===null)return!0;var r=pr.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Ge.call(r)==$r}Ke.exports=Er});var Lt=Ve((K,P)=>{var Tr=200,Ye="__lodash_hash_undefined__",Xe=9007199254740991,he="[object Arguments]",Ar="[object Array]",ze="[object Boolean]",Qe="[object Date]",vr="[object Error]",de="[object Function]",et="[object GeneratorFunction]",te="[object Map]",tt="[object Number]",me="[object Object]",rt="[object Promise]",nt="[object RegExp]",re="[object Set]",ot="[object String]",st="[object Symbol]",pe="[object WeakMap]",it="[object ArrayBuffer]",ne="[object DataView]",at="[object Float32Array]",ut="[object Float64Array]",lt="[object Int8Array]",ct="[object Int16Array]",gt="[object Int32Array]",ft="[object Uint8Array]",ht="[object Uint8ClampedArray]",dt="[object Uint16Array]",mt="[object Uint32Array]",Sr=/[\\^$.*+?()[\]{}|]/g,_r=/\w*$/,Nr=/^\[object .+?Constructor\]$/,Cr=/^(?:0|[1-9]\d*)$/,w={};w[he]=w[Ar]=w[it]=w[ne]=w[ze]=w[Qe]=w[at]=w[ut]=w[lt]=w[ct]=w[gt]=w[te]=w[tt]=w[me]=w[nt]=w[re]=w[ot]=w[st]=w[ft]=w[ht]=w[dt]=w[mt]=!0;w[vr]=w[de]=w[pe]=!1;var Or=typeof global=="object"&&global&&global.Object===Object&&global,Dr=typeof self=="object"&&self&&self.Object===Object&&self,D=Or||Dr||Function("return this")(),pt=typeof K=="object"&&K&&!K.nodeType&&K,$t=pt&&typeof P=="object"&&P&&!P.nodeType&&P,Wr=$t&&$t.exports===pt;function Rr(e,t){return e.set(t[0],t[1]),e}function Ir(e,t){return e.add(t),e}function Mr(e,t){for(var r=-1,o=e?e.length:0;++r<o&&t(e[r],r,e)!==!1;);return e}function jr(e,t){for(var r=-1,o=t.length,u=e.length;++r<o;)e[u+r]=t[r];return e}function bt(e,t,r,o){var u=-1,n=e?e.length:0;for(o&&n&&(r=e[++u]);++u<n;)r=t(r,e[u],u,e);return r}function xr(e,t){for(var r=-1,o=Array(e);++r<e;)o[r]=t(r);return o}function Lr(e,t){return e==null?void 0:e[t]}function yt(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function wt(e){var t=-1,r=Array(e.size);return e.forEach(function(o,u){r[++t]=[u,o]}),r}function $e(e,t){return function(r){return e(t(r))}}function Et(e){var t=-1,r=Array(e.size);return e.forEach(function(o){r[++t]=o}),r}var Hr=Array.prototype,Vr=Function.prototype,oe=Object.prototype,be=D["__core-js_shared__"],Tt=function(){var e=/[^.]+$/.exec(be&&be.keys&&be.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),At=Vr.toString,R=oe.hasOwnProperty,se=oe.toString,Fr=RegExp("^"+At.call(R).replace(Sr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),vt=Wr?D.Buffer:void 0,St=D.Symbol,_t=D.Uint8Array,Pr=$e(Object.getPrototypeOf,Object),Jr=Object.create,Br=oe.propertyIsEnumerable,Ur=Hr.splice,Nt=Object.getOwnPropertySymbols,kr=vt?vt.isBuffer:void 0,qr=$e(Object.keys,Object),ye=F(D,"DataView"),q=F(D,"Map"),we=F(D,"Promise"),Ee=F(D,"Set"),Te=F(D,"WeakMap"),G=F(Object,"create"),Gr=L(ye),Kr=L(q),Zr=L(we),Yr=L(Ee),Xr=L(Te),Ct=St?St.prototype:void 0,Ot=Ct?Ct.valueOf:void 0;function j(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}function zr(){this.__data__=G?G(null):{}}function Qr(e){return this.has(e)&&delete this.__data__[e]}function en(e){var t=this.__data__;if(G){var r=t[e];return r===Ye?void 0:r}return R.call(t,e)?t[e]:void 0}function tn(e){var t=this.__data__;return G?t[e]!==void 0:R.call(t,e)}function rn(e,t){var r=this.__data__;return r[e]=G&&t===void 0?Ye:t,this}j.prototype.clear=zr;j.prototype.delete=Qr;j.prototype.get=en;j.prototype.has=tn;j.prototype.set=rn;function W(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}function nn(){this.__data__=[]}function on(e){var t=this.__data__,r=ie(t,e);if(r<0)return!1;var o=t.length-1;return r==o?t.pop():Ur.call(t,r,1),!0}function sn(e){var t=this.__data__,r=ie(t,e);return r<0?void 0:t[r][1]}function an(e){return ie(this.__data__,e)>-1}function un(e,t){var r=this.__data__,o=ie(r,e);return o<0?r.push([e,t]):r[o][1]=t,this}W.prototype.clear=nn;W.prototype.delete=on;W.prototype.get=sn;W.prototype.has=an;W.prototype.set=un;function H(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var o=e[t];this.set(o[0],o[1])}}function ln(){this.__data__={hash:new j,map:new(q||W),string:new j}}function cn(e){return ae(this,e).delete(e)}function gn(e){return ae(this,e).get(e)}function fn(e){return ae(this,e).has(e)}function hn(e,t){return ae(this,e).set(e,t),this}H.prototype.clear=ln;H.prototype.delete=cn;H.prototype.get=gn;H.prototype.has=fn;H.prototype.set=hn;function V(e){this.__data__=new W(e)}function dn(){this.__data__=new W}function mn(e){return this.__data__.delete(e)}function pn(e){return this.__data__.get(e)}function $n(e){return this.__data__.has(e)}function bn(e,t){var r=this.__data__;if(r instanceof W){var o=r.__data__;if(!q||o.length<Tr-1)return o.push([e,t]),this;r=this.__data__=new H(o)}return r.set(e,t),this}V.prototype.clear=dn;V.prototype.delete=mn;V.prototype.get=pn;V.prototype.has=$n;V.prototype.set=bn;function yn(e,t){var r=Se(e)||Bn(e)?xr(e.length,String):[],o=r.length,u=!!o;for(var n in e)(t||R.call(e,n))&&!(u&&(n=="length"||Vn(n,o)))&&r.push(n);return r}function Dt(e,t,r){var o=e[t];(!(R.call(e,t)&&Mt(o,r))||r===void 0&&!(t in e))&&(e[t]=r)}function ie(e,t){for(var r=e.length;r--;)if(Mt(e[r][0],t))return r;return-1}function wn(e,t){return e&&Wt(t,_e(t),e)}function Ae(e,t,r,o,u,n,g){var a;if(o&&(a=n?o(e,u,n,g):o(e)),a!==void 0)return a;if(!ue(e))return e;var c=Se(e);if(c){if(a=xn(e),!t)return In(e,a)}else{var i=x(e),f=i==de||i==et;if(kn(e))return _n(e,t);if(i==me||i==he||f&&!n){if(yt(e))return n?e:{};if(a=Ln(f?{}:e),!t)return Mn(e,wn(a,e))}else{if(!w[i])return n?e:{};a=Hn(e,i,Ae,t)}}g||(g=new V);var m=g.get(e);if(m)return m;if(g.set(e,a),!c)var p=r?jn(e):_e(e);return Mr(p||e,function(d,h){p&&(h=d,d=e[h]),Dt(a,h,Ae(d,t,r,o,h,e,g))}),a}function En(e){return ue(e)?Jr(e):{}}function Tn(e,t,r){var o=t(e);return Se(e)?o:jr(o,r(e))}function An(e){return se.call(e)}function vn(e){if(!ue(e)||Pn(e))return!1;var t=xt(e)||yt(e)?Fr:Nr;return t.test(L(e))}function Sn(e){if(!It(e))return qr(e);var t=[];for(var r in Object(e))R.call(e,r)&&r!="constructor"&&t.push(r);return t}function _n(e,t){if(t)return e.slice();var r=new e.constructor(e.length);return e.copy(r),r}function ve(e){var t=new e.constructor(e.byteLength);return new _t(t).set(new _t(e)),t}function Nn(e,t){var r=t?ve(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}function Cn(e,t,r){var o=t?r(wt(e),!0):wt(e);return bt(o,Rr,new e.constructor)}function On(e){var t=new e.constructor(e.source,_r.exec(e));return t.lastIndex=e.lastIndex,t}function Dn(e,t,r){var o=t?r(Et(e),!0):Et(e);return bt(o,Ir,new e.constructor)}function Wn(e){return Ot?Object(Ot.call(e)):{}}function Rn(e,t){var r=t?ve(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function In(e,t){var r=-1,o=e.length;for(t||(t=Array(o));++r<o;)t[r]=e[r];return t}function Wt(e,t,r,o){r||(r={});for(var u=-1,n=t.length;++u<n;){var g=t[u],a=o?o(r[g],e[g],g,r,e):void 0;Dt(r,g,a===void 0?e[g]:a)}return r}function Mn(e,t){return Wt(e,Rt(e),t)}function jn(e){return Tn(e,_e,Rt)}function ae(e,t){var r=e.__data__;return Fn(t)?r[typeof t=="string"?"string":"hash"]:r.map}function F(e,t){var r=Lr(e,t);return vn(r)?r:void 0}var Rt=Nt?$e(Nt,Object):Kn,x=An;(ye&&x(new ye(new ArrayBuffer(1)))!=ne||q&&x(new q)!=te||we&&x(we.resolve())!=rt||Ee&&x(new Ee)!=re||Te&&x(new Te)!=pe)&&(x=function(e){var t=se.call(e),r=t==me?e.constructor:void 0,o=r?L(r):void 0;if(o)switch(o){case Gr:return ne;case Kr:return te;case Zr:return rt;case Yr:return re;case Xr:return pe}return t});function xn(e){var t=e.length,r=e.constructor(t);return t&&typeof e[0]=="string"&&R.call(e,"index")&&(r.index=e.index,r.input=e.input),r}function Ln(e){return typeof e.constructor=="function"&&!It(e)?En(Pr(e)):{}}function Hn(e,t,r,o){var u=e.constructor;switch(t){case it:return ve(e);case ze:case Qe:return new u(+e);case ne:return Nn(e,o);case at:case ut:case lt:case ct:case gt:case ft:case ht:case dt:case mt:return Rn(e,o);case te:return Cn(e,o,r);case tt:case ot:return new u(e);case nt:return On(e);case re:return Dn(e,o,r);case st:return Wn(e)}}function Vn(e,t){return t=t==null?Xe:t,!!t&&(typeof e=="number"||Cr.test(e))&&e>-1&&e%1==0&&e<t}function Fn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Pn(e){return!!Tt&&Tt in e}function It(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||oe;return e===r}function L(e){if(e!=null){try{return At.call(e)}catch(t){}try{return e+""}catch(t){}}return""}function Jn(e){return Ae(e,!0,!0)}function Mt(e,t){return e===t||e!==e&&t!==t}function Bn(e){return Un(e)&&R.call(e,"callee")&&(!Br.call(e,"callee")||se.call(e)==he)}var Se=Array.isArray;function jt(e){return e!=null&&qn(e.length)&&!xt(e)}function Un(e){return Gn(e)&&jt(e)}var kn=kr||Zn;function xt(e){var t=ue(e)?se.call(e):"";return t==de||t==et}function qn(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Xe}function ue(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Gn(e){return!!e&&typeof e=="object"}function _e(e){return jt(e)?yn(e):Sn(e)}function Kn(){return[]}function Zn(){return!1}P.exports=Jn});var uo={};ar(uo,{defaults:()=>tr,removeWidows:()=>ao,version:()=>io});function Je(e){return typeof e=="string"?e.length?[e]:[]:e}function Be(e){return e&&typeof e=="object"&&!Array.isArray(e)}function ee(e){return typeof e=="string"}var Ue={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},lr=e=>e+1;function cr(e,t,r,o,u=!1,n=lr){let g=typeof r=="function"?r():r;if(+t<0&&u&&g==="EOL")return g;let a=T(T({},Ue),o);if(t>=e.length&&!u)return!1;let c=u?1:r.length,i=0,f=!1,m=!1,p=!1,d=a.maxMismatches,h=t,A=!1,b=!1,y=!1;function v(){return i===1&&d<a.maxMismatches-1}for(;e[h];){let S=n(h);if(a.trimBeforeMatching&&e[h].trim()===""){if(!e[S]&&u&&r==="EOL")return!0;h=n(h);continue}if(a&&!a.i&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.includes(e[h])||(a==null?void 0:a.i)&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.map(_=>_.toLowerCase()).includes(e[h].toLowerCase())){if(u&&r==="EOL"&&!e[S])return!0;h=n(h);continue}let E=S>h?r[r.length-c]:r[c-1];if(!a.i&&e[h]===E||a.i&&e[h].toLowerCase()===E.toLowerCase()){if(A||(A=!0),p||(p=!0),c===r.length){if(b=!0,d!==a.maxMismatches)return!1}else c===1&&(y=!0);if(c-=1,i++,v())return!1;if(!c)return i!==r.length||d===a.maxMismatches||!f?h:!1}else if(!f&&!i&&(f=!0),a.maxMismatches&&d&&h){d-=1;for(let _=0;_<=d;_++){let l=S>h?r[r.length-c+1+_]:r[c-2-_],C=e[n(h)];if(l&&(!a.i&&e[h]===l||a.i&&e[h].toLowerCase()===l.toLowerCase())&&(!a.firstMustMatch||c!==r.length)){if(i++,v())return!1;c-=2,A=!0;break}else if(C&&l&&(!a.i&&C===l||a.i&&C.toLowerCase()===l.toLowerCase())&&(!a.firstMustMatch||c!==r.length)){if(!i&&!a.hungry)return!1;c-=1,A=!0;break}else if(l===void 0&&d>=0&&A&&(!a.firstMustMatch||b)&&(!a.lastMustMatch||y))return h}A||(m=h)}else return h===0&&c===1&&!a.lastMustMatch&&p?0:!1;if(m!==!1&&m!==h&&(m=!1),c<1)return h;h=n(h)}if(c>0)return u&&g==="EOL"?!0:a&&a.maxMismatches>=c&&p?m||0:!1}function gr(e,t,r,o,u){if(Be(u)&&Object.prototype.hasOwnProperty.call(u,"trimBeforeMatching")&&typeof u.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(u.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let n=T(T({},Ue),u);if(typeof n.trimCharsBeforeMatching=="string"&&(n.trimCharsBeforeMatching=Je(n.trimCharsBeforeMatching)),n.trimCharsBeforeMatching=n.trimCharsBeforeMatching.map(f=>ee(f)?f:String(f)),!ee(t)||!t.length)return!1;if(!Number.isInteger(r)||r<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof r}, equal to:
11
+ ${JSON.stringify(r,null,4)}`);let g,a;if(ee(o))g=[o];else if(Array.isArray(o))g=o;else if(!o)g=o;else if(typeof o=="function")g=[],g.push(o);else throw new Error(`string-match-left-right/${e}(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof o}, equal to:
12
+ ${JSON.stringify(o,null,4)}`);if(u&&!Be(u))throw new Error(`string-match-left-right/${e}(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof u}", and equal to:
13
+ ${JSON.stringify(u,null,4)}`);let c=0,i="";if((n==null?void 0:n.trimCharsBeforeMatching)&&n.trimCharsBeforeMatching.some((f,m)=>f.length>1?(c=m,i=f,!0):!1))throw new Error(`string-match-left-right/${e}(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${c} is longer than 1 character, ${i.length} (equals to ${i}). Please split it into separate characters and put into array as separate elements.`);if(!g||!Array.isArray(g)||Array.isArray(g)&&!g.length||Array.isArray(g)&&g.length===1&&ee(g[0])&&!g[0].trim()){if(typeof n.cb=="function"){let m,p=r;if((e==="matchLeftIncl"||e==="matchRight")&&(p+=1),e[5]==="L")for(let b=p;b--;){let y=t[b];if((!n.trimBeforeMatching||n.trimBeforeMatching&&y!==void 0&&y.trim())&&(!n.trimCharsBeforeMatching||!n.trimCharsBeforeMatching.length||y!==void 0&&!n.trimCharsBeforeMatching.includes(y))){m=b;break}}else if(e.startsWith("matchRight"))for(let b=p;b<t.length;b++){let y=t[b];if((!n.trimBeforeMatching||n.trimBeforeMatching&&y.trim())&&(!n.trimCharsBeforeMatching||!n.trimCharsBeforeMatching.length||!n.trimCharsBeforeMatching.includes(y))){m=b;break}}if(m===void 0)return!1;let d=t[m],h=m+1,A="";return h&&h>0&&(A=t.slice(0,h)),e[5]==="L"||m&&m>0&&(A=t.slice(m)),n.cb(d,A,m)}let f="";throw u||(f=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${e}(): [THROW_ID_08] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!${f}`)}for(let f=0,m=g.length;f<m;f++){a=typeof g[f]=="function";let p=g[f],d,h,A="",b=r;e==="matchRight"?b+=1:e==="matchLeft"&&(b-=1);let y=cr(t,b,p,n,a,v=>e[5]==="L"?v-1:v+1);if(y&&a&&typeof p=="function"&&p()==="EOL")return p()&&(n.cb?n.cb(d,A,h):!0)?p():!1;if(Number.isInteger(y)&&(h=e.startsWith("matchLeft")?y-1:y+1,e[5]==="L"?A=t.slice(0,y):A=t.slice(h)),h<0&&(h=void 0),t[h]&&(d=t[h]),Number.isInteger(y)&&(n.cb?n.cb(d,A,h):!0))return p}return!1}function ke(e,t,r,o){return gr("matchRightIncl",e,t,r,o)}var Yn=Pe(Ze(),1),Xn=Pe(Lt(),1);var J="\xA0";function zn({str:e,idx:t=0,stopAtNewlines:r=!1,stopAtRawNbsp:o=!1}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),!e[t+1]))return null;if(e[t+1]&&(e[t+1].trim()||r&&`
14
+ \r`.includes(e[t+1])||o&&e[t+1]===J))return t+1;if(e[t+2]&&(e[t+2].trim()||r&&`
15
+ \r`.includes(e[t+2])||o&&e[t+2]===J))return t+2;for(let u=t+1,n=e.length;u<n;u++)if(e[u].trim()||r&&`
16
+ \r`.includes(e[u])||o&&e[u]===J)return u;return null}function B(e,t=0){return zn({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function Qn({str:e,idx:t,stopAtNewlines:r,stopAtRawNbsp:o}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),t<1))return null;if(e[~-t]&&(e[~-t].trim()||r&&`
17
+ \r`.includes(e[~-t])||o&&e[~-t]===J))return~-t;if(e[t-2]&&(e[t-2].trim()||r&&`
18
+ \r`.includes(e[t-2])||o&&e[t-2]===J))return t-2;for(let u=t;u--;)if(e[u]&&(e[u].trim()||r&&`
19
+ \r`.includes(e[u])||o&&e[u]===J))return u;return null}function Z(e,t=0){return Qn({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}function le(e,t=1){let r="\xA0";function o(n){return Array.from(n).reverse().join("")}function u(n,g,a){let c=a?`
20
+ `:"\r",i=a?"\r":`
21
+ `;if(!n)return n;let f=0,m=0,p="";for(let d=0,h=n.length;d<h;d++)(n[d]===c||n[d]===i&&n[d-1]!==c)&&m++,`\r
22
+ `.includes(n[d])||n[d]===r?(f=0,n[d]===r?p+=n[d]:n[d]===c?m<=g&&(p+=n[d],n[d+1]===i&&(p+=n[d+1],d++)):n[d]===i&&(!n[d-1]||n[d-1]!==c)&&m<=g&&(p+=n[d])):(f++,!n[d+1]&&!m&&(p+=" "));return p}if(typeof e=="string"&&e.length){let n=1;typeof+t=="number"&&Number.isInteger(+t)&&+t>=0&&(n=+t);let g="",a="";if(!e.trim())g=e;else if(!e[0].trim()){for(let c=0,i=e.length;c<i;c++)if(e[c].trim()){g=e.slice(0,c);break}}if(e.trim()&&(e.slice(-1).trim()===""||e.slice(-1)===r)){for(let c=e.length;c--;)if(e[c].trim()){a=e.slice(c+1);break}}return`${u(g,n,!1)}${e.trim()}${o(u(o(a),n,!0))}`}return e}var eo={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function Ht(e,t){if(!Array.isArray(e)||!e.length)return e;let r=T(T({},eo),t),o,u;if(r.strictlyTwoElementsInRangeArrays&&!e.every((a,c)=>!Array.isArray(a)||a.length!==2?(o=c,u=a.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${o}th range (${JSON.stringify(e[o],null,4)}) has not two but ${u} elements!`);if(!e.every((a,c)=>!Array.isArray(a)||!Number.isInteger(a[0])||a[0]<0||!Number.isInteger(a[1])||a[1]<0?(o=c,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${o}th range (${JSON.stringify(e[o],null,4)}) does not consist of only natural numbers!`);let n=e.length**2,g=0;return Array.from(e).sort((a,c)=>(r.progressFn&&(g+=1,r.progressFn(Math.floor(g*100/n))),a[0]===c[0]?a[1]<c[1]?-1:a[1]>c[1]?1:0:a[0]<c[0]?-1:1))}var Vt={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function to(e,t){function r(i){return i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;let o;if(t)if(r(t)){if(o=T(T({},Vt),t),o.progressFn&&r(o.progressFn)&&!Object.keys(o.progressFn).length)o.progressFn=null;else if(o.progressFn&&typeof o.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof o.progressFn}", equal to ${JSON.stringify(o.progressFn,null,4)}`);if(![1,2,"1","2"].includes(o.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof o.mergeType}", equal to ${JSON.stringify(o.mergeType,null,4)}`);if(typeof o.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof o.joinRangesThatTouchEdges}", equal to ${JSON.stringify(o.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
23
+ ${JSON.stringify(t,null,4)} (type ${typeof t})`);else o=T({},Vt);let u=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),n,g,a;o.progressFn?n=Ht(u,{progressFn:i=>{a=Math.floor(i/5),a!==g&&(g=a,o.progressFn(a))}}):n=Ht(u);let c=n.length-1;for(let i=c;i>0;i--)o.progressFn&&(a=Math.floor((1-i/c)*78)+21,a!==g&&a>g&&(g=a,o.progressFn(a))),(n[i][0]<=n[i-1][0]||!o.joinRangesThatTouchEdges&&n[i][0]<n[i-1][1]||o.joinRangesThatTouchEdges&&n[i][0]<=n[i-1][1])&&(n[i-1][0]=Math.min(n[i][0],n[i-1][0]),n[i-1][1]=Math.max(n[i][1],n[i-1][1]),n[i][2]!==void 0&&(n[i-1][0]>=n[i][0]||n[i-1][1]<=n[i][1])&&n[i-1][2]!==null&&(n[i][2]===null&&n[i-1][2]!==null?n[i-1][2]=null:n[i-1][2]!=null?+o.mergeType==2&&n[i-1][0]===n[i][0]?n[i-1][2]=n[i][2]:n[i-1][2]+=n[i][2]:n[i-1][2]=n[i][2]),n.splice(i,1),i=n.length);return n.length?n:null}function I(e){return e!=null}function M(e){return Number.isInteger(e)&&e>=0}function Y(e){return typeof e=="string"}var ro={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1},Ft=class{constructor(e){fe(this,"ranges");fe(this,"opts");let t=T(T({},ro),e);if(t.mergeType&&t.mergeType!==1&&t.mergeType!==2)if(Y(t.mergeType)&&t.mergeType.trim()==="1")t.mergeType=1;else if(Y(t.mergeType)&&t.mergeType.trim()==="2")t.mergeType=2;else throw new Error(`ranges-push: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof t.mergeType}", equal to ${JSON.stringify(t.mergeType,null,4)}`);this.opts=t,this.ranges=[]}add(e,t,r){if(e==null&&t==null)return;if(I(e)&&!I(t)){if(Array.isArray(e)){if(e.length){if(e.some(n=>Array.isArray(n))){e.forEach(n=>{Array.isArray(n)&&this.add(...n)});return}e.length&&M(+e[0])&&M(+e[1])&&this.add(...e)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(e,null,0)}) but second-one, "to" is not (${JSON.stringify(t,null,0)})`)}else if(!I(e)&&I(t))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(t,null,0)}) but first-one, "from" is not (${JSON.stringify(e,null,0)})`);let o=+e,u=+t;if(M(r)&&(r=String(r)),M(o)&&M(u)){if(I(r)&&!Y(r)&&!M(r))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof r}, equal to:
24
+ ${JSON.stringify(r,null,4)}`);if(I(this.ranges)&&Array.isArray(this.last())&&o===this.last()[1]){if(this.last()[1]=u,this.last()[2],this.last()[2]!==null&&I(r)){let n=this.last()[2]&&this.last()[2].length>0&&(!this.opts||!this.opts.mergeType||this.opts.mergeType===1)?`${this.last()[2]}${r}`:r;this.opts.limitToBeAddedWhitespace&&(n=le(n,this.opts.limitLinebreaksCount)),Y(n)&&!n.length||(this.last()[2]=n)}}else{this.ranges||(this.ranges=[]);let n=r!==void 0&&!(Y(r)&&!r.length)?[o,u,r&&this.opts.limitToBeAddedWhitespace?le(r,this.opts.limitLinebreaksCount):r]:[o,u];this.ranges.push(n)}}else throw M(o)&&o>=0?new TypeError(`ranges-push/Ranges/add(): [THROW_ID_10] "to" value, the second input argument, must be a natural number or zero! Currently it's of a type "${typeof u}" equal to: ${JSON.stringify(u,null,4)}`):new TypeError(`ranges-push/Ranges/add(): [THROW_ID_09] "from" value, the first input argument, must be a natural number or zero! Currently it's of a type "${typeof o}" equal to: ${JSON.stringify(o,null,4)}`)}push(e,t,r){this.add(e,t,r)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=to(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>I(e[2])?[e[0],e[1],le(e[2],this.opts.limitLinebreaksCount)]:e):this.ranges):null}wipe(){this.ranges=[]}replace(e){if(Array.isArray(e)&&e.length)if(Array.isArray(e[0])&&M(e[0][0]))this.ranges=Array.from(e);else throw new Error(`ranges-push/Ranges/replace(): [THROW_ID_11] Single range was given but we expected array of arrays! The first element, ${JSON.stringify(e[0],null,4)} should be an array and its first element should be an integer, a string index.`);else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}};var no={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function Ne(e,t){if(!Array.isArray(e)||!e.length)return e;let r=T(T({},no),t),o,u;if(r.strictlyTwoElementsInRangeArrays&&!e.every((a,c)=>!Array.isArray(a)||a.length!==2?(o=c,u=a.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${o}th range (${JSON.stringify(e[o],null,4)}) has not two but ${u} elements!`);if(!e.every((a,c)=>!Array.isArray(a)||!Number.isInteger(a[0])||a[0]<0||!Number.isInteger(a[1])||a[1]<0?(o=c,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${o}th range (${JSON.stringify(e[o],null,4)}) does not consist of only natural numbers!`);let n=e.length**2,g=0;return Array.from(e).sort((a,c)=>(r.progressFn&&(g+=1,r.progressFn(Math.floor(g*100/n))),a[0]===c[0]?a[1]<c[1]?-1:a[1]>c[1]?1:0:a[0]<c[0]?-1:1))}var Pt={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Jt(e,t){function r(i){return i&&typeof i=="object"&&!Array.isArray(i)}if(!Array.isArray(e)||!e.length)return null;let o;if(t)if(r(t)){if(o=T(T({},Pt),t),o.progressFn&&r(o.progressFn)&&!Object.keys(o.progressFn).length)o.progressFn=null;else if(o.progressFn&&typeof o.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof o.progressFn}", equal to ${JSON.stringify(o.progressFn,null,4)}`);if(![1,2,"1","2"].includes(o.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof o.mergeType}", equal to ${JSON.stringify(o.mergeType,null,4)}`);if(typeof o.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof o.joinRangesThatTouchEdges}", equal to ${JSON.stringify(o.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
25
+ ${JSON.stringify(t,null,4)} (type ${typeof t})`);else o=T({},Pt);let u=e.filter(i=>Array.isArray(i)).map(i=>[...i]).filter(i=>i[2]!==void 0||i[0]!==i[1]),n,g,a;o.progressFn?n=Ne(u,{progressFn:i=>{a=Math.floor(i/5),a!==g&&(g=a,o.progressFn(a))}}):n=Ne(u);let c=n.length-1;for(let i=c;i>0;i--)o.progressFn&&(a=Math.floor((1-i/c)*78)+21,a!==g&&a>g&&(g=a,o.progressFn(a))),(n[i][0]<=n[i-1][0]||!o.joinRangesThatTouchEdges&&n[i][0]<n[i-1][1]||o.joinRangesThatTouchEdges&&n[i][0]<=n[i-1][1])&&(n[i-1][0]=Math.min(n[i][0],n[i-1][0]),n[i-1][1]=Math.max(n[i][1],n[i-1][1]),n[i][2]!==void 0&&(n[i-1][0]>=n[i][0]||n[i-1][1]<=n[i][1])&&n[i-1][2]!==null&&(n[i][2]===null&&n[i-1][2]!==null?n[i-1][2]=null:n[i-1][2]!=null?+o.mergeType==2&&n[i-1][0]===n[i][0]?n[i-1][2]=n[i][2]:n[i-1][2]+=n[i][2]:n[i-1][2]=n[i][2]),n.splice(i,1),i=n.length);return n.length?n:null}var oo=!0,Ce="Invariant failed";function Bt(e,t){if(!e){if(oo)throw new Error(Ce);var r=typeof t=="function"?t():t,o=r?Ce+": "+r:Ce;throw new Error(o)}}function Oe(e,t,r){let o=0,u=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(t&&!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(r&&typeof r!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!t||!t.filter(f=>f).length)return e;let n;Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?n=[Array.from(t)]:n=Array.from(t);let g=n.length,a=0;n.filter(f=>f).forEach((f,m)=>{if(r&&(o=Math.floor(a/g*10),o!==u&&(u=o,r(o))),!Array.isArray(f))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${m}th element not an array: ${JSON.stringify(f,null,4)}, which is ${typeof f}`);if(!Number.isInteger(f[0])){if(!Number.isInteger(+f[0])||+f[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${m}th element, array ${JSON.stringify(f,null,0)}. Its first element is not an integer, string index, but ${typeof f[0]}, equal to: ${JSON.stringify(f[0],null,4)}.`);n[m][0]=+n[m][0]}if(!Number.isInteger(f[1])){if(!Number.isInteger(+f[1])||+f[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${m}th element, array ${JSON.stringify(f,null,0)}. Its second element is not an integer, string index, but ${typeof f[1]}, equal to: ${JSON.stringify(f[1],null,4)}.`);n[m][1]=+n[m][1]}a+=1});let c=Jt(n,{progressFn:f=>{r&&(o=10+Math.floor(f/10),o!==u&&(u=o,r(o)))}});Bt(c);let i=c.length;if(i>0){let f=e.slice(c[i-1][1]);e=c.reduce((m,p,d,h)=>{r&&(o=20+Math.floor(d/i*80),o!==u&&(u=o,r(o)));let A=d===0?0:h[d-1][1],b=h[d][0];return`${m}${e.slice(A,b)}${h[d][2]||""}`},""),e+=f}return e}var Ut="3.0.12";var U="\xA0",X="&nbsp;",z="\\00A0",Q="\\u00A0",kt="\u2013",qt="&ndash;",Gt="\\2013",Kt="\\u2013",Zt="\u2014",Yt="&mdash;",Xt="\\2014",zt="\\u2014",De=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],Qt=[{heads:"{{",tails:"}}"}],We=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],er=["abbr","address","area","article","aside","audio","base","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","param","picture","pre","progress","rb","rp","rt","rtc","ruby","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","var","video","wbr","xml"];var io=Ut,tr={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};function ao(e,t){var lo;let r=Date.now();if(typeof e!="string")throw e===void 0?new Error("string-remove-widows: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`string-remove-widows: [THROW_ID_02] the first input argument must be string! It was given as "${typeof e}", equal to:
26
+ ${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new Error(`string-remove-widows: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof t}, equal to ${JSON.stringify(t,null,4)}`);let o=Array.isArray,u=e.length,n=new Ft({mergeType:2}),g=["."],a=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,c=/^[0-9][A-Z]{2}/,i=.06,f,m=0,p=0,d=0,h,A,b,y,v,S,E,_,l=T(T({},tr),t),C={removeWidows:!1,convertEntities:!1};if(!l.ignore||!o(l.ignore)&&typeof l.ignore!="string")l.ignore=[];else if(typeof l.ignore=="string"&&(l.ignore=[l.ignore]),l.ignore.includes("all"))l.ignore=l.ignore.concat(De.concat(We));else if(l.ignore.some(s=>typeof s=="string")){let s=[];l.ignore=l.ignore.filter(N=>typeof N=="string"&&N.length?(["nunjucks","jinja","liquid"].includes(N.trim().toLowerCase())?s=s.concat(De):["hugo"].includes(N.trim().toLowerCase())?s=s.concat(Qt):["hexo"].includes(N.trim().toLowerCase())&&(s=s.concat(We)),!1):typeof N=="object"),s.length&&(l.ignore=l.ignore.concat(s))}let Re;l.reportProgressFunc&&(Re=Math.floor(l.reportProgressFuncTo-(l.reportProgressFuncTo-l.reportProgressFuncFrom)*i-l.reportProgressFuncFrom));function ce(s,N){let $=U;l.removeWidowPreventionMeasures?$=" ":l.convertEntities&&($=X,typeof l.targetLanguage=="string"&&(l.targetLanguage.trim().toLowerCase()==="css"?$=z:l.targetLanguage.trim().toLowerCase()==="js"&&($=Q))),e.slice(s,N)!==$&&n.push(s,N,$)}function Ie(){p=0,d=0,h=void 0,A=void 0,b=void 0,y=void 0,v=void 0,S=void 0}Ie();for(let s=0;s<=u;s++){if(!E&&o(l.ignore)&&l.ignore.length&&l.ignore.some(($,O)=>{if(o($.heads)&&$.heads.some(Me=>e.startsWith(Me,s))||typeof $.heads=="string"&&e.startsWith($.heads,s))return p+=1,E=l.ignore[O].tails,!0}),!E&&_&&_===s&&(p+=1,_=void 0),typeof l.reportProgressFunc=="function"&&(f=l.reportProgressFuncFrom+Math.floor(s/u*(Re||1)),f!==m&&(m=f,l.reportProgressFunc(f))),!E&&s&&e[s]&&e[s].trim()&&(!e[s-1]||e[s-1]&&!e[s-1].trim())&&(y=s),!E&&e[s]&&e[s].trim()&&(d+=1),!E&&l.hyphens&&(`-${Zt}${kt}`.includes(e[s])||e.startsWith(qt,s)||e.startsWith(Gt,s)||e.startsWith(Kt,s)||e.startsWith(Yt,s)||e.startsWith(Xt,s)||e.startsWith(zt,s))&&e[s+1]&&(!e[s+1].trim()||e[s]==="&")&&e[s-1]&&!e[s-1].trim()&&e[Z(e,s)]&&(ce(Z(e,s)+1,s),C.removeWidows=!0),!E&&(e.startsWith("&nbsp;",s)||e.startsWith("&#160;",s))&&(v=s,S=s+6,e[s+6]&&e[s+6].trim()&&(_=s+6),l.convertEntities?(l.targetLanguage==="css"||l.targetLanguage==="js")&&(n.push(s,s+6,l.targetLanguage==="css"?z:Q),C.convertEntities=!0):(n.push(s,s+6,U),C.convertEntities=!0)),!E&&e[s+4]&&e[s]==="\\"&&e[s+1]==="0"&&e[s+2]==="0"&&e[s+3].toUpperCase()==="A"&&e[s+4]==="0"&&(v=s,S=s+5,e[s+5]&&e[s+5].trim()&&(_=s+5),l.convertEntities?(l.targetLanguage==="html"||l.targetLanguage==="js")&&(n.push(s,s+5,l.targetLanguage==="html"?X:Q),C.convertEntities=!0):(n.push(s,s+5,U),C.convertEntities=!0)),!E&&e[s]==="\\"&&e[s+1]&&e[s+1].toLowerCase()==="u"&&e[s+2]==="0"&&e[s+3]==="0"&&e[s+4]&&e[s+4].toUpperCase()==="A"&&e[s+5]==="0"&&(v=s,S=s+6,e[s+6]&&e[s+6].trim()&&(_=s+6),l.convertEntities?(l.targetLanguage==="html"||l.targetLanguage==="css")&&n.push(s,s+6,l.targetLanguage==="html"?X:z):n.push(s,s+6,U)),!E&&e[s]===U&&(v=s,S=s+1,l.convertEntities&&n.push(s,s+1,l.targetLanguage==="css"?z:l.targetLanguage==="js"?Q:X)),!E&&e[s]&&e[s].trim()&&(!e[s-1]||!e[s-1].trim())&&(p+=1),!E&&(!e[s]||`\r
27
+ `.includes(e[s])||(e[s]===`
28
+ `||e[s]==="\r"||e[s]==="\r"&&e[s+1]===`
29
+ `)&&Z(e,s)&&g.includes(e[Z(e,s)]))){if((!l.minWordCount||p>=l.minWordCount)&&(!l.minCharCount||d>=l.minCharCount)){let $,O;b!==void 0&&y!==void 0&&v!==void 0&&S!==void 0?b>v?($=b,O=y):($=v,O=S):b!==void 0&&y!==void 0?($=b,O=y):v!==void 0&&S!==void 0&&($=v,O=S),!($&&O)&&h&&A&&($=h,O=A),$&&O&&(ce($,O),C.removeWidows=!0)}Ie()}l.UKPostcodes&&e[s]&&!e[s].trim()&&e[s-1]&&e[s-1].trim()&&a.test(e.slice(0,s))&&e[B(e,s)]&&c.test(e.slice(B(e,s)))&&(ce(s,B(e,s)),C.removeWidows=!0),!E&&e[s]&&!e[s].trim()&&e[s-1]&&e[s-1].trim()&&(b===void 0||e[b-1]&&e[b-1].trim())&&!"/>".includes(e[B(e,s)])&&!e.slice(0,s).trim().endsWith("br")&&!e.slice(0,s).trim().endsWith("hr")&&!(e.slice(0,s).endsWith("<")&&er.some($=>e.startsWith($,B(e,s))))&&(h=b,A=y,b=s,y=void 0,(v!==void 0||S!==void 0)&&(v=void 0,S=void 0));let N;E&&(typeof E=="string"&&(!E.length||e.startsWith(E,s))?E=void 0:o(E)&&(!E.length||E.some($=>{if(e.startsWith($,s))return N=$,!0}))&&(E=void 0,s+=N.length,o(l.ignore)&&l.ignore.length&&e[s+1]&&l.ignore.some($=>ke(e,s,$.tails,{trimBeforeMatching:!0,cb:(O,Me,je)=>(je&&(s=je-1,e[s+1]&&e[s+1].trim()&&(p+=1)),!0)})))),e[s]&&`\r
30
+ `.includes(e[s])&&(p=0,d=0),o(l.tagRanges)&&l.tagRanges.length&&l.tagRanges.some($=>{if(s>=$[0]&&s<=$[1]&&$[1]-1>s)return s=$[1]-1,!0})}return Oe(e,n.current()).split("").forEach((s,N)=>{}),{res:Oe(e,n.current(),l.reportProgressFunc?s=>{f=Math.floor((l.reportProgressFuncTo-l.reportProgressFuncFrom)*(1-i)+s/100*(l.reportProgressFuncTo-l.reportProgressFuncFrom)*i),f!==m&&(m=f,l.reportProgressFunc(f))}:void 0),ranges:n.current(),log:{timeTakenInMilliseconds:Date.now()-r},whatWasDone:C}}return ur(uo);})();
11
31
  /**
12
32
  * @name arrayiffy-if-string
13
33
  * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
14
- * @version 4.0.6
34
+ * @version 4.0.12
15
35
  * @author Roy Revelt, Codsen Ltd
16
36
  * @license MIT
17
37
  * {@link https://codsen.com/os/arrayiffy-if-string/}
18
38
  */
19
39
  /**
20
- * @name string-match-left-right
21
- * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
22
- * @version 8.0.6
40
+ * @name ranges-apply
41
+ * @fileoverview Take an array of string index ranges, delete/replace the string according to them
42
+ * @version 6.0.12
23
43
  * @author Roy Revelt, Codsen Ltd
24
44
  * @license MIT
25
- * {@link https://codsen.com/os/string-match-left-right/}
45
+ * {@link https://codsen.com/os/ranges-apply/}
26
46
  */
27
- function e(t){return t&&"object"==typeof t&&!Array.isArray(t)}function r(t){return"string"==typeof t}const n={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},o=t=>t+1;function i(t,e,r,i,s=!1,a=o){const u="function"==typeof r?r():r;if(+e<0&&s&&"EOL"===u)return u;const l={...n,...i};if(e>=t.length&&!s)return!1;let c=s?1:r.length,g=0,f=!1,h=!1,p=!1,y=l.maxMismatches,m=e,d=!1,b=!1,w=!1;function v(){return 1===g&&y<l.maxMismatches-1}for(;t[m];){const e=a(m);if(l.trimBeforeMatching&&""===t[m].trim()){if(!t[e]&&s&&"EOL"===r)return!0;m=a(m);continue}if(l&&!l.i&&l.trimCharsBeforeMatching&&l.trimCharsBeforeMatching.includes(t[m])||l&&l.i&&l.trimCharsBeforeMatching&&l.trimCharsBeforeMatching.map((t=>t.toLowerCase())).includes(t[m].toLowerCase())){if(s&&"EOL"===r&&!t[e])return!0;m=a(m);continue}const n=e>m?r[r.length-c]:r[c-1];if(!l.i&&t[m]===n||l.i&&t[m].toLowerCase()===n.toLowerCase()){if(d||(d=!0),p||(p=!0),c===r.length){if(b=!0,y!==l.maxMismatches)return!1}else 1===c&&(w=!0);if(c-=1,g++,v())return!1;if(!c)return(g!==r.length||y===l.maxMismatches||!f)&&m}else{if(f||g||(f=!0),!(l.maxMismatches&&y&&m))return!(0!==m||1!==c||l.lastMustMatch||!p)&&0;y-=1;for(let n=0;n<=y;n++){const o=e>m?r[r.length-c+1+n]:r[c-2-n],i=t[a(m)];if(o&&(!l.i&&t[m]===o||l.i&&t[m].toLowerCase()===o.toLowerCase())&&(!l.firstMustMatch||c!==r.length)){if(g++,v())return!1;c-=2,d=!0;break}if(i&&o&&(!l.i&&i===o||l.i&&i.toLowerCase()===o.toLowerCase())&&(!l.firstMustMatch||c!==r.length)){if(!g&&!l.hungry)return!1;c-=1,d=!0;break}if(void 0===o&&y>=0&&d&&(!l.firstMustMatch||b)&&(!l.lastMustMatch||w))return m}d||(h=m)}if(!1!==h&&h!==m&&(h=!1),c<1)return m;m=a(m)}return c>0?!(!s||"EOL"!==u)||!!(l&&l.maxMismatches>=c&&p)&&(h||0):void 0}function s(t,o,s,a){return function(t,o,s,a,u){if(e(u)&&Object.prototype.hasOwnProperty.call(u,"trimBeforeMatching")&&"boolean"!=typeof u.trimBeforeMatching)throw new Error(`string-match-left-right/${t}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(u.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);const l={...n,...u};var c;if("string"==typeof l.trimCharsBeforeMatching&&(l.trimCharsBeforeMatching="string"==typeof(c=l.trimCharsBeforeMatching)?c.length?[c]:[]:c),l.trimCharsBeforeMatching=l.trimCharsBeforeMatching.map((t=>r(t)?t:String(t))),!r(o))return!1;if(!o.length)return!1;if(!Number.isInteger(s)||s<0)throw new Error(`string-match-left-right/${t}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof s}, equal to:\n${JSON.stringify(s,null,4)}`);let g,f;if(r(a))g=[a];else if(Array.isArray(a))g=a;else if(a){if("function"!=typeof a)throw new Error(`string-match-left-right/${t}(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof a}, equal to:\n${JSON.stringify(a,null,4)}`);g=[],g.push(a)}else g=a;if(u&&!e(u))throw new Error(`string-match-left-right/${t}(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof u}", and equal to:\n${JSON.stringify(u,null,4)}`);let h=0,p="";if(l&&l.trimCharsBeforeMatching&&l.trimCharsBeforeMatching.some(((t,e)=>t.length>1&&(h=e,p=t,!0))))throw new Error(`string-match-left-right/${t}(): [THROW_ID_07] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${h} is longer than 1 character, ${p.length} (equals to ${p}). Please split it into separate characters and put into array as separate elements.`);if(!g||!Array.isArray(g)||Array.isArray(g)&&!g.length||Array.isArray(g)&&1===g.length&&r(g[0])&&!g[0].trim()){if("function"==typeof l.cb){let e,r=s;if("matchLeftIncl"!==t&&"matchRight"!==t||(r+=1),"L"===t[5])for(let t=r;t--;){const r=o[t];if((!l.trimBeforeMatching||l.trimBeforeMatching&&void 0!==r&&r.trim())&&(!l.trimCharsBeforeMatching||!l.trimCharsBeforeMatching.length||void 0!==r&&!l.trimCharsBeforeMatching.includes(r))){e=t;break}}else if(t.startsWith("matchRight"))for(let t=r;t<o.length;t++){const r=o[t];if((!l.trimBeforeMatching||l.trimBeforeMatching&&r.trim())&&(!l.trimCharsBeforeMatching||!l.trimCharsBeforeMatching.length||!l.trimCharsBeforeMatching.includes(r))){e=t;break}}if(void 0===e)return!1;const n=o[e],i=e+1;let a="";return i&&i>0&&(a=o.slice(0,i)),"L"===t[5]||e&&e>0&&(a=o.slice(e)),l.cb(n,a,e)}let e="";throw u||(e=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${t}(): [THROW_ID_08] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!${e}`)}for(let e=0,r=g.length;e<r;e++){f="function"==typeof g[e];const r=g[e];let n,a,u="",c=s;"matchRight"===t?c+=1:"matchLeft"===t&&(c-=1);const h=i(o,c,r,l,f,(e=>"L"===t[5]?e-1:e+1));if(h&&f&&"function"==typeof r&&"EOL"===r())return!(!r()||l.cb&&!l.cb(n,u,a))&&r();if(Number.isInteger(h)&&(a=t.startsWith("matchLeft")?h-1:h+1,u="L"===t[5]?o.slice(0,h):o.slice(a)),a<0&&(a=void 0),o[a]&&(n=o[a]),Number.isInteger(h)&&(!l.cb||l.cb(n,u,a)))return r}return!1}("matchRightIncl",t,o,s,a)}var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};Function.prototype.toString.call(Object);var u={exports:{}};!function(t,e){var r="__lodash_hash_undefined__",n=9007199254740991,o="[object Arguments]",i="[object Boolean]",s="[object Date]",u="[object Function]",l="[object GeneratorFunction]",c="[object Map]",g="[object Number]",f="[object Object]",h="[object Promise]",p="[object RegExp]",y="[object Set]",m="[object String]",d="[object Symbol]",b="[object WeakMap]",w="[object ArrayBuffer]",v="[object DataView]",_="[object Float32Array]",T="[object Float64Array]",O="[object Int8Array]",A="[object Int16Array]",j="[object Int32Array]",$="[object Uint8Array]",E="[object Uint8ClampedArray]",I="[object Uint16Array]",M="[object Uint32Array]",R=/\w*$/,W=/^\[object .+?Constructor\]$/,F=/^(?:0|[1-9]\d*)$/,C={};C[o]=C["[object Array]"]=C[w]=C[v]=C[i]=C[s]=C[_]=C[T]=C[O]=C[A]=C[j]=C[c]=C[g]=C[f]=C[p]=C[y]=C[m]=C[d]=C[$]=C[E]=C[I]=C[M]=!0,C["[object Error]"]=C[u]=C[b]=!1;var N="object"==typeof self&&self&&self.Object===Object&&self,S="object"==typeof a&&a&&a.Object===Object&&a||N||Function("return this")(),L=e&&!e.nodeType&&e,x=L&&t&&!t.nodeType&&t,D=x&&x.exports===L;function B(t,e){return t.set(e[0],e[1]),t}function H(t,e){return t.add(e),t}function J(t,e,r,n){var o=-1,i=t?t.length:0;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r}function P(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function k(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function q(t,e){return function(r){return t(e(r))}}function U(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var z,Z=Array.prototype,K=Function.prototype,V=Object.prototype,G=S["__core-js_shared__"],Q=(z=/[^.]+$/.exec(G&&G.keys&&G.keys.IE_PROTO||""))?"Symbol(src)_1."+z:"",X=K.toString,Y=V.hasOwnProperty,tt=V.toString,et=RegExp("^"+X.call(Y).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=D?S.Buffer:void 0,nt=S.Symbol,ot=S.Uint8Array,it=q(Object.getPrototypeOf,Object),st=Object.create,at=V.propertyIsEnumerable,ut=Z.splice,lt=Object.getOwnPropertySymbols,ct=rt?rt.isBuffer:void 0,gt=q(Object.keys,Object),ft=xt(S,"DataView"),ht=xt(S,"Map"),pt=xt(S,"Promise"),yt=xt(S,"Set"),mt=xt(S,"WeakMap"),dt=xt(Object,"create"),bt=Pt(ft),wt=Pt(ht),vt=Pt(pt),_t=Pt(yt),Tt=Pt(mt),Ot=nt?nt.prototype:void 0,At=Ot?Ot.valueOf:void 0;function jt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function $t(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Et(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function It(t){this.__data__=new $t(t)}function Mt(t,e){var r=qt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Ut(t)}(t)&&Y.call(t,"callee")&&(!at.call(t,"callee")||tt.call(t)==o)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,i=!!n;for(var s in t)!e&&!Y.call(t,s)||i&&("length"==s||Ht(s,n))||r.push(s);return r}function Rt(t,e,r){var n=t[e];Y.call(t,e)&&kt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function Wt(t,e){for(var r=t.length;r--;)if(kt(t[r][0],e))return r;return-1}function Ft(t,e,r,n,a,h,b){var W;if(n&&(W=h?n(t,a,h,b):n(t)),void 0!==W)return W;if(!Kt(t))return t;var F=qt(t);if(F){if(W=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&Y.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!e)return function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(t,W)}else{var N=Bt(t),S=N==u||N==l;if(zt(t))return function(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}(t,e);if(N==f||N==o||S&&!h){if(P(t))return h?t:{};if(W=function(t){return"function"!=typeof t.constructor||Jt(t)?{}:(e=it(t),Kt(e)?st(e):{});var e}(S?{}:t),!e)return function(t,e){return St(t,Dt(t),e)}(t,function(t,e){return t&&St(e,Vt(e),t)}(W,t))}else{if(!C[N])return h?t:{};W=function(t,e,r,n){var o=t.constructor;switch(e){case w:return Nt(t);case i:case s:return new o(+t);case v:return function(t,e){var r=e?Nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case _:case T:case O:case A:case j:case $:case E:case I:case M:return function(t,e){var r=e?Nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case c:return function(t,e,r){return J(e?r(k(t),!0):k(t),B,new t.constructor)}(t,n,r);case g:case m:return new o(t);case p:return function(t){var e=new t.constructor(t.source,R.exec(t));return e.lastIndex=t.lastIndex,e}(t);case y:return function(t,e,r){return J(e?r(U(t),!0):U(t),H,new t.constructor)}(t,n,r);case d:return a=t,At?Object(At.call(a)):{}}var a}(t,N,Ft,e)}}b||(b=new It);var L=b.get(t);if(L)return L;if(b.set(t,W),!F)var x=r?function(t){return function(t,e,r){var n=e(t);return qt(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,Vt,Dt)}(t):Vt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(x||t,(function(o,i){x&&(o=t[i=o]),Rt(W,i,Ft(o,e,r,n,i,t,b))})),W}function Ct(t){return!(!Kt(t)||(e=t,Q&&Q in e))&&(Zt(t)||P(t)?et:W).test(Pt(t));var e}function Nt(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function St(t,e,r,n){r||(r={});for(var o=-1,i=e.length;++o<i;){var s=e[o],a=n?n(r[s],t[s],s,r,t):void 0;Rt(r,s,void 0===a?t[s]:a)}return r}function Lt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function xt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Ct(r)?r:void 0}jt.prototype.clear=function(){this.__data__=dt?dt(null):{}},jt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},jt.prototype.get=function(t){var e=this.__data__;if(dt){var n=e[t];return n===r?void 0:n}return Y.call(e,t)?e[t]:void 0},jt.prototype.has=function(t){var e=this.__data__;return dt?void 0!==e[t]:Y.call(e,t)},jt.prototype.set=function(t,e){return this.__data__[t]=dt&&void 0===e?r:e,this},$t.prototype.clear=function(){this.__data__=[]},$t.prototype.delete=function(t){var e=this.__data__,r=Wt(e,t);return!(r<0)&&(r==e.length-1?e.pop():ut.call(e,r,1),!0)},$t.prototype.get=function(t){var e=this.__data__,r=Wt(e,t);return r<0?void 0:e[r][1]},$t.prototype.has=function(t){return Wt(this.__data__,t)>-1},$t.prototype.set=function(t,e){var r=this.__data__,n=Wt(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},Et.prototype.clear=function(){this.__data__={hash:new jt,map:new(ht||$t),string:new jt}},Et.prototype.delete=function(t){return Lt(this,t).delete(t)},Et.prototype.get=function(t){return Lt(this,t).get(t)},Et.prototype.has=function(t){return Lt(this,t).has(t)},Et.prototype.set=function(t,e){return Lt(this,t).set(t,e),this},It.prototype.clear=function(){this.__data__=new $t},It.prototype.delete=function(t){return this.__data__.delete(t)},It.prototype.get=function(t){return this.__data__.get(t)},It.prototype.has=function(t){return this.__data__.has(t)},It.prototype.set=function(t,e){var r=this.__data__;if(r instanceof $t){var n=r.__data__;if(!ht||n.length<199)return n.push([t,e]),this;r=this.__data__=new Et(n)}return r.set(t,e),this};var Dt=lt?q(lt,Object):function(){return[]},Bt=function(t){return tt.call(t)};function Ht(t,e){return!!(e=null==e?n:e)&&("number"==typeof t||F.test(t))&&t>-1&&t%1==0&&t<e}function Jt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||V)}function Pt(t){if(null!=t){try{return X.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function kt(t,e){return t===e||t!=t&&e!=e}(ft&&Bt(new ft(new ArrayBuffer(1)))!=v||ht&&Bt(new ht)!=c||pt&&Bt(pt.resolve())!=h||yt&&Bt(new yt)!=y||mt&&Bt(new mt)!=b)&&(Bt=function(t){var e=tt.call(t),r=e==f?t.constructor:void 0,n=r?Pt(r):void 0;if(n)switch(n){case bt:return v;case wt:return c;case vt:return h;case _t:return y;case Tt:return b}return e});var qt=Array.isArray;function Ut(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=n}(t.length)&&!Zt(t)}var zt=ct||function(){return!1};function Zt(t){var e=Kt(t)?tt.call(t):"";return e==u||e==l}function Kt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Vt(t){return Ut(t)?Mt(t):function(t){if(!Jt(t))return gt(t);var e=[];for(var r in Object(t))Y.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return Ft(t,!0,!0)}}(u,u.exports);
28
47
  /**
29
- * @name string-left-right
30
- * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
31
- * @version 5.0.6
48
+ * @name ranges-merge
49
+ * @fileoverview Merge and sort string index ranges
50
+ * @version 8.0.12
32
51
  * @author Roy Revelt, Codsen Ltd
33
52
  * @license MIT
34
- * {@link https://codsen.com/os/string-left-right/}
53
+ * {@link https://codsen.com/os/ranges-merge/}
35
54
  */
36
- const l=" ";function c(t,e=0){return function({str:t,idx:e=0,stopAtNewlines:r=!1,stopAtRawNbsp:n=!1}){if("string"!=typeof t||!t.length)return null;if(e&&"number"==typeof e||(e=0),!t[e+1])return null;if(t[e+1]&&(t[e+1].trim()||r&&"\n\r".includes(t[e+1])||n&&t[e+1]===l))return e+1;if(t[e+2]&&(t[e+2].trim()||r&&"\n\r".includes(t[e+2])||n&&t[e+2]===l))return e+2;for(let o=e+1,i=t.length;o<i;o++)if(t[o].trim()||r&&"\n\r".includes(t[o])||n&&t[o]===l)return o;return null}({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function g(t,e=0){return function({str:t,idx:e,stopAtNewlines:r,stopAtRawNbsp:n}){if("string"!=typeof t||!t.length)return null;if(e&&"number"==typeof e||(e=0),e<1)return null;if(t[~-e]&&(t[~-e].trim()||r&&"\n\r".includes(t[~-e])||n&&t[~-e]===l))return~-e;if(t[e-2]&&(t[e-2].trim()||r&&"\n\r".includes(t[e-2])||n&&t[e-2]===l))return e-2;for(let o=e;o--;)if(t[o]&&(t[o].trim()||r&&"\n\r".includes(t[o])||n&&t[o]===l))return o;return null}({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}
37
- /**
38
- * @name string-collapse-leading-whitespace
39
- * @fileoverview Collapse the leading and trailing whitespace of a string
40
- * @version 6.0.6
41
- * @author Roy Revelt, Codsen Ltd
42
- * @license MIT
43
- * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
44
- */function f(t,e=1){function r(t){return Array.from(t).reverse().join("")}function n(t,e,r){const n=r?"\n":"\r",o=r?"\r":"\n";if(!t)return t;let i=0,s="";for(let r=0,a=t.length;r<a;r++)(t[r]===n||t[r]===o&&t[r-1]!==n)&&i++,"\r\n".includes(t[r])||" "===t[r]?" "===t[r]?s+=t[r]:t[r]===n?i<=e&&(s+=t[r],t[r+1]===o&&(s+=t[r+1],r++)):t[r]===o&&(!t[r-1]||t[r-1]!==n)&&i<=e&&(s+=t[r]):t[r+1]||i||(s+=" ");return s}if("string"==typeof t&&t.length){let o=1;"number"==typeof+e&&Number.isInteger(+e)&&+e>=0&&(o=+e);let i="",s="";if(t.trim()){if(!t[0].trim())for(let e=0,r=t.length;e<r;e++)if(t[e].trim()){i=t.slice(0,e);break}}else i=t;if(t.trim()&&(""===t.slice(-1).trim()||" "===t.slice(-1)))for(let e=t.length;e--;)if(t[e].trim()){s=t.slice(e+1);break}return`${n(i,o,!1)}${t.trim()}${r(n(r(s),o,!0))}`}return t}
45
55
  /**
46
56
  * @name ranges-push
47
57
  * @fileoverview Gather string index ranges
48
- * @version 6.0.6
58
+ * @version 6.0.12
49
59
  * @author Roy Revelt, Codsen Ltd
50
60
  * @license MIT
51
61
  * {@link https://codsen.com/os/ranges-push/}
52
- */const h={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function p(t,e){if(!Array.isArray(t)||!t.length)return t;const r={...h,...e};let n,o;if(r.strictlyTwoElementsInRangeArrays&&!t.filter((t=>t)).every(((t,e)=>2===t.length||(n=e,o=t.length,!1))))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(t[n],null,4)}) has not two but ${o} elements!`);if(!t.filter((t=>t)).every(((t,e)=>!(!Number.isInteger(t[0])||t[0]<0||!Number.isInteger(t[1])||t[1]<0)||(n=e,!1))))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(t[n],null,4)}) does not consist of only natural numbers!`);const i=t.filter((t=>t)).length**2;let s=0;return Array.from(t).filter((t=>t)).sort(((t,e)=>(r.progressFn&&(s+=1,r.progressFn(Math.floor(100*s/i))),t[0]===e[0]?t[1]<e[1]?-1:t[1]>e[1]?1:0:t[0]<e[0]?-1:1)))}const y={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function m(t){return null!=t}function d(t){return Number.isInteger(t)&&t>=0}function b(t){return"string"==typeof t}const w={limitToBeAddedWhitespace:!1,limitLinebreaksCount:1,mergeType:1};class v{constructor(t){const e={...w,...t};if(e.mergeType&&1!==e.mergeType&&2!==e.mergeType)if(b(e.mergeType)&&"1"===e.mergeType.trim())e.mergeType=1;else{if(!b(e.mergeType)||"2"!==e.mergeType.trim())throw new Error(`ranges-push: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof e.mergeType}", equal to ${JSON.stringify(e.mergeType,null,4)}`);e.mergeType=2}this.opts=e,this.ranges=[]}ranges;opts;add(t,e,r){if(null==t&&null==e)return;if(m(t)&&!m(e)){if(Array.isArray(t)){if(t.length){if(t.some((t=>Array.isArray(t))))return void t.forEach((t=>{Array.isArray(t)&&this.add(...t)}));t.length&&d(+t[0])&&d(+t[1])&&this.add(...t)}return}throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_12] the first input argument, "from" is set (${JSON.stringify(t,null,0)}) but second-one, "to" is not (${JSON.stringify(e,null,0)})`)}if(!m(t)&&m(e))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_13] the second input argument, "to" is set (${JSON.stringify(e,null,0)}) but first-one, "from" is not (${JSON.stringify(t,null,0)})`);const n=+t,o=+e;if(d(r)&&(r=String(r)),!d(n)||!d(o))throw d(n)&&n>=0?new TypeError(`ranges-push/Ranges/add(): [THROW_ID_10] "to" value, the second input argument, must be a natural number or zero! Currently it's of a type "${typeof o}" equal to: ${JSON.stringify(o,null,4)}`):new TypeError(`ranges-push/Ranges/add(): [THROW_ID_09] "from" value, the first input argument, must be a natural number or zero! Currently it's of a type "${typeof n}" equal to: ${JSON.stringify(n,null,4)}`);if(m(r)&&!b(r)&&!d(r))throw new TypeError(`ranges-push/Ranges/add(): [THROW_ID_08] The third argument, the value to add, was given not as string but ${typeof r}, equal to:\n${JSON.stringify(r,null,4)}`);if(m(this.ranges)&&Array.isArray(this.last())&&n===this.last()[1]){if(this.last()[1]=o,this.last(),null!==this.last()[2]&&m(r)){let t=!(this.last()[2]&&this.last()[2].length>0)||this.opts&&this.opts.mergeType&&1!==this.opts.mergeType?r:this.last()[2]+r;this.opts.limitToBeAddedWhitespace&&(t=f(t,this.opts.limitLinebreaksCount)),b(t)&&!t.length||(this.last()[2]=t)}}else{this.ranges||(this.ranges=[]);const t=void 0===r||b(r)&&!r.length?[n,o]:[n,o,r&&this.opts.limitToBeAddedWhitespace?f(r,this.opts.limitLinebreaksCount):r];this.ranges.push(t)}}push(t,e,r){this.add(t,e,r)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=function(t,e){function r(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!Array.isArray(t)||!t.length)return null;let n;if(e){if(!r(e))throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:\n${JSON.stringify(e,null,4)} (type ${typeof e})`);if(n={...y,...e},n.progressFn&&r(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&"function"!=typeof n.progressFn)throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(n.mergeType&&1!=+n.mergeType&&2!=+n.mergeType)throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if("boolean"!=typeof n.joinRangesThatTouchEdges)throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else n={...y};const o=t.filter((t=>t)).map((t=>[...t])).filter((t=>void 0!==t[2]||t[0]!==t[1]));let i,s,a;if(i=n.progressFn?p(o,{progressFn:t=>{a=Math.floor(t/5),a!==s&&(s=a,n.progressFn(a))}}):p(o),!i)return null;const u=i.length-1;for(let t=u;t>0;t--)n.progressFn&&(a=Math.floor(78*(1-t/u))+21,a!==s&&a>s&&(s=a,n.progressFn(a))),(i[t][0]<=i[t-1][0]||!n.joinRangesThatTouchEdges&&i[t][0]<i[t-1][1]||n.joinRangesThatTouchEdges&&i[t][0]<=i[t-1][1])&&(i[t-1][0]=Math.min(i[t][0],i[t-1][0]),i[t-1][1]=Math.max(i[t][1],i[t-1][1]),void 0!==i[t][2]&&(i[t-1][0]>=i[t][0]||i[t-1][1]<=i[t][1])&&null!==i[t-1][2]&&(null===i[t][2]&&null!==i[t-1][2]?i[t-1][2]=null:null!=i[t-1][2]?2==+n.mergeType&&i[t-1][0]===i[t][0]?i[t-1][2]=i[t][2]:i[t-1][2]+=i[t][2]:i[t-1][2]=i[t][2]),i.splice(t,1),t=i.length);return i.length?i:null}(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map((t=>m(t[2])?[t[0],t[1],f(t[2],this.opts.limitLinebreaksCount)]:t)):this.ranges):null}wipe(){this.ranges=[]}replace(t){if(Array.isArray(t)&&t.length){if(!Array.isArray(t[0])||!d(t[0][0]))throw new Error(`ranges-push/Ranges/replace(): [THROW_ID_11] Single range was given but we expected array of arrays! The first element, ${JSON.stringify(t[0],null,4)} should be an array and its first element should be an integer, a string index.`);this.ranges=Array.from(t)}else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}}
62
+ */
53
63
  /**
54
64
  * @name ranges-sort
55
65
  * @fileoverview Sort string index ranges
56
- * @version 5.0.6
66
+ * @version 5.0.12
57
67
  * @author Roy Revelt, Codsen Ltd
58
68
  * @license MIT
59
69
  * {@link https://codsen.com/os/ranges-sort/}
60
- */const _={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function T(t,e){if(!Array.isArray(t)||!t.length)return t;const r={..._,...e};let n,o;if(r.strictlyTwoElementsInRangeArrays&&!t.filter((t=>t)).every(((t,e)=>2===t.length||(n=e,o=t.length,!1))))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${n}th range (${JSON.stringify(t[n],null,4)}) has not two but ${o} elements!`);if(!t.filter((t=>t)).every(((t,e)=>!(!Number.isInteger(t[0])||t[0]<0||!Number.isInteger(t[1])||t[1]<0)||(n=e,!1))))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${n}th range (${JSON.stringify(t[n],null,4)}) does not consist of only natural numbers!`);const i=t.filter((t=>t)).length**2;let s=0;return Array.from(t).filter((t=>t)).sort(((t,e)=>(r.progressFn&&(s+=1,r.progressFn(Math.floor(100*s/i))),t[0]===e[0]?t[1]<e[1]?-1:t[1]>e[1]?1:0:t[0]<e[0]?-1:1)))}
70
+ */
61
71
  /**
62
- * @name ranges-merge
63
- * @fileoverview Merge and sort string index ranges
64
- * @version 8.0.6
72
+ * @name string-collapse-leading-whitespace
73
+ * @fileoverview Collapse the leading and trailing whitespace of a string
74
+ * @version 6.0.12
65
75
  * @author Roy Revelt, Codsen Ltd
66
76
  * @license MIT
67
- * {@link https://codsen.com/os/ranges-merge/}
68
- */const O={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function A(t,e){function r(t){return t&&"object"==typeof t&&!Array.isArray(t)}if(!Array.isArray(t)||!t.length)return null;let n;if(e){if(!r(e))throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:\n${JSON.stringify(e,null,4)} (type ${typeof e})`);if(n={...O,...e},n.progressFn&&r(n.progressFn)&&!Object.keys(n.progressFn).length)n.progressFn=null;else if(n.progressFn&&"function"!=typeof n.progressFn)throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof n.progressFn}", equal to ${JSON.stringify(n.progressFn,null,4)}`);if(n.mergeType&&1!=+n.mergeType&&2!=+n.mergeType)throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof n.mergeType}", equal to ${JSON.stringify(n.mergeType,null,4)}`);if("boolean"!=typeof n.joinRangesThatTouchEdges)throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof n.joinRangesThatTouchEdges}", equal to ${JSON.stringify(n.joinRangesThatTouchEdges,null,4)}`)}else n={...O};const o=t.filter((t=>t)).map((t=>[...t])).filter((t=>void 0!==t[2]||t[0]!==t[1]));let i,s,a;if(i=n.progressFn?T(o,{progressFn:t=>{a=Math.floor(t/5),a!==s&&(s=a,n.progressFn(a))}}):T(o),!i)return null;const u=i.length-1;for(let t=u;t>0;t--)n.progressFn&&(a=Math.floor(78*(1-t/u))+21,a!==s&&a>s&&(s=a,n.progressFn(a))),(i[t][0]<=i[t-1][0]||!n.joinRangesThatTouchEdges&&i[t][0]<i[t-1][1]||n.joinRangesThatTouchEdges&&i[t][0]<=i[t-1][1])&&(i[t-1][0]=Math.min(i[t][0],i[t-1][0]),i[t-1][1]=Math.max(i[t][1],i[t-1][1]),void 0!==i[t][2]&&(i[t-1][0]>=i[t][0]||i[t-1][1]<=i[t][1])&&null!==i[t-1][2]&&(null===i[t][2]&&null!==i[t-1][2]?i[t-1][2]=null:null!=i[t-1][2]?2==+n.mergeType&&i[t-1][0]===i[t][0]?i[t-1][2]=i[t][2]:i[t-1][2]+=i[t][2]:i[t-1][2]=i[t][2]),i.splice(t,1),t=i.length);return i.length?i:null}
77
+ * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
78
+ */
69
79
  /**
70
- * @name ranges-apply
71
- * @fileoverview Take an array of string index ranges, delete/replace the string according to them
72
- * @version 6.0.6
80
+ * @name string-left-right
81
+ * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
82
+ * @version 5.0.12
73
83
  * @author Roy Revelt, Codsen Ltd
74
84
  * @license MIT
75
- * {@link https://codsen.com/os/ranges-apply/}
76
- */function j(t,e,r){let n,o=0,i=0;if(0===arguments.length)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if("string"!=typeof t)throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(e&&!Array.isArray(e))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(r&&"function"!=typeof r)throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!e||!e.filter((t=>t)).length)return t;n=Array.isArray(e)&&Number.isInteger(e[0])&&Number.isInteger(e[1])?[Array.from(e)]:Array.from(e);const s=n.length;let a=0;n.filter((t=>t)).forEach(((t,e)=>{if(r&&(o=Math.floor(a/s*10),o!==i&&(i=o,r(o))),!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${e}th element not an array: ${JSON.stringify(t,null,4)}, which is ${typeof t}`);if(!Number.isInteger(t[0])){if(!Number.isInteger(+t[0])||+t[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${e}th element, array ${JSON.stringify(t,null,0)}. Its first element is not an integer, string index, but ${typeof t[0]}, equal to: ${JSON.stringify(t[0],null,4)}.`);n[e][0]=+n[e][0]}if(!Number.isInteger(t[1])){if(!Number.isInteger(+t[1])||+t[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${e}th element, array ${JSON.stringify(t,null,0)}. Its second element is not an integer, string index, but ${typeof t[1]}, equal to: ${JSON.stringify(t[1],null,4)}.`);n[e][1]=+n[e][1]}a+=1}));const u=A(n,{progressFn:t=>{r&&(o=10+Math.floor(t/10),o!==i&&(i=o,r(o)))}}),l=Array.isArray(u)?u.length:0;if(l>0){const e=t.slice(u[l-1][1]);t=u.reduce(((e,n,s,a)=>{r&&(o=20+Math.floor(s/l*80),o!==i&&(i=o,r(o)));return e+t.slice(0===s?0:a[s-1][1],a[s][0])+(a[s][2]||"")}),""),t+=e}return t}const $=" ",E="&nbsp;",I="\\00A0",M="\\u00A0",R=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],W=[{heads:"{{",tails:"}}"}],F=[{heads:["<%","<%=","<%-"],tails:["%>","=%>","-%>"]}],C=["abbr","address","area","article","aside","audio","base","bdi","bdo","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","param","picture","pre","progress","rb","rp","rt","rtc","ruby","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","ul","var","video","wbr","xml"],N={removeWidowPreventionMeasures:!1,convertEntities:!0,targetLanguage:"html",UKPostcodes:!1,hyphens:!0,minWordCount:4,minCharCount:5,ignore:[],reportProgressFunc:null,reportProgressFuncFrom:0,reportProgressFuncTo:100,tagRanges:[]};t.defaults=N,t.removeWidows=function(t,e){const r=Date.now();if("string"!=typeof t)throw void 0===t?new Error("string-remove-widows: [THROW_ID_01] the first input argument is completely missing! It should be given as string."):new Error(`string-remove-widows: [THROW_ID_02] the first input argument must be string! It was given as "${typeof t}", equal to:\n${JSON.stringify(t,null,4)}`);if(e&&"object"!=typeof e)throw new Error(`string-remove-widows: [THROW_ID_03] the second input argument, options object, should be a plain object but it was given as type ${typeof e}, equal to ${JSON.stringify(e,null,4)}`);const n=Array.isArray,o=t.length,i=new v({mergeType:2}),a=["."],u=/[A-Z]{1,2}[0-9][0-9A-Z]?$/,l=/^[0-9][A-Z]{2}/,f=.06;let h,p,y,m,d,b,w,_,T,O=0,A=0,S=0;const L={...N,...e},x={removeWidows:!1,convertEntities:!1};if(!L.ignore||!n(L.ignore)&&"string"!=typeof L.ignore)L.ignore=[];else if("string"==typeof L.ignore&&(L.ignore=[L.ignore]),L.ignore.includes("all"))L.ignore=L.ignore.concat(R.concat(F));else if(L.ignore.some((t=>"string"==typeof t))){let t=[];L.ignore=L.ignore.filter((e=>"string"==typeof e&&e.length?(["nunjucks","jinja","liquid"].includes(e.trim().toLowerCase())?t=t.concat(R):["hugo"].includes(e.trim().toLowerCase())?t=t.concat(W):["hexo"].includes(e.trim().toLowerCase())&&(t=t.concat(F)),!1):"object"==typeof e||void 0)),t.length&&(L.ignore=L.ignore.concat(t))}let D;function B(e,r){let n=$;L.removeWidowPreventionMeasures?n=" ":L.convertEntities&&(n=E,"string"==typeof L.targetLanguage&&("css"===L.targetLanguage.trim().toLowerCase()?n=I:"js"===L.targetLanguage.trim().toLowerCase()&&(n=M))),t.slice(e,r)!==n&&i.push(e,r,n)}function H(){A=0,S=0,p=void 0,y=void 0,m=void 0,d=void 0,b=void 0,w=void 0}L.reportProgressFunc&&(D=Math.floor(L.reportProgressFuncTo-(L.reportProgressFuncTo-L.reportProgressFuncFrom)*f-L.reportProgressFuncFrom)),H();for(let e=0;e<=o;e++){if(!_&&n(L.ignore)&&L.ignore.length&&L.ignore.some(((r,o)=>{if(n(r.heads)&&r.heads.some((r=>t.startsWith(r,e)))||"string"==typeof r.heads&&t.startsWith(r.heads,e))return A+=1,_=L.ignore[o].tails,!0})),!_&&T&&T===e&&(A+=1,T=void 0),"function"==typeof L.reportProgressFunc&&(h=L.reportProgressFuncFrom+Math.floor(e/o*(D||1)),h!==O&&(O=h,L.reportProgressFunc(h))),!_&&e&&t[e]&&t[e].trim()&&(!t[e-1]||t[e-1]&&!t[e-1].trim())&&(d=e),!_&&t[e]&&t[e].trim()&&(S+=1),_||!L.hyphens||!("-—–".includes(t[e])||t.startsWith("&ndash;",e)||t.startsWith("\\2013",e)||t.startsWith("\\u2013",e)||t.startsWith("&mdash;",e)||t.startsWith("\\2014",e)||t.startsWith("\\u2014",e))||!t[e+1]||t[e+1].trim()&&"&"!==t[e]||t[e-1]&&!t[e-1].trim()&&t[g(t,e)]&&(B(g(t,e)+1,e),x.removeWidows=!0),_||!t.startsWith("&nbsp;",e)&&!t.startsWith("&#160;",e)||(b=e,w=e+6,t[e+6]&&t[e+6].trim()&&(T=e+6),L.convertEntities?"css"!==L.targetLanguage&&"js"!==L.targetLanguage||(i.push(e,e+6,"css"===L.targetLanguage?I:M),x.convertEntities=!0):(i.push(e,e+6,$),x.convertEntities=!0)),!_&&t[e+4]&&"\\"===t[e]&&"0"===t[e+1]&&"0"===t[e+2]&&"A"===t[e+3].toUpperCase()&&"0"===t[e+4]&&(b=e,w=e+5,t[e+5]&&t[e+5].trim()&&(T=e+5),L.convertEntities?"html"!==L.targetLanguage&&"js"!==L.targetLanguage||(i.push(e,e+5,"html"===L.targetLanguage?E:M),x.convertEntities=!0):(i.push(e,e+5,$),x.convertEntities=!0)),!_&&"\\"===t[e]&&t[e+1]&&"u"===t[e+1].toLowerCase()&&"0"===t[e+2]&&"0"===t[e+3]&&t[e+4]&&"A"===t[e+4].toUpperCase()&&"0"===t[e+5]&&(b=e,w=e+6,t[e+6]&&t[e+6].trim()&&(T=e+6),L.convertEntities?"html"!==L.targetLanguage&&"css"!==L.targetLanguage||i.push(e,e+6,"html"===L.targetLanguage?E:I):i.push(e,e+6,$)),_||t[e]!==$||(b=e,w=e+1,L.convertEntities&&i.push(e,e+1,"css"===L.targetLanguage?I:"js"===L.targetLanguage?M:E)),_||!t[e]||!t[e].trim()||t[e-1]&&t[e-1].trim()||(A+=1),!_&&(!t[e]||"\r\n".includes(t[e])||("\n"===t[e]||"\r"===t[e]||"\r"===t[e]&&"\n"===t[e+1])&&g(t,e)&&a.includes(t[g(t,e)]))){if((!L.minWordCount||A>=L.minWordCount)&&(!L.minCharCount||S>=L.minCharCount)){let t,e;void 0!==m&&void 0!==d&&void 0!==b&&void 0!==w?m>b?(t=m,e=d):(t=b,e=w):void 0!==m&&void 0!==d?(t=m,e=d):void 0!==b&&void 0!==w&&(t=b,e=w),t&&e||!p||!y||(t=p,e=y),t&&e&&(B(t,e),x.removeWidows=!0)}H()}let r;L.UKPostcodes&&t[e]&&!t[e].trim()&&t[e-1]&&t[e-1].trim()&&u.test(t.slice(0,e))&&t[c(t,e)]&&l.test(t.slice(c(t,e)))&&(B(e,c(t,e)),x.removeWidows=!0),_||!t[e]||t[e].trim()||!t[e-1]||!t[e-1].trim()||!(void 0===m||t[m-1]&&t[m-1].trim())||"/>".includes(t[c(t,e)])||t.slice(0,e).trim().endsWith("br")||t.slice(0,e).trim().endsWith("hr")||t.slice(0,e).endsWith("<")&&C.some((r=>t.startsWith(r,c(t,e))))||(p=m,y=d,m=e,d=void 0,void 0===b&&void 0===w||(b=void 0,w=void 0)),_&&("string"!=typeof _||_.length&&!t.startsWith(_,e)?!n(_)||_.length&&!_.some((n=>{if(t.startsWith(n,e))return r=n,!0}))||(_=void 0,e+=r.length,n(L.ignore)&&L.ignore.length&&t[e+1]&&L.ignore.some((r=>s(t,e,r.tails,{trimBeforeMatching:!0,cb:(r,n,o)=>(o&&(e=o-1,t[e+1]&&t[e+1].trim()&&(A+=1)),!0)})))):_=void 0),t[e]&&"\r\n".includes(t[e])&&(A=0,S=0),n(L.tagRanges)&&L.tagRanges.length&&L.tagRanges.some((t=>{if(e>=t[0]&&e<=t[1]&&t[1]-1>e)return e=t[1]-1,!0}))}return j(t,i.current()).split("").forEach(((t,e)=>{})),{res:j(t,i.current(),L.reportProgressFunc?t=>{h=Math.floor(.94*(L.reportProgressFuncTo-L.reportProgressFuncFrom)+t/100*(L.reportProgressFuncTo-L.reportProgressFuncFrom)*f),h!==O&&(O=h,L.reportProgressFunc(h))}:void 0),ranges:i.current(),log:{timeTakenInMilliseconds:Date.now()-r},whatWasDone:x}},t.version="3.0.6",Object.defineProperty(t,"__esModule",{value:!0})}));
85
+ * {@link https://codsen.com/os/string-left-right/}
86
+ */
87
+ /**
88
+ * @name string-match-left-right
89
+ * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
90
+ * @version 8.0.12
91
+ * @author Roy Revelt, Codsen Ltd
92
+ * @license MIT
93
+ * {@link https://codsen.com/os/string-match-left-right/}
94
+ */
@@ -1,6 +1,7 @@
1
1
  // Quick Take
2
2
 
3
3
  import { strict as assert } from "assert";
4
+
4
5
  import { removeWidows } from "../dist/string-remove-widows.esm.js";
5
6
 
6
7
  const { ranges, res } = removeWidows("Some text with many words on one line.");
@@ -1,7 +1,8 @@
1
1
  // Widow word removal from text within HTML
2
2
 
3
3
  import { strict as assert } from "assert";
4
- import { stripHtml } from "../../string-strip-html/dist/string-strip-html.esm.js";
4
+ import { stripHtml } from "string-strip-html";
5
+
5
6
  import { removeWidows } from "../dist/string-remove-widows.esm.js";
6
7
 
7
8
  const someHtml = `The quick brown fox jumps of the lazy dog.<div class="a">`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-remove-widows",
3
- "version": "3.0.6",
3
+ "version": "3.0.12",
4
4
  "description": "Helps to prevent widow words in a text",
5
5
  "keywords": [
6
6
  "against",
@@ -38,93 +38,46 @@
38
38
  },
39
39
  "types": "types/index.d.ts",
40
40
  "scripts": {
41
- "build": "rollup -c",
42
- "build:esbuild": "node '../../scripts/esbuild.js'",
43
- "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
44
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
45
- "clean_types": "../../scripts/cleanTypes.js",
46
- "dev": "rollup -c --dev",
47
- "devunittest": "npm run dev && tap --only -R 'base'",
48
- "format": "npm run lect && npm run prettier && npm run lint",
49
- "lect": "lect",
50
- "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
51
- "perf": "node perf/check",
52
- "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
53
- "republish": "npm publish || :",
54
- "tap": "tap",
55
- "pretest": "npm run build",
56
- "test": "npm run test:ci && npm run perf",
57
- "test:ci": "npm run unittest && npm run test:examples && npm run format",
58
- "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
59
- "tsc": "tsc",
60
- "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
41
+ "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
42
+ "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
43
+ "devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
44
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
45
+ "examples": "node '../../ops/scripts/run-examples.js'",
46
+ "lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
47
+ "letspublish": "yarn publish || :",
48
+ "lint": "eslint . --fix",
49
+ "perf": "node perf/check.js",
50
+ "prepare": "echo 'ready'",
51
+ "prettier": "prettier",
52
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
53
+ "pretest": "yarn run lect && yarn run build",
54
+ "test": "yarn run devtest",
55
+ "unit": "uvu test"
61
56
  },
62
- "tap": {
63
- "check-coverage": false,
64
- "node-arg": [
65
- "--no-warnings",
66
- "--experimental-loader",
67
- "@istanbuljs/esm-loader-hook"
57
+ "engines": {
58
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
59
+ },
60
+ "c8": {
61
+ "check-coverage": true,
62
+ "exclude": [
63
+ "**/test/**/*.*"
68
64
  ],
69
- "timeout": 0
65
+ "lines": 100
70
66
  },
71
67
  "lect": {
72
68
  "licence": {
73
69
  "extras": [
74
70
  ""
75
71
  ]
76
- },
77
- "req": "{ removeWidows, defaults, version }",
78
- "various": {
79
- "devDependencies": []
80
72
  }
81
73
  },
82
74
  "dependencies": {
83
- "@babel/runtime": "^7.16.3",
84
- "ranges-apply": "^6.0.6",
85
- "ranges-push": "^6.0.6",
86
- "string-left-right": "^5.0.6",
87
- "string-match-left-right": "^8.0.6"
75
+ "ranges-apply": "^6.0.12",
76
+ "ranges-push": "^6.0.12",
77
+ "string-left-right": "^5.0.12",
78
+ "string-match-left-right": "^8.0.12"
88
79
  },
89
80
  "devDependencies": {
90
- "@babel/cli": "^7.16.0",
91
- "@babel/core": "^7.16.0",
92
- "@babel/node": "^7.16.0",
93
- "@babel/plugin-external-helpers": "^7.16.0",
94
- "@babel/plugin-proposal-class-properties": "^7.16.0",
95
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
96
- "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
97
- "@babel/plugin-proposal-optional-chaining": "^7.16.0",
98
- "@babel/plugin-transform-runtime": "^7.16.4",
99
- "@babel/preset-env": "^7.16.4",
100
- "@babel/preset-typescript": "^7.16.0",
101
- "@babel/register": "^7.16.0",
102
- "@istanbuljs/esm-loader-hook": "^0.1.2",
103
- "@rollup/plugin-babel": "^5.3.0",
104
- "@rollup/plugin-commonjs": "^21.0.1",
105
- "@rollup/plugin-json": "^4.1.0",
106
- "@rollup/plugin-node-resolve": "^13.0.6",
107
- "@rollup/plugin-strip": "^2.1.0",
108
- "@rollup/plugin-typescript": "^8.3.0",
109
- "@types/node": "^16.11.9",
110
- "@types/tap": "^15.0.5",
111
- "@typescript-eslint/eslint-plugin": "^5.4.0",
112
- "@typescript-eslint/parser": "^5.4.0",
113
- "core-js": "^3.19.1",
114
- "cross-env": "^7.0.3",
115
- "eslint": "^8.3.0",
116
- "lect": "^0.18.6",
117
- "rollup": "^2.60.0",
118
- "rollup-plugin-ascii": "^0.0.3",
119
- "rollup-plugin-banner": "^0.2.1",
120
- "rollup-plugin-cleanup": "^3.2.1",
121
- "rollup-plugin-dts": "^4.0.1",
122
- "rollup-plugin-terser": "^7.0.2",
123
- "tap": "^15.1.2",
124
- "tslib": "^2.3.1",
125
- "typescript": "^4.5.2"
126
- },
127
- "engines": {
128
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
81
+ "string-strip-html": "^9.1.6"
129
82
  }
130
83
  }
package/types/index.d.ts CHANGED
@@ -1,37 +1,38 @@
1
- declare type Range = [from: number, to: number] | [from: number, to: number, whatToInsert: string | null | undefined];
1
+ declare type Range =
2
+ | [from: number, to: number]
3
+ | [from: number, to: number, whatToInsert: string | null | undefined];
2
4
  declare type Ranges = Range[] | null;
3
5
 
4
6
  declare const version: string;
5
-
6
7
  interface HeadsAndTailsObj {
7
- heads: string | string[];
8
- tails: string | string[];
8
+ heads: string | string[];
9
+ tails: string | string[];
9
10
  }
10
11
  interface Opts {
11
- removeWidowPreventionMeasures: boolean;
12
- convertEntities: boolean;
13
- targetLanguage: "html" | "css" | "js";
14
- UKPostcodes: boolean;
15
- hyphens: boolean;
16
- minWordCount: number;
17
- minCharCount: number;
18
- ignore: HeadsAndTailsObj[] | string | string[];
19
- reportProgressFunc: null | ((percDone: number) => void);
20
- reportProgressFuncFrom: number;
21
- reportProgressFuncTo: number;
22
- tagRanges: Range[] | null;
12
+ removeWidowPreventionMeasures: boolean;
13
+ convertEntities: boolean;
14
+ targetLanguage: "html" | "css" | "js";
15
+ UKPostcodes: boolean;
16
+ hyphens: boolean;
17
+ minWordCount: number;
18
+ minCharCount: number;
19
+ ignore: HeadsAndTailsObj[] | string | string[];
20
+ reportProgressFunc: null | ((percDone: number) => void);
21
+ reportProgressFuncFrom: number;
22
+ reportProgressFuncTo: number;
23
+ tagRanges: Range[] | null;
23
24
  }
24
25
  declare const defaults: Opts;
25
26
  interface Res {
26
- res: string;
27
- ranges: Ranges;
28
- log: {
29
- timeTakenInMilliseconds: number;
30
- };
31
- whatWasDone: {
32
- removeWidows: boolean;
33
- convertEntities: boolean;
34
- };
27
+ res: string;
28
+ ranges: Ranges;
29
+ log: {
30
+ timeTakenInMilliseconds: number;
31
+ };
32
+ whatWasDone: {
33
+ removeWidows: boolean;
34
+ convertEntities: boolean;
35
+ };
35
36
  }
36
37
  declare function removeWidows(str: string, originalOpts?: Partial<Opts>): Res;
37
38
 
package/types/util.d.ts CHANGED
@@ -10,20 +10,40 @@ declare const rawMdash = "\u2014";
10
10
  declare const encodedMdashHtml = "&mdash;";
11
11
  declare const encodedMdashCss = "\\2014";
12
12
  declare const encodedMdashJs = "\\u2014";
13
- declare const headsAndTailsJinja: ({
14
- heads: string;
15
- tails: string;
16
- } | {
17
- heads: string[];
18
- tails: string[];
19
- })[];
13
+ declare const headsAndTailsJinja: (
14
+ | {
15
+ heads: string;
16
+ tails: string;
17
+ }
18
+ | {
19
+ heads: string[];
20
+ tails: string[];
21
+ }
22
+ )[];
20
23
  declare const headsAndTailsHugo: {
21
- heads: string;
22
- tails: string;
24
+ heads: string;
25
+ tails: string;
23
26
  }[];
24
27
  declare const headsAndTailsHexo: {
25
- heads: string[];
26
- tails: string[];
28
+ heads: string[];
29
+ tails: string[];
27
30
  }[];
28
31
  declare const knownHTMLTags: string[];
29
- export { rawnbsp, encodedNbspHtml, encodedNbspCss, encodedNbspJs, rawNdash, encodedNdashHtml, encodedNdashCss, encodedNdashJs, rawMdash, encodedMdashHtml, encodedMdashCss, encodedMdashJs, headsAndTailsJinja, headsAndTailsHugo, headsAndTailsHexo, knownHTMLTags, };
32
+ export {
33
+ rawnbsp,
34
+ encodedNbspHtml,
35
+ encodedNbspCss,
36
+ encodedNbspJs,
37
+ rawNdash,
38
+ encodedNdashHtml,
39
+ encodedNdashCss,
40
+ encodedNdashJs,
41
+ rawMdash,
42
+ encodedMdashHtml,
43
+ encodedMdashCss,
44
+ encodedMdashJs,
45
+ headsAndTailsJinja,
46
+ headsAndTailsHugo,
47
+ headsAndTailsHexo,
48
+ knownHTMLTags,
49
+ };
package/examples/api.json DELETED
@@ -1 +0,0 @@
1
- {"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; removeWidows &#x7D; from \"string-remove-widows\";\n\nconst &#x7B; ranges, res &#x7D; = removeWidows(\"Some text with many words on one line.\");\n\n// see codsen.com/ranges/\nassert.deepEqual(ranges, [[32, 33, \"&nbsp;\"]]);\n\nassert.equal(res, \"Some text with many words on one&nbsp;line.\");"},"widow-word-removal-from-html.js":{"title":"Widow word removal from text within HTML","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\nimport &#x7B; removeWidows &#x7D; from \"string-remove-widows\";\n\nconst someHtml = `The quick brown fox jumps of the lazy dog.<div class=\"a\">`;\n\n// default widow word removal libs are not aware of HTML:\n// -----------------------------------------------------------------------------\n\nassert.equal(\n removeWidows(someHtml).res,\n `The quick brown fox jumps of the lazy dog.<div&nbsp;class=\"a\">` // 😱\n);\n\n// luckily, removeWidows() consumes optional HTML tag locations\nassert.equal(\n removeWidows(someHtml, &#x7B;\n tagRanges: stripHtml(someHtml)\n // remove the third argument, what to insert (\"&nbsp;\" string in these cases)\n .ranges.map(([from, to]) => [from, to]),\n &#x7D;).res,\n `The quick brown fox jumps of the lazy&nbsp;dog.<div class=\"a\">` // ✅\n);"}}