is-html-tag-opening 3.1.3 → 3.1.5

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/CHANGELOG.md CHANGED
@@ -12,7 +12,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
12
12
 
13
13
  ## 3.0.15 (2022-04-18)
14
14
 
15
- ### Bug Fixes
15
+ ### Fixed
16
16
 
17
17
  - tweak types ([6e721d2](https://github.com/codsen/codsen/commit/6e721d2872d07182718d0ab4e54e213e62a88b17))
18
18
 
@@ -24,7 +24,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
24
24
 
25
25
  ### BREAKING CHANGES
26
26
 
27
- - programs now are in ES Modules and won't work with Common JS require()
27
+ - programs now are in ES Modules and won't work with Common JS `require()`
28
28
 
29
29
  ## 2.1.0 (2021-05-24)
30
30
 
@@ -40,16 +40,16 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
40
40
 
41
41
  ## 2.0.9 (2021-03-23)
42
42
 
43
- ### Bug Fixes
43
+ ### Fixed
44
44
 
45
45
  - address the `opts.allowCustomTagNames` in context of malformed closing tags ([0a785fa](https://github.com/codsen/codsen/commit/0a785faa2a0e7821007fa9c9665bc247ac4cc6b2))
46
46
  - better detection of missing opening bracket when slash + known tag name follows ([b569953](https://github.com/codsen/codsen/commit/b56995356d6b449851ba1fc4a9e4e1b7bc220770))
47
47
 
48
48
  ## 2.0.1 (2021-01-28)
49
49
 
50
- ### Bug Fixes
50
+ ### Fixed
51
51
 
52
- - add testStats to npmignore ([f3c84e9](https://github.com/codsen/codsen/commit/f3c84e95afc5514214312f913692d85b2e12eb29))
52
+ - add `testStats` to npmignore ([f3c84e9](https://github.com/codsen/codsen/commit/f3c84e95afc5514214312f913692d85b2e12eb29))
53
53
 
54
54
  ## 2.0.0 (2021-01-23)
55
55
 
@@ -75,7 +75,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
75
75
 
76
76
  ## 1.9.0 (2020-11-28)
77
77
 
78
- Accidental version bump during migration to sourcehut. Sorry about that.
78
+ Accidental version bump during migration to SourceHut. Sorry about that.
79
79
 
80
80
  ## 1.8.0 (2020-09-07)
81
81
 
@@ -85,7 +85,7 @@ Accidental version bump during migration to sourcehut. Sorry about that.
85
85
 
86
86
  ## 1.7.0 (2020-03-16)
87
87
 
88
- ### Bug Fixes
88
+ ### Fixed
89
89
 
90
90
  - require that tag name would not be followed by equal sign ([9081082](https://gitlab.com/codsen/codsen/commit/9081082c8f0a4142c6c4941405b4b1b400d1e390))
91
91
 
@@ -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 3.1.3
4
+ * @version 3.1.5
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 N,matchRightIncl as S}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="3.1.3";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},r="[\\\\ \\t\\r\\n/]*",i="._a-z0-9\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\uFFFF",w=new RegExp(`^<${n.skipOpeningBracket?"?":""}${r}\\w+${r}\\/?${r}>`,"g"),k=new RegExp(`^<${n.skipOpeningBracket?"?":""}${r}[${i}]+[-${i}]*${r}>`,"g"),y=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\w+\\s+\\w+(?:-\\w+)?\\s*=\\s*['"\\w]`,"g"),E=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\w+\\s+[${i}]+[-${i}]*(?:-\\w+)?\\s*=\\s*['"\\w]`),D=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\/?\\s*\\w+\\s*\\/?\\s*>`,"g"),O=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\/?\\s*[${i}]+[-${i}]*\\s*\\/?\\s*>`,"g"),R=new RegExp(`^<${n.skipOpeningBracket?"?":""}${r}\\w+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),v=new RegExp(`^<${n.skipOpeningBracket?"?":""}${r}[${i}]+[-${i}]*\\s+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),$=new RegExp(`^<${n.skipOpeningBracket?"?\\/?":""}(${r}[${i}]+)+${r}[\\\\/=>]`,""),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,"!"," "," ",`
10
+ import{matchRight as N,matchRightIncl as S}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="3.1.5";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},r="[\\\\ \\t\\r\\n/]*",i="._a-z0-9\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\uFFFF",w=new RegExp(`^<${n.skipOpeningBracket?"?":""}${r}\\w+${r}\\/?${r}>`,"g"),k=new RegExp(`^<${n.skipOpeningBracket?"?":""}${r}[${i}]+[-${i}]*${r}>`,"g"),y=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\w+\\s+\\w+(?:-\\w+)?\\s*=\\s*['"\\w]`,"g"),E=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\w+\\s+[${i}]+[-${i}]*(?:-\\w+)?\\s*=\\s*['"\\w]`),D=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\/?\\s*\\w+\\s*\\/?\\s*>`,"g"),O=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\/?\\s*[${i}]+[-${i}]*\\s*\\/?\\s*>`,"g"),R=new RegExp(`^<${n.skipOpeningBracket?"?":""}${r}\\w+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),v=new RegExp(`^<${n.skipOpeningBracket?"?":""}${r}[${i}]+[-${i}]*\\s+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),$=new RegExp(`^<${n.skipOpeningBracket?"?\\/?":""}(${r}[${i}]+)+${r}[\\\\/=>]`,""),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]&&s[1].trim())&&($.test(s)||/^<\w+$/.test(s))||k.test(s)&&p(e,t)||E.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]&&s[1].trim())&&$.test(s)||w.test(s)&&p(e,t)||y.test(s)||D.test(s)&&p(e,t)||R.test(s))&&(l=!0),l&&S(e,t,g,{cb:u=>u===void 0?((e[t]==="<"&&e[t+1]&&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]&&e[t+1].trim()&&N(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 3.1.3
4
+ * @version 3.1.5
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(n,null,4)}`);if(i&&!vt(i))throw new Error(`string-match-left-ri
13
13
  ${JSON.stringify(i,null,4)}`);let g=0,d="";if((o==null?void 0:o.trimCharsBeforeMatching)&&o.trimCharsBeforeMatching.some((p,f)=>p.length>1?(g=f,d=p,!0):!1))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 ${g} is longer than 1 character, ${d.length} (equals to ${d}). Please split it into separate characters and put into array as separate elements.`);if(!u||!Array.isArray(u)||Array.isArray(u)&&!u.length||Array.isArray(u)&&u.length===1&&P(u[0])&&!u[0].trim()){if(typeof o.cb=="function"){let f,a=r;if((t==="matchLeftIncl"||t==="matchRight")&&(a+=1),t[5]==="L")for(let m=a;m--;){let c=e[m];if((!o.trimBeforeMatching||o.trimBeforeMatching&&c!==void 0&&c.trim())&&(!((_=o.trimCharsBeforeMatching)!=null&&_.length)||c!==void 0&&!o.trimCharsBeforeMatching.includes(c))){f=m;break}}else if(t.startsWith("matchRight"))for(let m=a;m<e.length;m++){let c=e[m];if((!o.trimBeforeMatching||o.trimBeforeMatching&&c.trim())&&(!((w=o.trimCharsBeforeMatching)!=null&&w.length)||!o.trimCharsBeforeMatching.includes(c))){f=m;break}}if(f===void 0)return!1;let y=e[f],l=f+1,b="";return l&&l>0&&(b=e.slice(0,l)),t[5]==="L"||f&&f>0&&(b=e.slice(f)),o.cb(y,b,f)}let p="";throw i||(p=" 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!${p}`)}for(let p=0,f=u.length;p<f;p++){s=typeof u[p]=="function";let a=u[p],y,l,b="",m=r;t==="matchRight"?m+=1:t==="matchLeft"&&(m-=1);let c=Se(e,m,a,o,s,E=>t[5]==="L"?E-1:E+1);if(c&&s&&typeof a=="function"&&a()==="EOL")return a()&&(o.cb?o.cb(y,b,l):!0)?a():!1;if(Number.isInteger(c)&&(l=t.startsWith("matchLeft")?c-1:c+1,t[5]==="L"?b=e.slice(0,c):b=e.slice(l)),l<0&&(l=void 0),e[l]&&(y=e[l]),Number.isInteger(c)&&(o.cb?o.cb(y,b,l):!0))return a}return!1}function At(t,e,r,n){return Ct("matchRightIncl",t,e,r,n)}function Et(t,e,r,n){return Ct("matchRight",t,e,r,n)}var pn=$t(Rt(),1),mn=$t(ye(),1);var ft="\xA0";function dn({str:t,idx:e,stopAtNewlines:r,stopAtRawNbsp:n}){if(typeof t!="string"||!t.length||((!e||typeof e!="number")&&(e=0),e<1))return null;if(t[~-e]&&(t[~-e].trim()||r&&`
14
14
  \r`.includes(t[~-e])||n&&t[~-e]===ft))return~-e;if(t[e-2]&&(t[e-2].trim()||r&&`
15
15
  \r`.includes(t[e-2])||n&&t[e-2]===ft))return e-2;for(let i=e;i--;)if(t[i]&&(t[i].trim()||r&&`
16
- \r`.includes(t[i])||n&&t[i]===ft))return i;return null}function I(t,e=0){return dn({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}var ht={allowCustomTagNames:!1,skipOpeningBracket:!1},gt="\\",pt=["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 we(t){return t===void 0||t.toUpperCase()===t.toLowerCase()&&!/\d/.test(t)&&t!=="="}function H(t,e){return t[e]==="<"||t[I(t,e)]==="<"}var $e="3.1.3";var yn=$e;function wn(t,e=0,r){if(typeof t!="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 t}", value being ${JSON.stringify(t,null,4)}`);if(!Number.isInteger(e)||e<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 e}", value being ${JSON.stringify(e,null,4)}`);let n=v(v({},ht),r),i="[\\\\ \\t\\r\\n/]*",o="._a-z0-9\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\uFFFF",u=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}\\w+${i}\\/?${i}>`,"g"),s=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}[${o}]+[-${o}]*${i}>`,"g"),g=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\w+\\s+\\w+(?:-\\w+)?\\s*=\\s*['"\\w]`,"g"),d=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\w+\\s+[${o}]+[-${o}]*(?:-\\w+)?\\s*=\\s*['"\\w]`),_=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\/?\\s*\\w+\\s*\\/?\\s*>`,"g"),w=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\/?\\s*[${o}]+[-${o}]*\\s*\\/?\\s*>`,"g"),p=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}\\w+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),f=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}[${o}]+[-${o}]*\\s+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),a=new RegExp(`^<${n.skipOpeningBracket?"?\\/?":""}(${i}[${o}]+)+${i}[\\\\/=>]`,""),y=new RegExp("^\\/\\s*\\w+s*>"),l=e?t.slice(e):t,b=I(t,e),m=!1,c=!1,E={cb:we,i:!0,trimCharsBeforeMatching:["/",gt,"!"," "," ",`
16
+ \r`.includes(t[i])||n&&t[i]===ft))return i;return null}function I(t,e=0){return dn({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}var ht={allowCustomTagNames:!1,skipOpeningBracket:!1},gt="\\",pt=["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 we(t){return t===void 0||t.toUpperCase()===t.toLowerCase()&&!/\d/.test(t)&&t!=="="}function H(t,e){return t[e]==="<"||t[I(t,e)]==="<"}var $e="3.1.5";var yn=$e;function wn(t,e=0,r){if(typeof t!="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 t}", value being ${JSON.stringify(t,null,4)}`);if(!Number.isInteger(e)||e<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 e}", value being ${JSON.stringify(e,null,4)}`);let n=v(v({},ht),r),i="[\\\\ \\t\\r\\n/]*",o="._a-z0-9\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\uFFFF",u=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}\\w+${i}\\/?${i}>`,"g"),s=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}[${o}]+[-${o}]*${i}>`,"g"),g=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\w+\\s+\\w+(?:-\\w+)?\\s*=\\s*['"\\w]`,"g"),d=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\w+\\s+[${o}]+[-${o}]*(?:-\\w+)?\\s*=\\s*['"\\w]`),_=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\/?\\s*\\w+\\s*\\/?\\s*>`,"g"),w=new RegExp(`^<${n.skipOpeningBracket?"?":""}\\s*\\/?\\s*[${o}]+[-${o}]*\\s*\\/?\\s*>`,"g"),p=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}\\w+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),f=new RegExp(`^<${n.skipOpeningBracket?"?":""}${i}[${o}]+[-${o}]*\\s+(?:\\s*\\w+)?\\s*\\w+=['"]`,"g"),a=new RegExp(`^<${n.skipOpeningBracket?"?\\/?":""}(${i}[${o}]+)+${i}[\\\\/=>]`,""),y=new RegExp("^\\/\\s*\\w+s*>"),l=e?t.slice(e):t,b=I(t,e),m=!1,c=!1,E={cb:we,i:!0,trimCharsBeforeMatching:["/",gt,"!"," "," ",`
17
17
  `,"\r"]};return n.allowCustomTagNames?((n.skipOpeningBracket&&(t[e-1]==="<"||t[e-1]==="/"&&t[I(t,b)]==="<")||l[0]==="<"&&l[1]&&l[1].trim())&&(a.test(l)||/^<\w+$/.test(l))||s.test(l)&&H(t,e)||d.test(l)||w.test(l)&&H(t,e)||f.test(l)||t[e]==="/"&&t[b]!=="<"&&y.test(l))&&(c=!0):(((n.skipOpeningBracket&&(t[e-1]==="<"||t[e-1]==="/"&&t[I(t,b)]==="<")||(l[0]==="<"||l[0]==="/"&&(!t[b]||t[b]!=="<"))&&l[1]&&l[1].trim())&&a.test(l)||u.test(l)&&H(t,e)||g.test(l)||_.test(l)&&H(t,e)||p.test(l))&&(m=!0),m&&At(t,e,pt,{cb:$=>$===void 0?((t[e]==="<"&&t[e+1]&&t[e+1].trim()||t[e-1]==="<")&&(c=!0),!0):$.toUpperCase()===$.toLowerCase()&&!/\d/.test($)&&$!=="=",i:!0,trimCharsBeforeMatching:["<","/",gt,"!"," "," ",`
18
18
  `,"\r"]})&&(c=!0)),!c&&t[e]==="<"&&t[e+1]&&t[e+1].trim()&&Et(t,e,pt,E)&&(c=!0),typeof t=="string"&&e<t.length&&c}return Te($n);})();
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 4.1.2
22
+ * @version 4.1.4
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(i,null,4)}`);let g=0,d="";if((o==null?void 0:o.trimCharsBeforeM
27
27
  /**
28
28
  * @name string-left-right
29
29
  * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
30
- * @version 5.1.3
30
+ * @version 5.1.5
31
31
  * @author Roy Revelt, Codsen Ltd
32
32
  * @license MIT
33
33
  * {@link https://codsen.com/os/string-left-right/}
@@ -35,7 +35,7 @@ ${JSON.stringify(i,null,4)}`);let g=0,d="";if((o==null?void 0:o.trimCharsBeforeM
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 8.2.3
38
+ * @version 8.2.5
39
39
  * @author Roy Revelt, Codsen Ltd
40
40
  * @license MIT
41
41
  * {@link https://codsen.com/os/string-match-left-right/}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "is-html-tag-opening",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "description": "Does an HTML tag start at given position?",
5
5
  "keywords": [
6
6
  "bracket",
@@ -44,7 +44,7 @@
44
44
  "examples": "node '../../ops/scripts/run-examples.js'",
45
45
  "lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
46
46
  "letspublish": "yarn publish || :",
47
- "lint": "eslint . --fix",
47
+ "lint": "eslint . --ext .js --ext .ts --fix",
48
48
  "perf": "node perf/check.js",
49
49
  "prepare": "echo 'ready'",
50
50
  "prettier": "prettier",
@@ -71,10 +71,10 @@
71
71
  }
72
72
  },
73
73
  "dependencies": {
74
- "string-left-right": "^5.1.3",
75
- "string-match-left-right": "^8.2.3"
74
+ "string-left-right": "^5.1.5",
75
+ "string-match-left-right": "^8.2.5"
76
76
  },
77
77
  "devDependencies": {
78
- "test-mixer": "^3.1.2"
78
+ "test-mixer": "^3.1.4"
79
79
  }
80
80
  }
@@ -1,16 +0,0 @@
1
- // Quick Take
2
-
3
- import { strict as assert } from "assert";
4
-
5
- import { isOpening } from "../dist/is-html-tag-opening.esm.js";
6
-
7
- const text = `<span>a < b<span>`;
8
-
9
- // opening span tag's opening
10
- assert.equal(isOpening(text, 0), true);
11
-
12
- // unencoded bracket between a and b
13
- assert.equal(isOpening(text, 8), false);
14
-
15
- // closing span tag's opening
16
- assert.equal(isOpening(text, 11), true);
@@ -1,21 +0,0 @@
1
- // `opts.allowCustomTagNames`
2
-
3
- import { strict as assert } from "assert";
4
-
5
- import { isOpening } from "../dist/is-html-tag-opening.esm.js";
6
-
7
- // recognised tag
8
- assert.equal(isOpening(`abc <div>`, 4), true);
9
- // ^
10
-
11
- // unrecognised tag
12
- assert.equal(isOpening(`abc <zzz>`, 4), false);
13
- // ^
14
-
15
- // but with opts.allowCustomTagNames result is "true"
16
- assert.equal(
17
- isOpening(`abc <zzz>`, 4, {
18
- allowCustomTagNames: true,
19
- }),
20
- true
21
- );
@@ -1,23 +0,0 @@
1
- // `opts.skipOpeningBracket`
2
-
3
- import { strict as assert } from "assert";
4
-
5
- import { isOpening } from "../dist/is-html-tag-opening.esm.js";
6
-
7
- // missing opening bracket:
8
- assert.equal(isOpening(`<a>div class="w-64 h-3">`, 3), false);
9
- // ^
10
- // result is instant "false" because `idx` has to be
11
- // on an opening bracket (besides checking for tag name
12
- // being present and recognised and attributes being present)
13
-
14
- // but with opts.skipOpeningBracket we remove the requirement
15
- // that "idx" has to be on a bracket - algorithm detects valid
16
- // tag name and the attribute that follows and recognise it's a
17
- // tag starting:
18
- assert.equal(
19
- isOpening(`<a>div class="w-64 h-3">`, 3, {
20
- skipOpeningBracket: true,
21
- }),
22
- true
23
- );