string-remove-widows 3.0.10 → 3.0.11

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,14 +26,12 @@
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
@@ -61,8 +59,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
61
59
 
62
60
  MIT License
63
61
 
64
- Copyright (c) 2010-2021 Roy Revelt and other contributors
65
-
62
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
66
63
 
67
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">
68
-
@@ -1,15 +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.10
4
+ * @version 3.0.11
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 as ee}from"string-match-left-right";import{left as N,right as w}from"string-left-right";import{Ranges as te}from"ranges-push";import{rApply as K}from"ranges-apply";var M="3.0.10";var h="\xA0",E="&nbsp;",S="\\00A0",D="\\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=D))),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:D),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:D),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"?D:E)),!s&&t[e]&&t[e].trim()&&(!t[e-1]||!t[e-1].trim())&&(g+=1),!s&&(!t[e]||`\r
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.11";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
12
  `.includes(t[e])||(t[e]===`
13
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[w(t,e)]&&Q.test(t.slice(w(t,e)))&&(C(e,w(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[w(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,w(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
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
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,7 +1,7 @@
1
1
  /**
2
2
  * @name string-remove-widows
3
3
  * @fileoverview Helps to prevent widow words in a text
4
- * @version 3.0.10
4
+ * @version 3.0.11
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-remove-widows/}
@@ -22,7 +22,7 @@ ${JSON.stringify(u,null,4)}`);let c=0,i="";if((n==null?void 0:n.trimCharsBeforeM
22
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
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
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.10";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",We=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],Qt=[{heads:"{{",tails:"}}"}],De=[{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:
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.11";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",We=[{heads:"{{",tails:"}}"},{heads:["{% if","{%- if"],tails:["{% endif","{%- endif"]},{heads:["{% for","{%- for"],tails:["{% endfor","{%- endfor"]},{heads:["{%","{%-"],tails:["%}","-%}"]},{heads:"{#",tails:"#}"}],Qt=[{heads:"{{",tails:"}}"}],De=[{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
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(We.concat(De));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(We):["hugo"].includes(N.trim().toLowerCase())?s=s.concat(Qt):["hexo"].includes(N.trim().toLowerCase())&&(s=s.concat(De)),!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
27
  `.includes(e[s])||(e[s]===`
28
28
  `||e[s]==="\r"||e[s]==="\r"&&e[s+1]===`
@@ -31,7 +31,7 @@ ${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new Error(`string-r
31
31
  /**
32
32
  * @name arrayiffy-if-string
33
33
  * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
34
- * @version 4.0.10
34
+ * @version 4.0.11
35
35
  * @author Roy Revelt, Codsen Ltd
36
36
  * @license MIT
37
37
  * {@link https://codsen.com/os/arrayiffy-if-string/}
@@ -39,7 +39,7 @@ ${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new Error(`string-r
39
39
  /**
40
40
  * @name ranges-apply
41
41
  * @fileoverview Take an array of string index ranges, delete/replace the string according to them
42
- * @version 6.0.10
42
+ * @version 6.0.11
43
43
  * @author Roy Revelt, Codsen Ltd
44
44
  * @license MIT
45
45
  * {@link https://codsen.com/os/ranges-apply/}
@@ -47,7 +47,7 @@ ${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new Error(`string-r
47
47
  /**
48
48
  * @name ranges-merge
49
49
  * @fileoverview Merge and sort string index ranges
50
- * @version 8.0.10
50
+ * @version 8.0.11
51
51
  * @author Roy Revelt, Codsen Ltd
52
52
  * @license MIT
53
53
  * {@link https://codsen.com/os/ranges-merge/}
@@ -55,7 +55,7 @@ ${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new Error(`string-r
55
55
  /**
56
56
  * @name ranges-push
57
57
  * @fileoverview Gather string index ranges
58
- * @version 6.0.10
58
+ * @version 6.0.11
59
59
  * @author Roy Revelt, Codsen Ltd
60
60
  * @license MIT
61
61
  * {@link https://codsen.com/os/ranges-push/}
@@ -63,7 +63,7 @@ ${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new Error(`string-r
63
63
  /**
64
64
  * @name ranges-sort
65
65
  * @fileoverview Sort string index ranges
66
- * @version 5.0.10
66
+ * @version 5.0.11
67
67
  * @author Roy Revelt, Codsen Ltd
68
68
  * @license MIT
69
69
  * {@link https://codsen.com/os/ranges-sort/}
@@ -71,7 +71,7 @@ ${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new Error(`string-r
71
71
  /**
72
72
  * @name string-collapse-leading-whitespace
73
73
  * @fileoverview Collapse the leading and trailing whitespace of a string
74
- * @version 6.0.10
74
+ * @version 6.0.11
75
75
  * @author Roy Revelt, Codsen Ltd
76
76
  * @license MIT
77
77
  * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
@@ -79,7 +79,7 @@ ${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new Error(`string-r
79
79
  /**
80
80
  * @name string-left-right
81
81
  * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
82
- * @version 5.0.10
82
+ * @version 5.0.11
83
83
  * @author Roy Revelt, Codsen Ltd
84
84
  * @license MIT
85
85
  * {@link https://codsen.com/os/string-left-right/}
@@ -87,7 +87,7 @@ ${JSON.stringify(e,null,4)}`);if(t&&typeof t!="object")throw new Error(`string-r
87
87
  /**
88
88
  * @name string-match-left-right
89
89
  * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
90
- * @version 8.0.10
90
+ * @version 8.0.11
91
91
  * @author Roy Revelt, Codsen Ltd
92
92
  * @license MIT
93
93
  * {@link https://codsen.com/os/string-match-left-right/}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-remove-widows",
3
- "version": "3.0.10",
3
+ "version": "3.0.11",
4
4
  "description": "Helps to prevent widow words in a text",
5
5
  "keywords": [
6
6
  "against",
@@ -40,13 +40,15 @@
40
40
  "scripts": {
41
41
  "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
42
42
  "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
43
- "dts": "rollup -c",
43
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
44
44
  "examples": "node '../../ops/scripts/run-examples.js'",
45
45
  "lect": "node '../../ops/lect/lect.js'",
46
46
  "letspublish": "yarn publish || :",
47
47
  "lint": "eslint . --fix",
48
48
  "perf": "node perf/check.js",
49
49
  "prepare": "echo 'ready'",
50
+ "prettier": "prettier",
51
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
50
52
  "pretest": "yarn run lect && yarn run build",
51
53
  "test": "c8 yarn run unit && yarn run examples && yarn run lint",
52
54
  "unit": "uvu test"
@@ -69,12 +71,12 @@
69
71
  }
70
72
  },
71
73
  "dependencies": {
72
- "ranges-apply": "^6.0.10",
73
- "ranges-push": "^6.0.10",
74
- "string-left-right": "^5.0.10",
75
- "string-match-left-right": "^8.0.10"
74
+ "ranges-apply": "^6.0.11",
75
+ "ranges-push": "^6.0.11",
76
+ "string-left-right": "^5.0.11",
77
+ "string-match-left-right": "^8.0.11"
76
78
  },
77
79
  "devDependencies": {
78
- "string-strip-html": "^9.1.4"
80
+ "string-strip-html": "^9.1.5"
79
81
  }
80
82
  }
package/types/index.d.ts CHANGED
@@ -1,36 +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
7
  interface HeadsAndTailsObj {
6
- heads: string | string[];
7
- tails: string | string[];
8
+ heads: string | string[];
9
+ tails: string | string[];
8
10
  }
9
11
  interface Opts {
10
- removeWidowPreventionMeasures: boolean;
11
- convertEntities: boolean;
12
- targetLanguage: "html" | "css" | "js";
13
- UKPostcodes: boolean;
14
- hyphens: boolean;
15
- minWordCount: number;
16
- minCharCount: number;
17
- ignore: HeadsAndTailsObj[] | string | string[];
18
- reportProgressFunc: null | ((percDone: number) => void);
19
- reportProgressFuncFrom: number;
20
- reportProgressFuncTo: number;
21
- 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;
22
24
  }
23
25
  declare const defaults: Opts;
24
26
  interface Res {
25
- res: string;
26
- ranges: Ranges;
27
- log: {
28
- timeTakenInMilliseconds: number;
29
- };
30
- whatWasDone: {
31
- removeWidows: boolean;
32
- convertEntities: boolean;
33
- };
27
+ res: string;
28
+ ranges: Ranges;
29
+ log: {
30
+ timeTakenInMilliseconds: number;
31
+ };
32
+ whatWasDone: {
33
+ removeWidows: boolean;
34
+ convertEntities: boolean;
35
+ };
34
36
  }
35
37
  declare function removeWidows(str: string, originalOpts?: Partial<Opts>): Res;
36
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
+ };