is-html-tag-opening 4.0.12 → 4.0.13
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.
|
@@ -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.13
|
|
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 x}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 N,matchRightIncl as x}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.13";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]&&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]&&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&&x(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,21 +1,21 @@
|
|
|
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.13
|
|
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
|
-
"use strict";var isHtmlTagOpening=(()=>{var
|
|
10
|
+
"use strict";var isHtmlTagOpening=(()=>{var Y=Object.create;var E=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,te=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var V=(e,t,s)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,v=(e,t)=>{for(var s in t||(t={}))k.call(t,s)&&V(e,s,t[s]);if(I)for(var s of I(t))re.call(t,s)&&V(e,s,t[s]);return e};var ne=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ie=(e,t)=>{for(var s in t)E(e,s,{get:t[s],enumerable:!0})},F=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ee(t))!k.call(e,n)&&n!==s&&E(e,n,{get:()=>t[n],enumerable:!(o=X(t,n))||o.enumerable});return e};var _=(e,t,s)=>(s=e!=null?Y(te(e)):{},F(t||!e||!e.__esModule?E(s,"default",{value:e,enumerable:!0}):s,e)),se=e=>F(E({},"__esModule",{value:!0}),e);var L=ne((be,W)=>{"use strict";W.exports=ae;function M(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function ae(e){if(e=e||{},e.circles)return oe(e);return e.proto?o:s;function t(n,a){for(var i=Object.keys(n),r=new Array(i.length),u=0;u<i.length;u++){var l=i[u],g=n[l];typeof g!="object"||g===null?r[l]=g:g instanceof Date?r[l]=new Date(g):ArrayBuffer.isView(g)?r[l]=M(g):r[l]=a(g)}return r}function s(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(Array.isArray(n))return t(n,s);if(n instanceof Map)return new Map(t(Array.from(n),s));if(n instanceof Set)return new Set(t(Array.from(n),s));var a={};for(var i in n)if(Object.hasOwnProperty.call(n,i)!==!1){var r=n[i];typeof r!="object"||r===null?a[i]=r:r instanceof Date?a[i]=new Date(r):r instanceof Map?a[i]=new Map(t(Array.from(r),s)):r instanceof Set?a[i]=new Set(t(Array.from(r),s)):ArrayBuffer.isView(r)?a[i]=M(r):a[i]=s(r)}return a}function o(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(Array.isArray(n))return t(n,o);if(n instanceof Map)return new Map(t(Array.from(n),o));if(n instanceof Set)return new Set(t(Array.from(n),o));var a={};for(var i in n){var r=n[i];typeof r!="object"||r===null?a[i]=r:r instanceof Date?a[i]=new Date(r):r instanceof Map?a[i]=new Map(t(Array.from(r),o)):r instanceof Set?a[i]=new Set(t(Array.from(r),o)):ArrayBuffer.isView(r)?a[i]=M(r):a[i]=o(r)}return a}}function oe(e){var t=[],s=[];return e.proto?a:n;function o(i,r){for(var u=Object.keys(i),l=new Array(u.length),g=0;g<u.length;g++){var b=u[g],m=i[b];if(typeof m!="object"||m===null)l[b]=m;else if(m instanceof Date)l[b]=new Date(m);else if(ArrayBuffer.isView(m))l[b]=M(m);else{var h=t.indexOf(m);h!==-1?l[b]=s[h]:l[b]=r(m)}}return l}function n(i){if(typeof i!="object"||i===null)return i;if(i instanceof Date)return new Date(i);if(Array.isArray(i))return o(i,n);if(i instanceof Map)return new Map(o(Array.from(i),n));if(i instanceof Set)return new Set(o(Array.from(i),n));var r={};t.push(i),s.push(r);for(var u in i)if(Object.hasOwnProperty.call(i,u)!==!1){var l=i[u];if(typeof l!="object"||l===null)r[u]=l;else if(l instanceof Date)r[u]=new Date(l);else if(l instanceof Map)r[u]=new Map(o(Array.from(l),n));else if(l instanceof Set)r[u]=new Set(o(Array.from(l),n));else if(ArrayBuffer.isView(l))r[u]=M(l);else{var g=t.indexOf(l);g!==-1?r[u]=s[g]:r[u]=n(l)}}return t.pop(),s.pop(),r}function a(i){if(typeof i!="object"||i===null)return i;if(i instanceof Date)return new Date(i);if(Array.isArray(i))return o(i,a);if(i instanceof Map)return new Map(o(Array.from(i),a));if(i instanceof Set)return new Set(o(Array.from(i),a));var r={};t.push(i),s.push(r);for(var u in i){var l=i[u];if(typeof l!="object"||l===null)r[u]=l;else if(l instanceof Date)r[u]=new Date(l);else if(l instanceof Map)r[u]=new Map(o(Array.from(l),a));else if(l instanceof Set)r[u]=new Set(o(Array.from(l),a));else if(ArrayBuffer.isView(l))r[u]=M(l);else{var g=t.indexOf(l);g!==-1?r[u]=s[g]:r[u]=a(l)}}return t.pop(),s.pop(),r}}});var ge={};ie(ge,{defaults:()=>x,isOpening:()=>pe,version:()=>me});function q(e){return typeof e!="string"?e:e.length?[e]:[]}var H=_(L(),1);var ye=(0,H.default)();function B(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function C(e){return typeof e=="string"}function P(e,t){return B(e)&&C(t)&&t in e}var J={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},le=e=>e+1;function ue(e,t,s,o,n=!1,a=le){let i=typeof s=="function"?s():s;if(+t<0&&n&&i==="EOL")return i;let r=v(v({},J),o);if(t>=e.length&&!n)return!1;let u=n?1:s.length,l=0,g=!1,b=!1,m=!1,h=r.maxMismatches,f=t,w=!1,c=!1,y=!1;function d(){return l===1&&h<r.maxMismatches-1}for(;e[f];){let p=a(f);if(r.trimBeforeMatching&&e[f].trim()===""){if(!e[p]&&n&&s==="EOL")return!0;f=a(f);continue}if(r&&!r.i&&r.trimCharsBeforeMatching&&r.trimCharsBeforeMatching.includes(e[f])||r!=null&&r.i&&r.trimCharsBeforeMatching&&r.trimCharsBeforeMatching.map(D=>D.toLowerCase()).includes(e[f].toLowerCase())){if(n&&s==="EOL"&&!e[p])return!0;f=a(f);continue}let A=p>f?s[s.length-u]:s[u-1];if(!r.i&&e[f]===A||r.i&&e[f].toLowerCase()===A.toLowerCase()){if(w||(w=!0),m||(m=!0),u===s.length){if(c=!0,h!==r.maxMismatches)return!1}else u===1&&(y=!0);if(u-=1,l++,d())return!1;if(!u)return l!==s.length||h===r.maxMismatches||!g?f:!1}else if(!g&&!l&&(g=!0),r.maxMismatches&&h&&f){h-=1;for(let D=0;D<=h;D++){let $=p>f?s[s.length-u+1+D]:s[u-2-D],S=e[a(f)];if($&&(!r.i&&e[f]===$||r.i&&e[f].toLowerCase()===$.toLowerCase())&&(!r.firstMustMatch||u!==s.length)){if(l++,d())return!1;u-=2,w=!0;break}else if(S&&$&&(!r.i&&S===$||r.i&&S.toLowerCase()===$.toLowerCase())&&(!r.firstMustMatch||u!==s.length)){if(!l&&!r.hungry)return!1;u-=1,w=!0;break}else if($===void 0&&h>=0&&w&&(!r.firstMustMatch||c)&&(!r.lastMustMatch||y))return f}w||(b=f)}else return f===0&&u===1&&!r.lastMustMatch&&m?0:!1;if(b!==!1&&b!==f&&(b=!1),u<1)return f;f=a(f)}if(u>0)return n&&i==="EOL"?!0:r&&r.maxMismatches>=u&&m?b||0:!1}function U(e,t,s,o,n){var g,b;if(B(n)&&P(n,"trimBeforeMatching")&&n&&typeof n.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(n.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let a=v(v({},J),n);if(typeof a.trimCharsBeforeMatching=="string"&&(a.trimCharsBeforeMatching=q(a.trimCharsBeforeMatching)),a.trimCharsBeforeMatching=a.trimCharsBeforeMatching.map(m=>C(m)?m:String(m)),!C(t)||!t.length)return!1;if(!Number.isInteger(s)||s<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 s}, equal to:
|
|
11
11
|
${JSON.stringify(s,null,4)}`);let i,r;if(C(o))i=[o];else if(Array.isArray(o))i=o;else if(!o)i=o;else if(typeof o=="function")i=[],i.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(n&&!
|
|
13
|
-
${JSON.stringify(n,null,4)}`);let u=0,l="";if(a!=null&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.some((m,h)=>m.length>1?(u=h,l=m,!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 p=t[d];if((!a.trimBeforeMatching||a.trimBeforeMatching&&p!==void 0&&p.trim())&&(!((g=a.trimCharsBeforeMatching)!=null&&g.length)||p!==void 0&&!a.trimCharsBeforeMatching.includes(p))){h=d;break}}else if(e.startsWith("matchRight"))for(let d=f;d<t.length;d++){let p=t[d];if((!a.trimBeforeMatching||a.trimBeforeMatching&&p.trim())&&(!((b=a.trimCharsBeforeMatching)!=null&&b.length)||!a.trimCharsBeforeMatching.includes(p))){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 m="";throw n||(m=" 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!${m}`)}for(let m=0,h=i.length;m<h;m++){r=typeof i[m]=="function";let f=i[m],w,c,y="",d=s;e==="matchRight"?d+=1:e==="matchLeft"&&(d-=1);let p=
|
|
14
|
-
\r`.includes(e[~-t])||o&&e[~-t]===
|
|
15
|
-
\r`.includes(e[t-2])||o&&e[t-2]===
|
|
16
|
-
\r`.includes(e[n])||o&&e[n]===
|
|
17
|
-
`,"\r"]};return o.allowCustomTagNames?((o.skipOpeningBracket&&(e[t-1]==="<"||e[t-1]==="/"&&e[O(e,y)]==="<")||c[0]==="<"&&c[1]&&c[1].trim())&&(f.test(c)||/^<\w+$/.test(c))||r.test(c)&&R(e,t)||l.test(c)||b.test(c)&&R(e,t)||h.test(c)||e[t]==="/"&&e[y]!=="<"&&w.test(c))&&(p=!0):(((o.skipOpeningBracket&&(e[t-1]==="<"||e[t-1]==="/"&&e[O(e,y)]==="<")||(c[0]==="<"||c[0]==="/"&&(!e[y]||e[y]!=="<"))&&c[1]&&c[1].trim())&&f.test(c)||i.test(c)&&R(e,t)||u.test(c)||g.test(c)&&R(e,t)||m.test(c))&&(d=!0),d&&
|
|
18
|
-
`,"\r"]})&&(p=!0)),!p&&e[t]==="<"&&e[t+1]&&e[t+1].trim()&&
|
|
12
|
+
${JSON.stringify(o,null,4)}`);if(n&&!B(n))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 n}", and equal to:
|
|
13
|
+
${JSON.stringify(n,null,4)}`);let u=0,l="";if(a!=null&&a.trimCharsBeforeMatching&&a.trimCharsBeforeMatching.some((m,h)=>m.length>1?(u=h,l=m,!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 p=t[d];if((!a.trimBeforeMatching||a.trimBeforeMatching&&p!==void 0&&p.trim())&&(!((g=a.trimCharsBeforeMatching)!=null&&g.length)||p!==void 0&&!a.trimCharsBeforeMatching.includes(p))){h=d;break}}else if(e.startsWith("matchRight"))for(let d=f;d<t.length;d++){let p=t[d];if((!a.trimBeforeMatching||a.trimBeforeMatching&&p.trim())&&(!((b=a.trimCharsBeforeMatching)!=null&&b.length)||!a.trimCharsBeforeMatching.includes(p))){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 m="";throw n||(m=" 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!${m}`)}for(let m=0,h=i.length;m<h;m++){r=typeof i[m]=="function";let f=i[m],w,c,y="",d=s;e==="matchRight"?d+=1:e==="matchLeft"&&(d-=1);let p=ue(t,d,f,a,r,A=>e[5]==="L"?A-1:A+1);if(p&&r&&typeof f=="function"&&f()==="EOL")return f()&&(!a.cb||a.cb(w,y,c))?f():!1;if(Number.isInteger(p)&&(c=e.startsWith("matchLeft")?p-1:p+1,e[5]==="L"?y=t.slice(0,p):y=t.slice(c)),c<0&&(c=void 0),t[c]&&(w=t[c]),Number.isInteger(p)&&(!a.cb||a.cb(w,y,c)))return f}return!1}function Q(e,t,s,o){return U("matchRightIncl",e,t,s,o)}function K(e,t,s,o){return U("matchRight",e,t,s,o)}var z=_(L(),1);var Oe=(0,z.default)();var N="\xA0";function fe({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
|
+
\r`.includes(e[~-t])||o&&e[~-t]===N))return~-t;if(e[t-2]&&(e[t-2].trim()||s&&`
|
|
15
|
+
\r`.includes(e[t-2])||o&&e[t-2]===N))return t-2;for(let n=t;n--;)if(e[n]&&(e[n].trim()||s&&`
|
|
16
|
+
\r`.includes(e[n])||o&&e[n]===N))return n;return null}function O(e,t=0){return fe({str:e,idx:t,stopAtNewlines:!1,stopAtRawNbsp:!1})}var x={allowCustomTagNames:!1,skipOpeningBracket:!1},j="\\",T=["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 G(e){return e===void 0||e.toUpperCase()===e.toLowerCase()&&!/\d/.test(e)&&e!=="="}function R(e,t){return e[t]==="<"||e[O(e,t)]==="<"}var Z="4.0.13";var me=Z;function pe(e,t=0,s){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({},x),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"),m=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=O(e,t),d=!1,p=!1,A={cb:G,i:!0,trimCharsBeforeMatching:["/",j,"!"," "," ",`
|
|
17
|
+
`,"\r"]};return o.allowCustomTagNames?((o.skipOpeningBracket&&(e[t-1]==="<"||e[t-1]==="/"&&e[O(e,y)]==="<")||c[0]==="<"&&c[1]&&c[1].trim())&&(f.test(c)||/^<\w+$/.test(c))||r.test(c)&&R(e,t)||l.test(c)||b.test(c)&&R(e,t)||h.test(c)||e[t]==="/"&&e[y]!=="<"&&w.test(c))&&(p=!0):(((o.skipOpeningBracket&&(e[t-1]==="<"||e[t-1]==="/"&&e[O(e,y)]==="<")||(c[0]==="<"||c[0]==="/"&&(!e[y]||e[y]!=="<"))&&c[1]&&c[1].trim())&&f.test(c)||i.test(c)&&R(e,t)||u.test(c)||g.test(c)&&R(e,t)||m.test(c))&&(d=!0),d&&Q(e,t,T,{cb:$=>$===void 0?((e[t]==="<"&&e[t+1]&&e[t+1].trim()||e[t-1]==="<")&&(p=!0),!0):$.toUpperCase()===$.toLowerCase()&&!/\d/.test($)&&$!=="=",i:!0,trimCharsBeforeMatching:["<","/",j,"!"," "," ",`
|
|
18
|
+
`,"\r"]})&&(p=!0)),!p&&e[t]==="<"&&e[t+1]&&e[t+1].trim()&&K(e,t,T,A)&&(p=!0),typeof e=="string"&&t<e.length&&p}return se(ge);})();
|
|
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.
|
|
@@ -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.
|
|
30
|
+
* @version 1.6.0
|
|
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.13
|
|
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.13
|
|
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.13",
|
|
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.13",
|
|
77
|
+
"string-match-left-right": "^9.0.13"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"test-mixer": "^4.1.
|
|
80
|
+
"test-mixer": "^4.1.10"
|
|
81
81
|
}
|
|
82
82
|
}
|