is-html-tag-opening 4.0.16 → 4.0.17
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 +1 -1
- package/README.md +1 -1
- package/dist/is-html-tag-opening.esm.js +2 -2
- package/dist/is-html-tag-opening.umd.js +6 -6
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2024 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
|
@@ -60,6 +60,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
60
60
|
|
|
61
61
|
MIT License.
|
|
62
62
|
|
|
63
|
-
Copyright © 2010-
|
|
63
|
+
Copyright © 2010-2024 Roy Revelt and other contributors.
|
|
64
64
|
|
|
65
65
|
<p align="center"><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"></p>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name is-html-tag-opening
|
|
3
3
|
* @fileoverview Does an HTML tag start at given position?
|
|
4
|
-
* @version 4.0.
|
|
4
|
+
* @version 4.0.17
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/is-html-tag-opening/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import{matchRight as x,matchRightIncl as N}from"string-match-left-right";import{left as c}from"string-left-right";var d={allowCustomTagNames:!1,skipOpeningBracket:!1},m="\\",g=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h1 - h6","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","slot","small","source","span","strike","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xml"];function b(e){return e===void 0||e.toUpperCase()===e.toLowerCase()&&!/\d/.test(e)&&e!=="="}import{left as T}from"string-left-right";function p(e,t){return e[t]==="<"||e[T(e,t)]==="<"}var f="4.0.
|
|
10
|
+
import{matchRight as x,matchRightIncl as N}from"string-match-left-right";import{left as c}from"string-left-right";var d={allowCustomTagNames:!1,skipOpeningBracket:!1},m="\\",g=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h1 - h6","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","slot","small","source","span","strike","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xml"];function b(e){return e===void 0||e.toUpperCase()===e.toLowerCase()&&!/\d/.test(e)&&e!=="="}import{left as T}from"string-left-right";function p(e,t){return e[t]==="<"||e[T(e,t)]==="<"}var f="4.0.17";var K=f;function U(e,t=0,h){if(typeof e!="string")throw new Error(`is-html-tag-opening: [THROW_ID_01] the first input argument should have been a string but it was given as "${typeof e}", value being ${JSON.stringify(e,null,4)}`);if(!Number.isInteger(t)||t<0)throw new Error(`is-html-tag-opening: [THROW_ID_02] the second input argument should have been a natural number string index but it was given as "${typeof t}", value being ${JSON.stringify(t,null,4)}`);let n={...d,...h},i="[\\\\ \\t\\r\\n/]*",r="._a-z0-9\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\uFFFF",w=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}\\w+${i}\\/?${i}>`,"g"),k=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}[${r}]+[-${r}]*${i}>`,"g"),E=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\w+\\s+\\w+(?:-\\w+)?\\s*=\\s*['"\\w]`,"g"),D=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\w+\\s+[${r}]+[-${r}]*(?:-\\w+)?\\s*=\\s*['"\\w]`),y=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\/?\\s*\\w+\\s*\\/?\\s*>`,"g"),O=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\/?\\s*[${r}]+[-${r}]*\\s*\\/?\\s*>`,"g"),R=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}\\w+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),v=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}[${r}]+[-${r}]*\\s+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),$=new RegExp(`^<${n.skipOpeningBracket?"?\\/?":""}(${i}[${r}]+)+${i}[\\\\/=>]`,""),V=new RegExp("^\\/\\s*\\w+s*>"),s=t?e.slice(t):e,a=c(e,t),l=!1,o=!1,B={cb:b,i:!0,trimCharsBeforeMatching:["/",m,"!"," "," ",`
|
|
11
11
|
`,"\r"]};return n.allowCustomTagNames?((n.skipOpeningBracket&&(e[t-1]==="<"||e[t-1]==="/"&&e[c(e,a)]==="<")||s[0]==="<"&&s[1]?.trim())&&($.test(s)||/^<\w+$/.test(s))||k.test(s)&&p(e,t)||D.test(s)||O.test(s)&&p(e,t)||v.test(s)||e[t]==="/"&&e[a]!=="<"&&V.test(s))&&(o=!0):(((n.skipOpeningBracket&&(e[t-1]==="<"||e[t-1]==="/"&&e[c(e,a)]==="<")||(s[0]==="<"||s[0]==="/"&&(!e[a]||e[a]!=="<"))&&s[1]?.trim())&&$.test(s)||w.test(s)&&p(e,t)||E.test(s)||y.test(s)&&p(e,t)||R.test(s))&&(l=!0),l&&N(e,t,g,{cb:u=>u===void 0?((e[t]==="<"&&e[t+1]?.trim()||e[t-1]==="<")&&(o=!0),!0):u.toUpperCase()===u.toLowerCase()&&!/\d/.test(u)&&u!=="=",i:!0,trimCharsBeforeMatching:["<","/",m,"!"," "," ",`
|
|
12
12
|
`,"\r"]})&&(o=!0)),!o&&e[t]==="<"&&e[t+1]?.trim()&&x(e,t,g,B)&&(o=!0),typeof e=="string"&&t<e.length&&o}export{d as defaults,U as isOpening,K as version};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name is-html-tag-opening
|
|
3
3
|
* @fileoverview Does an HTML tag start at given position?
|
|
4
|
-
* @version 4.0.
|
|
4
|
+
* @version 4.0.17
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/is-html-tag-opening/}
|
|
@@ -13,13 +13,13 @@ ${JSON.stringify(o,null,4)}`);if(n&&!S(n))throw new Error(`string-match-left-rig
|
|
|
13
13
|
${JSON.stringify(n,null,4)}`);let u=0,l="";if(a!=null&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.some((p,h)=>p.length>1?(u=h,l=p,!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 ${u} is longer than 1 character, ${l.length} (equals to ${l}). Please split it into separate characters and put into array as separate elements.`);if(!i||!Array.isArray(i)||Array.isArray(i)&&!i.length||Array.isArray(i)&&i.length===1&&C(i[0])&&!i[0].trim()){if(typeof a.cb=="function"){let h,f=s;if((e==="matchLeftIncl"||e==="matchRight")&&(f+=1),e[5]==="L")for(let d=f;d--;){let m=t[d];if((!a.trimBeforeMatching||a.trimBeforeMatching&&(m!=null&&m.trim()))&&(!((g=a.trimCharsBeforeMatching)!=null&&g.length)||m!==void 0&&!a.trimCharsBeforeMatching.includes(m))){h=d;break}}else if(e.startsWith("matchRight"))for(let d=f;d<t.length;d++){let m=t[d];if((!a.trimBeforeMatching||a.trimBeforeMatching&&m.trim())&&(!((b=a.trimCharsBeforeMatching)!=null&&b.length)||!a.trimCharsBeforeMatching.includes(m))){h=d;break}}if(h===void 0)return!1;let w=t[h],c=h+1,y="";return c&&c>0&&(y=t.slice(0,c)),e[5]==="L"||h&&h>0&&(y=t.slice(h)),a.cb(w,y,h)}let p="";throw n||(p=" 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!${p}`)}for(let p=0,h=i.length;p<h;p++){r=typeof i[p]=="function";let f=i[p],w,c,y="",d=s;e==="matchRight"?d+=1:e==="matchLeft"&&(d-=1);let m=me(t,d,f,a,r,A=>e[5]==="L"?A-1:A+1);if(m&&r&&typeof f=="function"&&f()==="EOL")return f()&&(!a.cb||a.cb(w,y,c))?f():!1;if(Number.isInteger(m)&&(c=e.startsWith("matchLeft")?m-1:m+1,e[5]==="L"?y=t.slice(0,m):y=t.slice(c)),c<0&&(c=void 0),t[c]&&(w=t[c]),Number.isInteger(m)&&(!a.cb||a.cb(w,y,c)))return f}return!1}function G(e,t,s,o){return z("matchRightIncl",e,t,s,o)}function Z(e,t,s,o){return z("matchRight",e,t,s,o)}var Y=H(N(),1);var Re=(0,Y.default)();var x="\xA0";function pe({str:e,idx:t,stopAtNewlines:s,stopAtRawNbsp:o}){if(typeof e!="string"||!e.length||((!t||typeof t!="number")&&(t=0),t<1))return null;if(e[~-t]&&(e[~-t].trim()||s&&`
|
|
14
14
|
\r`.includes(e[~-t])||o&&e[~-t]===x))return~-t;if(e[t-2]&&(e[t-2].trim()||s&&`
|
|
15
15
|
\r`.includes(e[t-2])||o&&e[t-2]===x))return t-2;for(let n=t;n--;)if(e[n]&&(e[n].trim()||s&&`
|
|
16
|
-
\r`.includes(e[n])||o&&e[n]===x))return n;return null}function E(e,t=0){return pe({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}var j={allowCustomTagNames:!1,skipOpeningBracket:!1},T="\\",I=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h1 - h6","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","slot","small","source","span","strike","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xml"];function X(e){return e===void 0||e.toUpperCase()===e.toLowerCase()&&!/\d/.test(e)&&e!=="="}function L(e,t){return e[t]==="<"||e[E(e,t)]==="<"}var ee="4.0.
|
|
16
|
+
\r`.includes(e[n])||o&&e[n]===x))return n;return null}function E(e,t=0){return pe({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}var j={allowCustomTagNames:!1,skipOpeningBracket:!1},T="\\",I=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","dir","div","dl","doctype","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h1 - h6","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","section","select","slot","small","source","span","strike","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr","xml"];function X(e){return e===void 0||e.toUpperCase()===e.toLowerCase()&&!/\d/.test(e)&&e!=="="}function L(e,t){return e[t]==="<"||e[E(e,t)]==="<"}var ee="4.0.17";var he=ee;function de(e,t=0,s){var $,M,V;if(typeof e!="string")throw new Error(`is-html-tag-opening: [THROW_ID_01] the first input argument should have been a string but it was given as "${typeof e}", value being ${JSON.stringify(e,null,4)}`);if(!Number.isInteger(t)||t<0)throw new Error(`is-html-tag-opening: [THROW_ID_02] the second input argument should have been a natural number string index but it was given as "${typeof t}", value being ${JSON.stringify(t,null,4)}`);let o=v(v({},j),s),n="[\\\\ \\t\\r\\n/]*",a="._a-z0-9\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\uFFFF",i=new RegExp(`^<${o.skipOpeningBracket?"?":""}${n}\\w+${n}\\/?${n}>`,"g"),r=new RegExp(`^<${o.skipOpeningBracket?"?":""}${n}[${a}]+[-${a}]*${n}>`,"g"),u=new RegExp(`^<${o.skipOpeningBracket?"?":""}\\s*\\w+\\s+\\w+(?:-\\w+)?\\s*=\\s*['"\\w]`,"g"),l=new RegExp(`^<${o.skipOpeningBracket?"?":""}\\s*\\w+\\s+[${a}]+[-${a}]*(?:-\\w+)?\\s*=\\s*['"\\w]`),g=new RegExp(`^<${o.skipOpeningBracket?"?":""}\\s*\\/?\\s*\\w+\\s*\\/?\\s*>`,"g"),b=new RegExp(`^<${o.skipOpeningBracket?"?":""}\\s*\\/?\\s*[${a}]+[-${a}]*\\s*\\/?\\s*>`,"g"),p=new RegExp(`^<${o.skipOpeningBracket?"?":""}${n}\\w+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),h=new RegExp(`^<${o.skipOpeningBracket?"?":""}${n}[${a}]+[-${a}]*\\s+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),f=new RegExp(`^<${o.skipOpeningBracket?"?\\/?":""}(${n}[${a}]+)+${n}[\\\\/=>]`,""),w=new RegExp("^\\/\\s*\\w+s*>"),c=t?e.slice(t):e,y=E(e,t),d=!1,m=!1,A={cb:X,i:!0,trimCharsBeforeMatching:["/",T,"!"," "," ",`
|
|
17
17
|
`,"\r"]};return o.allowCustomTagNames?((o.skipOpeningBracket&&(e[t-1]==="<"||e[t-1]==="/"&&e[E(e,y)]==="<")||c[0]==="<"&&(($=c[1])!=null&&$.trim()))&&(f.test(c)||/^<\w+$/.test(c))||r.test(c)&&L(e,t)||l.test(c)||b.test(c)&&L(e,t)||h.test(c)||e[t]==="/"&&e[y]!=="<"&&w.test(c))&&(m=!0):(((o.skipOpeningBracket&&(e[t-1]==="<"||e[t-1]==="/"&&e[E(e,y)]==="<")||(c[0]==="<"||c[0]==="/"&&(!e[y]||e[y]!=="<"))&&((M=c[1])!=null&&M.trim()))&&f.test(c)||i.test(c)&&L(e,t)||u.test(c)||g.test(c)&&L(e,t)||p.test(c))&&(d=!0),d&&G(e,t,I,{cb:B=>{var k;return B===void 0?((e[t]==="<"&&((k=e[t+1])!=null&&k.trim())||e[t-1]==="<")&&(m=!0),!0):B.toUpperCase()===B.toLowerCase()&&!/\d/.test(B)&&B!=="="},i:!0,trimCharsBeforeMatching:["<","/",T,"!"," "," ",`
|
|
18
18
|
`,"\r"]})&&(m=!0)),!m&&e[t]==="<"&&((V=e[t+1])!=null&&V.trim())&&Z(e,t,I,A)&&(m=!0),typeof e=="string"&&t<e.length&&m}return le(be);})();
|
|
19
19
|
/**
|
|
20
20
|
* @name arrayiffy-if-string
|
|
21
21
|
* @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
|
|
22
|
-
* @version 5.0.
|
|
22
|
+
* @version 5.0.8
|
|
23
23
|
* @author Roy Revelt, Codsen Ltd
|
|
24
24
|
* @license MIT
|
|
25
25
|
* {@link https://codsen.com/os/arrayiffy-if-string/}
|
|
@@ -27,7 +27,7 @@ ${JSON.stringify(n,null,4)}`);let u=0,l="";if(a!=null&&a.trimCharsBeforeMatching
|
|
|
27
27
|
/**
|
|
28
28
|
* @name codsen-utils
|
|
29
29
|
* @fileoverview Various utility functions
|
|
30
|
-
* @version 1.6.
|
|
30
|
+
* @version 1.6.3
|
|
31
31
|
* @author Roy Revelt, Codsen Ltd
|
|
32
32
|
* @license MIT
|
|
33
33
|
* {@link https://codsen.com/os/codsen-utils/}
|
|
@@ -35,7 +35,7 @@ ${JSON.stringify(n,null,4)}`);let u=0,l="";if(a!=null&&a.trimCharsBeforeMatching
|
|
|
35
35
|
/**
|
|
36
36
|
* @name string-match-left-right
|
|
37
37
|
* @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
|
|
38
|
-
* @version 9.0.
|
|
38
|
+
* @version 9.0.17
|
|
39
39
|
* @author Roy Revelt, Codsen Ltd
|
|
40
40
|
* @license MIT
|
|
41
41
|
* {@link https://codsen.com/os/string-match-left-right/}
|
|
@@ -43,7 +43,7 @@ ${JSON.stringify(n,null,4)}`);let u=0,l="";if(a!=null&&a.trimCharsBeforeMatching
|
|
|
43
43
|
/**
|
|
44
44
|
* @name string-left-right
|
|
45
45
|
* @fileoverview Looks up the first non-whitespace character to the left/right of a given index
|
|
46
|
-
* @version 6.0.
|
|
46
|
+
* @version 6.0.16
|
|
47
47
|
* @author Roy Revelt, Codsen Ltd
|
|
48
48
|
* @license MIT
|
|
49
49
|
* {@link https://codsen.com/os/string-left-right/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "is-html-tag-opening",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.17",
|
|
4
4
|
"description": "Does an HTML tag start at given position?",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bracket",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"string-left-right": "^6.0.
|
|
77
|
-
"string-match-left-right": "^9.0.
|
|
76
|
+
"string-left-right": "^6.0.16",
|
|
77
|
+
"string-match-left-right": "^9.0.17"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"test-mixer": "^4.1.
|
|
80
|
+
"test-mixer": "^4.1.13"
|
|
81
81
|
}
|
|
82
82
|
}
|