@vrcd-community/zhlint
Version:
A linting tool for Chinese language.
8 lines • 167 kB
JavaScript
(function(we,tt){typeof exports=="object"&&typeof module<"u"?tt(exports):typeof define=="function"&&define.amd?define(["exports"],tt):(we=typeof globalThis<"u"?globalThis:we||self,tt(we.zhlint={}))})(this,function(we){"use strict";var dl,gl;const tt=/^(?:(?<prefix>.+?)-,)?(?<textStart>.+?)(?:,(?<textEnd>.+?))?(?:,-(?<suffix>.+?))?$/,Jn=e=>{const n=e.match(tt);if(n){const{prefix:t,textStart:i,textEnd:r,suffix:l}=n.groups;return{prefix:t,textStart:i,textEnd:r,suffix:l}}},El=e=>{const{ignoredByRules:n,value:t}=e,i=/<!--\s*zhlint\s*ignore:\s*(.+?)\s*-->/g;let r;for(;(r=i.exec(t))!==null;){const l=Jn(r[1]);l&&n.push(l)}return e},Al=/\{% ([^ ]+?) [^%]*?%\}(?:\n|\{(?!%)|[^{])*?\{% end(?:\1) %\}/g,Sl=e=>(e.modifiedValue=e.modifiedValue.replace(Al,(n,t,i)=>{const{length:r}=n;return e.ignoredByParsers.push({name:t,meta:`hexo-${t}`,index:i,length:r,originValue:n}),"@".repeat(r)}),e);let Ut;try{Ut=new RegExp("(?<=^|\\n)(:::.*)\\n([\\s\\S]+?)\\n(:::)(?=\\n|$)","g")}catch{Ut=/(:::.*)\n([\s\S]+?)\n(:::)/g}const Cl=e=>(e.modifiedValue=e.modifiedValue.replace(Ut,(n,t,i,r,l)=>{const{length:u}=n,a=t.substring(3).trim().split(" ")[0]||"default";return e.ignoredByParsers.push({name:a,index:l,length:t.length,originValue:t,meta:`vuepress-${a}-start`}),e.ignoredByParsers.push({name:a,index:l+u-3,length:3,originValue:r,meta:`vuepress-${a}-end`}),"@".repeat(t.length)+`
`+i+`
`+"@".repeat(3)}),e);function Zn(e){if(e)throw e}function bt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/var Tl=function(n){return n!=null&&n.constructor!=null&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)};const Xn=bt(Tl);var xt=Object.prototype.hasOwnProperty,er=Object.prototype.toString,tr=Object.defineProperty,nr=Object.getOwnPropertyDescriptor,rr=function(n){return typeof Array.isArray=="function"?Array.isArray(n):er.call(n)==="[object Array]"},ir=function(n){if(!n||er.call(n)!=="[object Object]")return!1;var t=xt.call(n,"constructor"),i=n.constructor&&n.constructor.prototype&&xt.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!t&&!i)return!1;var r;for(r in n);return typeof r>"u"||xt.call(n,r)},lr=function(n,t){tr&&t.name==="__proto__"?tr(n,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):n[t.name]=t.newValue},ur=function(n,t){if(t==="__proto__")if(xt.call(n,t)){if(nr)return nr(n,t).value}else return;return n[t]},Fl=function e(){var n,t,i,r,l,u,a=arguments[0],s=1,c=arguments.length,f=!1;for(typeof a=="boolean"&&(f=a,a=arguments[1]||{},s=2),(a==null||typeof a!="object"&&typeof a!="function")&&(a={});s<c;++s)if(n=arguments[s],n!=null)for(t in n)i=ur(a,t),r=ur(n,t),a!==r&&(f&&r&&(ir(r)||(l=rr(r)))?(l?(l=!1,u=i&&rr(i)?i:[]):u=i&&ir(i)?i:{},lr(a,{name:t,newValue:e(f,u,r)})):typeof r<"u"&&lr(a,{name:t,newValue:r}));return a};const ar=bt(Fl);function Wt(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ol(){const e=[],n={run:t,use:i};return n;function t(...r){let l=-1;const u=r.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);a(null,...r);function a(s,...c){const f=e[++l];let o=-1;if(s){u(s);return}for(;++o<r.length;)(c[o]===null||c[o]===void 0)&&(c[o]=r[o]);r=c,f?Il(f,a)(...c):u(null,...c)}}function i(r){if(typeof r!="function")throw new TypeError("Expected `middelware` to be a function, not "+r);return e.push(r),n}}function Il(e,n){let t;return i;function i(...u){const a=e.length>u.length;let s;a&&u.push(r);try{s=e.apply(this,u)}catch(c){const f=c;if(a&&t)throw f;return r(f)}a||(s&&s.then&&typeof s.then=="function"?s.then(l,r):s instanceof Error?r(s):l(s))}function r(u,...a){t||(t=!0,n(u,...a))}function l(u){r(null,u)}}function nt(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?sr(e.position):"start"in e||"end"in e?sr(e):"line"in e||"column"in e?$t(e):""}function $t(e){return or(e&&e.line)+":"+or(e&&e.column)}function sr(e){return $t(e&&e.start)+"-"+$t(e&&e.end)}function or(e){return e&&typeof e=="number"?e:1}class le extends Error{constructor(n,t,i){const r=[null,null];let l={start:{line:null,column:null},end:{line:null,column:null}};if(super(),typeof t=="string"&&(i=t,t=void 0),typeof i=="string"){const u=i.indexOf(":");u===-1?r[1]=i:(r[0]=i.slice(0,u),r[1]=i.slice(u+1))}t&&("type"in t||"position"in t?t.position&&(l=t.position):"start"in t||"end"in t?l=t:("line"in t||"column"in t)&&(l.start=t)),this.name=nt(t)||"1:1",this.message=typeof n=="object"?n.message:n,this.stack="",typeof n=="object"&&n.stack&&(this.stack=n.stack),this.reason=this.message,this.fatal,this.line=l.start.line,this.column=l.start.column,this.position=l,this.source=r[0],this.ruleId=r[1],this.file,this.actual,this.expected,this.url,this.note}}le.prototype.file="",le.prototype.name="",le.prototype.reason="",le.prototype.message="",le.prototype.stack="",le.prototype.fatal=null,le.prototype.column=null,le.prototype.line=null,le.prototype.source=null,le.prototype.ruleId=null,le.prototype.position=null;const me={basename:Pl,dirname:_l,extname:Rl,join:Bl,sep:"/"};function Pl(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');rt(e);let t=0,i=-1,r=e.length,l;if(n===void 0||n.length===0||n.length>e.length){for(;r--;)if(e.charCodeAt(r)===47){if(l){t=r+1;break}}else i<0&&(l=!0,i=r+1);return i<0?"":e.slice(t,i)}if(n===e)return"";let u=-1,a=n.length-1;for(;r--;)if(e.charCodeAt(r)===47){if(l){t=r+1;break}}else u<0&&(l=!0,u=r+1),a>-1&&(e.charCodeAt(r)===n.charCodeAt(a--)?a<0&&(i=r):(a=-1,i=u));return t===i?i=u:i<0&&(i=e.length),e.slice(t,i)}function _l(e){if(rt(e),e.length===0)return".";let n=-1,t=e.length,i;for(;--t;)if(e.charCodeAt(t)===47){if(i){n=t;break}}else i||(i=!0);return n<0?e.charCodeAt(0)===47?"/":".":n===1&&e.charCodeAt(0)===47?"//":e.slice(0,n)}function Rl(e){rt(e);let n=e.length,t=-1,i=0,r=-1,l=0,u;for(;n--;){const a=e.charCodeAt(n);if(a===47){if(u){i=n+1;break}continue}t<0&&(u=!0,t=n+1),a===46?r<0?r=n:l!==1&&(l=1):r>-1&&(l=-1)}return r<0||t<0||l===0||l===1&&r===t-1&&r===i+1?"":e.slice(r,t)}function Bl(...e){let n=-1,t;for(;++n<e.length;)rt(e[n]),e[n]&&(t=t===void 0?e[n]:t+"/"+e[n]);return t===void 0?".":Ll(t)}function Ll(e){rt(e);const n=e.charCodeAt(0)===47;let t=vl(e,!n);return t.length===0&&!n&&(t="."),t.length>0&&e.charCodeAt(e.length-1)===47&&(t+="/"),n?"/"+t:t}function vl(e,n){let t="",i=0,r=-1,l=0,u=-1,a,s;for(;++u<=e.length;){if(u<e.length)a=e.charCodeAt(u);else{if(a===47)break;a=47}if(a===47){if(!(r===u-1||l===1))if(r!==u-1&&l===2){if(t.length<2||i!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){if(s=t.lastIndexOf("/"),s!==t.length-1){s<0?(t="",i=0):(t=t.slice(0,s),i=t.length-1-t.lastIndexOf("/")),r=u,l=0;continue}}else if(t.length>0){t="",i=0,r=u,l=0;continue}}n&&(t=t.length>0?t+"/..":"..",i=2)}else t.length>0?t+="/"+e.slice(r+1,u):t=e.slice(r+1,u),i=u-r-1;r=u,l=0}else a===46&&l>-1?l++:l=-1}return t}function rt(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Dl={cwd:Ml};function Ml(){return"/"}function qt(e){return e!==null&&typeof e=="object"&&e.href&&e.origin}function zl(e){if(typeof e=="string")e=new URL(e);else if(!qt(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return Nl(e)}function Nl(e){if(e.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const n=e.pathname;let t=-1;for(;++t<n.length;)if(n.charCodeAt(t)===37&&n.charCodeAt(t+1)===50){const i=n.charCodeAt(t+2);if(i===70||i===102){const r=new TypeError("File URL path must not include encoded / characters");throw r.code="ERR_INVALID_FILE_URL_PATH",r}}return decodeURIComponent(n)}const Gt=["history","path","basename","stem","extname","dirname"];class Hl{constructor(n){let t;n?typeof n=="string"||jl(n)?t={value:n}:qt(n)?t={path:n}:t=n:t={},this.data={},this.messages=[],this.history=[],this.cwd=Dl.cwd(),this.value,this.stored,this.result,this.map;let i=-1;for(;++i<Gt.length;){const l=Gt[i];l in t&&t[l]!==void 0&&t[l]!==null&&(this[l]=l==="history"?[...t[l]]:t[l])}let r;for(r in t)Gt.includes(r)||(this[r]=t[r])}get path(){return this.history[this.history.length-1]}set path(n){qt(n)&&(n=zl(n)),Qt(n,"path"),this.path!==n&&this.history.push(n)}get dirname(){return typeof this.path=="string"?me.dirname(this.path):void 0}set dirname(n){cr(this.basename,"dirname"),this.path=me.join(n||"",this.basename)}get basename(){return typeof this.path=="string"?me.basename(this.path):void 0}set basename(n){Qt(n,"basename"),Kt(n,"basename"),this.path=me.join(this.dirname||"",n)}get extname(){return typeof this.path=="string"?me.extname(this.path):void 0}set extname(n){if(Kt(n,"extname"),cr(this.dirname,"extname"),n){if(n.charCodeAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=me.join(this.dirname,this.stem+(n||""))}get stem(){return typeof this.path=="string"?me.basename(this.path,this.extname):void 0}set stem(n){Qt(n,"stem"),Kt(n,"stem"),this.path=me.join(this.dirname||"",n+(this.extname||""))}toString(n){return(this.value||"").toString(n||void 0)}message(n,t,i){const r=new le(n,t,i);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}info(n,t,i){const r=this.message(n,t,i);return r.fatal=null,r}fail(n,t,i){const r=this.message(n,t,i);throw r.fatal=!0,r}}function Kt(e,n){if(e&&e.includes(me.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+me.sep+"`")}function Qt(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function cr(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function jl(e){return Xn(e)}const Vl=hr().freeze(),fr={}.hasOwnProperty;function hr(){const e=Ol(),n=[];let t={},i,r=-1;return l.data=u,l.Parser=void 0,l.Compiler=void 0,l.freeze=a,l.attachers=n,l.use=s,l.parse=c,l.stringify=f,l.run=o,l.runSync=p,l.process=h,l.processSync=d,l;function l(){const y=hr();let x=-1;for(;++x<n.length;)y.use(...n[x]);return y.data(ar(!0,{},t)),y}function u(y,x){return typeof y=="string"?arguments.length===2?(Zt("data",i),t[y]=x,l):fr.call(t,y)&&t[y]||null:y?(Zt("data",i),t=y,l):t}function a(){if(i)return l;for(;++r<n.length;){const[y,...x]=n[r];if(x[0]===!1)continue;x[0]===!0&&(x[0]=void 0);const b=y.call(l,...x);typeof b=="function"&&e.use(b)}return i=!0,r=Number.POSITIVE_INFINITY,l}function s(y,...x){let b;if(Zt("use",i),y!=null)if(typeof y=="function")_(y,...x);else if(typeof y=="object")Array.isArray(y)?O(y):w(y);else throw new TypeError("Expected usable value, not `"+y+"`");return b&&(t.settings=Object.assign(t.settings||{},b)),l;function C(k){if(typeof k=="function")_(k);else if(typeof k=="object")if(Array.isArray(k)){const[S,...L]=k;_(S,...L)}else w(k);else throw new TypeError("Expected usable value, not `"+k+"`")}function w(k){O(k.plugins),k.settings&&(b=Object.assign(b||{},k.settings))}function O(k){let S=-1;if(k!=null)if(Array.isArray(k))for(;++S<k.length;){const L=k[S];C(L)}else throw new TypeError("Expected a list of plugins, not `"+k+"`")}function _(k,S){let L=-1,N;for(;++L<n.length;)if(n[L][0]===k){N=n[L];break}N?(Wt(N[1])&&Wt(S)&&(S=ar(!0,N[1],S)),N[1]=S):n.push([...arguments])}}function c(y){l.freeze();const x=it(y),b=l.Parser;return Yt("parse",b),pr(b,"parse")?new b(String(x),x).parse():b(String(x),x)}function f(y,x){l.freeze();const b=it(x),C=l.Compiler;return Jt("stringify",C),dr(y),pr(C,"compile")?new C(y,b).compile():C(y,b)}function o(y,x,b){if(dr(y),l.freeze(),!b&&typeof x=="function"&&(b=x,x=void 0),!b)return new Promise(C);C(null,b);function C(w,O){e.run(y,it(x),_);function _(k,S,L){S=S||y,k?O(k):w?w(S):b(null,S,L)}}}function p(y,x){let b,C;return l.run(y,x,w),gr("runSync","run",C),b;function w(O,_){Zn(O),b=_,C=!0}}function h(y,x){if(l.freeze(),Yt("process",l.Parser),Jt("process",l.Compiler),!x)return new Promise(b);b(null,x);function b(C,w){const O=it(y);l.run(l.parse(O),O,(k,S,L)=>{if(k||!S||!L)_(k);else{const N=l.stringify(S,L);N==null||($l(N)?L.value=N:L.result=N),_(k,L)}});function _(k,S){k||!S?w(k):C?C(S):x(null,S)}}}function d(y){let x;l.freeze(),Yt("processSync",l.Parser),Jt("processSync",l.Compiler);const b=it(y);return l.process(b,C),gr("processSync","process",x),b;function C(w){x=!0,Zn(w)}}}function pr(e,n){return typeof e=="function"&&e.prototype&&(Ul(e.prototype)||n in e.prototype)}function Ul(e){let n;for(n in e)if(fr.call(e,n))return!0;return!1}function Yt(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `Parser`")}function Jt(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `Compiler`")}function Zt(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function dr(e){if(!Wt(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function gr(e,n,t){if(!t)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function it(e){return Wl(e)?e:new Hl(e)}function Wl(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function $l(e){return typeof e=="string"||Xn(e)}const ql={};function Gl(e,n){const t=n||ql,i=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,r=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return mr(e,i,r)}function mr(e,n,t){if(Kl(e)){if("value"in e)return e.type==="html"&&!t?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return yr(e.children,n,t)}return Array.isArray(e)?yr(e,n,t):""}function yr(e,n,t){const i=[];let r=-1;for(;++r<e.length;)i[r]=mr(e[r],n,t);return i.join("")}function Kl(e){return!!(e&&typeof e=="object")}function re(e,n,t,i){const r=e.length;let l=0,u;if(n<0?n=-n>r?0:r+n:n=n>r?r:n,t=t>0?t:0,i.length<1e4)u=Array.from(i),u.unshift(n,t),e.splice(...u);else for(t&&e.splice(n,t);l<i.length;)u=i.slice(l,l+1e4),u.unshift(n,0),e.splice(...u),l+=1e4,n+=1e4}function ue(e,n){return e.length>0?(re(e,e.length,0,n),e):n}const br={}.hasOwnProperty;function xr(e){const n={};let t=-1;for(;++t<e.length;)Ql(n,e[t]);return n}function Ql(e,n){let t;for(t in n){const r=(br.call(e,t)?e[t]:void 0)||(e[t]={}),l=n[t];let u;if(l)for(u in l){br.call(r,u)||(r[u]=[]);const a=l[u];Yl(r[u],Array.isArray(a)?a:a?[a]:[])}}}function Yl(e,n){let t=-1;const i=[];for(;++t<n.length;)(n[t].add==="after"?e:i).push(n[t]);re(e,0,0,i)}const Jl=/[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,X=Pe(/[A-Za-z]/),te=Pe(/[\dA-Za-z]/),Zl=Pe(/[#-'*+\--9=?A-Z^-~]/);function kt(e){return e!==null&&(e<32||e===127)}const Xt=Pe(/\d/),Xl=Pe(/[\dA-Fa-f]/),eu=Pe(/[!-/:-@[-`{-~]/);function P(e){return e!==null&&e<-2}function V(e){return e!==null&&(e<0||e===32)}function v(e){return e===-2||e===-1||e===32}const wt=Pe(Jl),Me=Pe(/\s/);function Pe(e){return n;function n(t){return t!==null&&e.test(String.fromCharCode(t))}}function M(e,n,t,i){const r=i?i-1:Number.POSITIVE_INFINITY;let l=0;return u;function u(s){return v(s)?(e.enter(t),a(s)):n(s)}function a(s){return v(s)&&l++<r?(e.consume(s),a):(e.exit(t),n(s))}}const tu={tokenize:nu};function nu(e){const n=e.attempt(this.parser.constructs.contentInitial,i,r);let t;return n;function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),M(e,n,"linePrefix")}function r(a){return e.enter("paragraph"),l(a)}function l(a){const s=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=s),t=s,u(a)}function u(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return P(a)?(e.consume(a),e.exit("chunkText"),l):(e.consume(a),u)}}const ru={tokenize:iu},kr={tokenize:lu};function iu(e){const n=this,t=[];let i=0,r,l,u;return a;function a(w){if(i<t.length){const O=t[i];return n.containerState=O[1],e.attempt(O[0].continuation,s,c)(w)}return c(w)}function s(w){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,r&&C();const O=n.events.length;let _=O,k;for(;_--;)if(n.events[_][0]==="exit"&&n.events[_][1].type==="chunkFlow"){k=n.events[_][1].end;break}b(i);let S=O;for(;S<n.events.length;)n.events[S][1].end=Object.assign({},k),S++;return re(n.events,_+1,0,n.events.slice(O)),n.events.length=S,c(w)}return a(w)}function c(w){if(i===t.length){if(!r)return p(w);if(r.currentConstruct&&r.currentConstruct.concrete)return d(w);n.interrupt=!!(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(kr,f,o)(w)}function f(w){return r&&C(),b(i),p(w)}function o(w){return n.parser.lazy[n.now().line]=i!==t.length,u=n.now().offset,d(w)}function p(w){return n.containerState={},e.attempt(kr,h,d)(w)}function h(w){return i++,t.push([n.currentConstruct,n.containerState]),p(w)}function d(w){if(w===null){r&&C(),b(0),e.consume(w);return}return r=r||n.parser.flow(n.now()),e.enter("chunkFlow",{contentType:"flow",previous:l,_tokenizer:r}),y(w)}function y(w){if(w===null){x(e.exit("chunkFlow"),!0),b(0),e.consume(w);return}return P(w)?(e.consume(w),x(e.exit("chunkFlow")),i=0,n.interrupt=void 0,a):(e.consume(w),y)}function x(w,O){const _=n.sliceStream(w);if(O&&_.push(null),w.previous=l,l&&(l.next=w),l=w,r.defineSkip(w.start),r.write(_),n.parser.lazy[w.start.line]){let k=r.events.length;for(;k--;)if(r.events[k][1].start.offset<u&&(!r.events[k][1].end||r.events[k][1].end.offset>u))return;const S=n.events.length;let L=S,N,E;for(;L--;)if(n.events[L][0]==="exit"&&n.events[L][1].type==="chunkFlow"){if(N){E=n.events[L][1].end;break}N=!0}for(b(i),k=S;k<n.events.length;)n.events[k][1].end=Object.assign({},E),k++;re(n.events,L+1,0,n.events.slice(S)),n.events.length=k}}function b(w){let O=t.length;for(;O-- >w;){const _=t[O];n.containerState=_[1],_[0].exit.call(n,e)}t.length=w}function C(){r.write([null]),l=void 0,r=void 0,n.containerState._closeFlow=void 0}}function lu(e,n,t){return M(e,e.attempt(this.parser.constructs.document,n,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Et(e){if(e===null||V(e)||Me(e))return 1;if(wt(e))return 2}function At(e,n,t){const i=[];let r=-1;for(;++r<e.length;){const l=e[r].resolveAll;l&&!i.includes(l)&&(n=l(n,t),i.push(l))}return n}const en={name:"attention",tokenize:au,resolveAll:uu};function uu(e,n){let t=-1,i,r,l,u,a,s,c,f;for(;++t<e.length;)if(e[t][0]==="enter"&&e[t][1].type==="attentionSequence"&&e[t][1]._close){for(i=t;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&n.sliceSerialize(e[i][1]).charCodeAt(0)===n.sliceSerialize(e[t][1]).charCodeAt(0)){if((e[i][1]._close||e[t][1]._open)&&(e[t][1].end.offset-e[t][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[t][1].end.offset-e[t][1].start.offset)%3))continue;s=e[i][1].end.offset-e[i][1].start.offset>1&&e[t][1].end.offset-e[t][1].start.offset>1?2:1;const o=Object.assign({},e[i][1].end),p=Object.assign({},e[t][1].start);wr(o,-s),wr(p,s),u={type:s>1?"strongSequence":"emphasisSequence",start:o,end:Object.assign({},e[i][1].end)},a={type:s>1?"strongSequence":"emphasisSequence",start:Object.assign({},e[t][1].start),end:p},l={type:s>1?"strongText":"emphasisText",start:Object.assign({},e[i][1].end),end:Object.assign({},e[t][1].start)},r={type:s>1?"strong":"emphasis",start:Object.assign({},u.start),end:Object.assign({},a.end)},e[i][1].end=Object.assign({},u.start),e[t][1].start=Object.assign({},a.end),c=[],e[i][1].end.offset-e[i][1].start.offset&&(c=ue(c,[["enter",e[i][1],n],["exit",e[i][1],n]])),c=ue(c,[["enter",r,n],["enter",u,n],["exit",u,n],["enter",l,n]]),c=ue(c,At(n.parser.constructs.insideSpan.null,e.slice(i+1,t),n)),c=ue(c,[["exit",l,n],["enter",a,n],["exit",a,n],["exit",r,n]]),e[t][1].end.offset-e[t][1].start.offset?(f=2,c=ue(c,[["enter",e[t][1],n],["exit",e[t][1],n]])):f=0,re(e,i-1,t-i+3,c),t=i+c.length-f-2;break}}for(t=-1;++t<e.length;)e[t][1].type==="attentionSequence"&&(e[t][1].type="data");return e}function au(e,n){const t=this.parser.constructs.attentionMarkers.null,i=this.previous,r=Et(i);let l;return u;function u(s){return l=s,e.enter("attentionSequence"),a(s)}function a(s){if(s===l)return e.consume(s),a;const c=e.exit("attentionSequence"),f=Et(s),o=!f||f===2&&r||t.includes(s),p=!r||r===2&&f||t.includes(i);return c._open=!!(l===42?o:o&&(r||!p)),c._close=!!(l===42?p:p&&(f||!o)),n(s)}}function wr(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const su={name:"autolink",tokenize:ou};function ou(e,n,t){let i=0;return r;function r(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(h){return X(h)?(e.consume(h),u):c(h)}function u(h){return h===43||h===45||h===46||te(h)?(i=1,a(h)):c(h)}function a(h){return h===58?(e.consume(h),i=0,s):(h===43||h===45||h===46||te(h))&&i++<32?(e.consume(h),a):(i=0,c(h))}function s(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),n):h===null||h===32||h===60||kt(h)?t(h):(e.consume(h),s)}function c(h){return h===64?(e.consume(h),f):Zl(h)?(e.consume(h),c):t(h)}function f(h){return te(h)?o(h):t(h)}function o(h){return h===46?(e.consume(h),i=0,f):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),n):p(h)}function p(h){if((h===45||te(h))&&i++<63){const d=h===45?p:o;return e.consume(h),d}return t(h)}}const lt={tokenize:cu,partial:!0};function cu(e,n,t){return i;function i(l){return v(l)?M(e,r,"linePrefix")(l):r(l)}function r(l){return l===null||P(l)?n(l):t(l)}}const Er={name:"blockQuote",tokenize:fu,continuation:{tokenize:hu},exit:pu};function fu(e,n,t){const i=this;return r;function r(u){if(u===62){const a=i.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(u),e.exit("blockQuoteMarker"),l}return t(u)}function l(u){return v(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(u))}}function hu(e,n,t){const i=this;return r;function r(u){return v(u)?M(e,l,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):l(u)}function l(u){return e.attempt(Er,n,t)(u)}}function pu(e){e.exit("blockQuote")}const Ar={name:"characterEscape",tokenize:du};function du(e,n,t){return i;function i(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),r}function r(l){return eu(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):t(l)}}const Sr=document.createElement("i");function tn(e){const n="&"+e+";";Sr.innerHTML=n;const t=Sr.textContent;return t.charCodeAt(t.length-1)===59&&e!=="semi"||t===n?!1:t}const Cr={name:"characterReference",tokenize:gu};function gu(e,n,t){const i=this;let r=0,l,u;return a;function a(o){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(o),e.exit("characterReferenceMarker"),s}function s(o){return o===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(o),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),l=31,u=te,f(o))}function c(o){return o===88||o===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(o),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,u=Xl,f):(e.enter("characterReferenceValue"),l=7,u=Xt,f(o))}function f(o){if(o===59&&r){const p=e.exit("characterReferenceValue");return u===te&&!tn(i.sliceSerialize(p))?t(o):(e.enter("characterReferenceMarker"),e.consume(o),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return u(o)&&r++<l?(e.consume(o),f):t(o)}}const Tr={tokenize:yu,partial:!0},Fr={name:"codeFenced",tokenize:mu,concrete:!0};function mu(e,n,t){const i=this,r={tokenize:_,partial:!0};let l=0,u=0,a;return s;function s(k){return c(k)}function c(k){const S=i.events[i.events.length-1];return l=S&&S[1].type==="linePrefix"?S[2].sliceSerialize(S[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(k)}function f(k){return k===a?(u++,e.consume(k),f):u<3?t(k):(e.exit("codeFencedFenceSequence"),v(k)?M(e,o,"whitespace")(k):o(k))}function o(k){return k===null||P(k)?(e.exit("codeFencedFence"),i.interrupt?n(k):e.check(Tr,y,O)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(k))}function p(k){return k===null||P(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),o(k)):v(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),M(e,h,"whitespace")(k)):k===96&&k===a?t(k):(e.consume(k),p)}function h(k){return k===null||P(k)?o(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),d(k))}function d(k){return k===null||P(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),o(k)):k===96&&k===a?t(k):(e.consume(k),d)}function y(k){return e.attempt(r,O,x)(k)}function x(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),b}function b(k){return l>0&&v(k)?M(e,C,"linePrefix",l+1)(k):C(k)}function C(k){return k===null||P(k)?e.check(Tr,y,O)(k):(e.enter("codeFlowValue"),w(k))}function w(k){return k===null||P(k)?(e.exit("codeFlowValue"),C(k)):(e.consume(k),w)}function O(k){return e.exit("codeFenced"),n(k)}function _(k,S,L){let N=0;return E;function E(z){return k.enter("lineEnding"),k.consume(z),k.exit("lineEnding"),F}function F(z){return k.enter("codeFencedFence"),v(z)?M(k,I,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):I(z)}function I(z){return z===a?(k.enter("codeFencedFenceSequence"),U(z)):L(z)}function U(z){return z===a?(N++,k.consume(z),U):N>=u?(k.exit("codeFencedFenceSequence"),v(z)?M(k,G,"whitespace")(z):G(z)):L(z)}function G(z){return z===null||P(z)?(k.exit("codeFencedFence"),S(z)):L(z)}}}function yu(e,n,t){const i=this;return r;function r(u){return u===null?t(u):(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l)}function l(u){return i.parser.lazy[i.now().line]?t(u):n(u)}}const nn={name:"codeIndented",tokenize:xu},bu={tokenize:ku,partial:!0};function xu(e,n,t){const i=this;return r;function r(c){return e.enter("codeIndented"),M(e,l,"linePrefix",5)(c)}function l(c){const f=i.events[i.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?u(c):t(c)}function u(c){return c===null?s(c):P(c)?e.attempt(bu,u,s)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||P(c)?(e.exit("codeFlowValue"),u(c)):(e.consume(c),a)}function s(c){return e.exit("codeIndented"),n(c)}}function ku(e,n,t){const i=this;return r;function r(u){return i.parser.lazy[i.now().line]?t(u):P(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),r):M(e,l,"linePrefix",5)(u)}function l(u){const a=i.events[i.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?n(u):P(u)?r(u):t(u)}}const wu={name:"codeText",tokenize:Su,resolve:Eu,previous:Au};function Eu(e){let n=e.length-4,t=3,i,r;if((e[t][1].type==="lineEnding"||e[t][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(i=t;++i<n;)if(e[i][1].type==="codeTextData"){e[t][1].type="codeTextPadding",e[n][1].type="codeTextPadding",t+=2,n-=2;break}}for(i=t-1,n++;++i<=n;)r===void 0?i!==n&&e[i][1].type!=="lineEnding"&&(r=i):(i===n||e[i][1].type==="lineEnding")&&(e[r][1].type="codeTextData",i!==r+2&&(e[r][1].end=e[i-1][1].end,e.splice(r+2,i-r-2),n-=i-r-2,i=r+2),r=void 0);return e}function Au(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Su(e,n,t){let i=0,r,l;return u;function u(o){return e.enter("codeText"),e.enter("codeTextSequence"),a(o)}function a(o){return o===96?(e.consume(o),i++,a):(e.exit("codeTextSequence"),s(o))}function s(o){return o===null?t(o):o===32?(e.enter("space"),e.consume(o),e.exit("space"),s):o===96?(l=e.enter("codeTextSequence"),r=0,f(o)):P(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):(e.enter("codeTextData"),c(o))}function c(o){return o===null||o===32||o===96||P(o)?(e.exit("codeTextData"),s(o)):(e.consume(o),c)}function f(o){return o===96?(e.consume(o),r++,f):r===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(o)):(l.type="codeTextData",c(o))}}function Or(e){const n={};let t=-1,i,r,l,u,a,s,c;for(;++t<e.length;){for(;t in n;)t=n[t];if(i=e[t],t&&i[1].type==="chunkFlow"&&e[t-1][1].type==="listItemPrefix"&&(s=i[1]._tokenizer.events,l=0,l<s.length&&s[l][1].type==="lineEndingBlank"&&(l+=2),l<s.length&&s[l][1].type==="content"))for(;++l<s.length&&s[l][1].type!=="content";)s[l][1].type==="chunkText"&&(s[l][1]._isInFirstContentOfListItem=!0,l++);if(i[0]==="enter")i[1].contentType&&(Object.assign(n,Cu(e,t)),t=n[t],c=!0);else if(i[1]._container){for(l=t,r=void 0;l--&&(u=e[l],u[1].type==="lineEnding"||u[1].type==="lineEndingBlank");)u[0]==="enter"&&(r&&(e[r][1].type="lineEndingBlank"),u[1].type="lineEnding",r=l);r&&(i[1].end=Object.assign({},e[r][1].start),a=e.slice(r,t),a.unshift(i),re(e,r,t-r+1,a))}}return!c}function Cu(e,n){const t=e[n][1],i=e[n][2];let r=n-1;const l=[],u=t._tokenizer||i.parser[t.contentType](t.start),a=u.events,s=[],c={};let f,o,p=-1,h=t,d=0,y=0;const x=[y];for(;h;){for(;e[++r][1]!==h;);l.push(r),h._tokenizer||(f=i.sliceStream(h),h.next||f.push(null),o&&u.defineSkip(h.start),h._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(f),h._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),o=h,h=h.next}for(h=t;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(y=p+1,x.push(y),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(u.events=[],h?(h._tokenizer=void 0,h.previous=void 0):x.pop(),p=x.length;p--;){const b=a.slice(x[p],x[p+1]),C=l.pop();s.unshift([C,C+b.length-1]),re(e,C,2,b)}for(p=-1;++p<s.length;)c[d+s[p][0]]=d+s[p][1],d+=s[p][1]-s[p][0]-1;return c}const Tu={tokenize:Iu,resolve:Ou},Fu={tokenize:Pu,partial:!0};function Ou(e){return Or(e),e}function Iu(e,n){let t;return i;function i(a){return e.enter("content"),t=e.enter("chunkContent",{contentType:"content"}),r(a)}function r(a){return a===null?l(a):P(a)?e.check(Fu,u,l)(a):(e.consume(a),r)}function l(a){return e.exit("chunkContent"),e.exit("content"),n(a)}function u(a){return e.consume(a),e.exit("chunkContent"),t.next=e.enter("chunkContent",{contentType:"content",previous:t}),t=t.next,r}}function Pu(e,n,t){const i=this;return r;function r(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),M(e,l,"linePrefix")}function l(u){if(u===null||P(u))return t(u);const a=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?n(u):e.interrupt(i.parser.constructs.flow,t,n)(u)}}function Ir(e,n,t,i,r,l,u,a,s){const c=s||Number.POSITIVE_INFINITY;let f=0;return o;function o(b){return b===60?(e.enter(i),e.enter(r),e.enter(l),e.consume(b),e.exit(l),p):b===null||b===32||b===41||kt(b)?t(b):(e.enter(i),e.enter(u),e.enter(a),e.enter("chunkString",{contentType:"string"}),y(b))}function p(b){return b===62?(e.enter(l),e.consume(b),e.exit(l),e.exit(r),e.exit(i),n):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(b))}function h(b){return b===62?(e.exit("chunkString"),e.exit(a),p(b)):b===null||b===60||P(b)?t(b):(e.consume(b),b===92?d:h)}function d(b){return b===60||b===62||b===92?(e.consume(b),h):h(b)}function y(b){return!f&&(b===null||b===41||V(b))?(e.exit("chunkString"),e.exit(a),e.exit(u),e.exit(i),n(b)):f<c&&b===40?(e.consume(b),f++,y):b===41?(e.consume(b),f--,y):b===null||b===32||b===40||kt(b)?t(b):(e.consume(b),b===92?x:y)}function x(b){return b===40||b===41||b===92?(e.consume(b),y):y(b)}}function Pr(e,n,t,i,r,l){const u=this;let a=0,s;return c;function c(h){return e.enter(i),e.enter(r),e.consume(h),e.exit(r),e.enter(l),f}function f(h){return a>999||h===null||h===91||h===93&&!s||h===94&&!a&&"_hiddenFootnoteSupport"in u.parser.constructs?t(h):h===93?(e.exit(l),e.enter(r),e.consume(h),e.exit(r),e.exit(i),n):P(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),o(h))}function o(h){return h===null||h===91||h===93||P(h)||a++>999?(e.exit("chunkString"),f(h)):(e.consume(h),s||(s=!v(h)),h===92?p:o)}function p(h){return h===91||h===92||h===93?(e.consume(h),a++,o):o(h)}}function _r(e,n,t,i,r,l){let u;return a;function a(p){return p===34||p===39||p===40?(e.enter(i),e.enter(r),e.consume(p),e.exit(r),u=p===40?41:p,s):t(p)}function s(p){return p===u?(e.enter(r),e.consume(p),e.exit(r),e.exit(i),n):(e.enter(l),c(p))}function c(p){return p===u?(e.exit(l),s(u)):p===null?t(p):P(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),M(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===u||p===null||P(p)?(e.exit("chunkString"),c(p)):(e.consume(p),p===92?o:f)}function o(p){return p===u||p===92?(e.consume(p),f):f(p)}}function ut(e,n){let t;return i;function i(r){return P(r)?(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t=!0,i):v(r)?M(e,i,t?"linePrefix":"lineSuffix")(r):n(r)}}function ce(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const _u={name:"definition",tokenize:Bu},Ru={tokenize:Lu,partial:!0};function Bu(e,n,t){const i=this;let r;return l;function l(h){return e.enter("definition"),u(h)}function u(h){return Pr.call(i,e,a,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function a(h){return r=ce(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),s):t(h)}function s(h){return V(h)?ut(e,c)(h):c(h)}function c(h){return Ir(e,f,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function f(h){return e.attempt(Ru,o,o)(h)}function o(h){return v(h)?M(e,p,"whitespace")(h):p(h)}function p(h){return h===null||P(h)?(e.exit("definition"),i.parser.defined.push(r),n(h)):t(h)}}function Lu(e,n,t){return i;function i(a){return V(a)?ut(e,r)(a):t(a)}function r(a){return _r(e,l,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function l(a){return v(a)?M(e,u,"whitespace")(a):u(a)}function u(a){return a===null||P(a)?n(a):t(a)}}const vu={name:"hardBreakEscape",tokenize:Du};function Du(e,n,t){return i;function i(l){return e.enter("hardBreakEscape"),e.consume(l),r}function r(l){return P(l)?(e.exit("hardBreakEscape"),n(l)):t(l)}}const Mu={name:"headingAtx",tokenize:Nu,resolve:zu};function zu(e,n){let t=e.length-2,i=3,r,l;return e[i][1].type==="whitespace"&&(i+=2),t-2>i&&e[t][1].type==="whitespace"&&(t-=2),e[t][1].type==="atxHeadingSequence"&&(i===t-1||t-4>i&&e[t-2][1].type==="whitespace")&&(t-=i+1===t?2:4),t>i&&(r={type:"atxHeadingText",start:e[i][1].start,end:e[t][1].end},l={type:"chunkText",start:e[i][1].start,end:e[t][1].end,contentType:"text"},re(e,i,t-i+1,[["enter",r,n],["enter",l,n],["exit",l,n],["exit",r,n]])),e}function Nu(e,n,t){let i=0;return r;function r(f){return e.enter("atxHeading"),l(f)}function l(f){return e.enter("atxHeadingSequence"),u(f)}function u(f){return f===35&&i++<6?(e.consume(f),u):f===null||V(f)?(e.exit("atxHeadingSequence"),a(f)):t(f)}function a(f){return f===35?(e.enter("atxHeadingSequence"),s(f)):f===null||P(f)?(e.exit("atxHeading"),n(f)):v(f)?M(e,a,"whitespace")(f):(e.enter("atxHeadingText"),c(f))}function s(f){return f===35?(e.consume(f),s):(e.exit("atxHeadingSequence"),a(f))}function c(f){return f===null||f===35||V(f)?(e.exit("atxHeadingText"),a(f)):(e.consume(f),c)}}const Hu=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Rr=["pre","script","style","textarea"],ju={name:"htmlFlow",tokenize:$u,resolveTo:Wu,concrete:!0},Vu={tokenize:Gu,partial:!0},Uu={tokenize:qu,partial:!0};function Wu(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function $u(e,n,t){const i=this;let r,l,u,a,s;return c;function c(m){return f(m)}function f(m){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(m),o}function o(m){return m===33?(e.consume(m),p):m===47?(e.consume(m),l=!0,y):m===63?(e.consume(m),r=3,i.interrupt?n:g):X(m)?(e.consume(m),u=String.fromCharCode(m),x):t(m)}function p(m){return m===45?(e.consume(m),r=2,h):m===91?(e.consume(m),r=5,a=0,d):X(m)?(e.consume(m),r=4,i.interrupt?n:g):t(m)}function h(m){return m===45?(e.consume(m),i.interrupt?n:g):t(m)}function d(m){const de="CDATA[";return m===de.charCodeAt(a++)?(e.consume(m),a===de.length?i.interrupt?n:I:d):t(m)}function y(m){return X(m)?(e.consume(m),u=String.fromCharCode(m),x):t(m)}function x(m){if(m===null||m===47||m===62||V(m)){const de=m===47,Je=u.toLowerCase();return!de&&!l&&Rr.includes(Je)?(r=1,i.interrupt?n(m):I(m)):Hu.includes(u.toLowerCase())?(r=6,de?(e.consume(m),b):i.interrupt?n(m):I(m)):(r=7,i.interrupt&&!i.parser.lazy[i.now().line]?t(m):l?C(m):w(m))}return m===45||te(m)?(e.consume(m),u+=String.fromCharCode(m),x):t(m)}function b(m){return m===62?(e.consume(m),i.interrupt?n:I):t(m)}function C(m){return v(m)?(e.consume(m),C):E(m)}function w(m){return m===47?(e.consume(m),E):m===58||m===95||X(m)?(e.consume(m),O):v(m)?(e.consume(m),w):E(m)}function O(m){return m===45||m===46||m===58||m===95||te(m)?(e.consume(m),O):_(m)}function _(m){return m===61?(e.consume(m),k):v(m)?(e.consume(m),_):w(m)}function k(m){return m===null||m===60||m===61||m===62||m===96?t(m):m===34||m===39?(e.consume(m),s=m,S):v(m)?(e.consume(m),k):L(m)}function S(m){return m===s?(e.consume(m),s=null,N):m===null||P(m)?t(m):(e.consume(m),S)}function L(m){return m===null||m===34||m===39||m===47||m===60||m===61||m===62||m===96||V(m)?_(m):(e.consume(m),L)}function N(m){return m===47||m===62||v(m)?w(m):t(m)}function E(m){return m===62?(e.consume(m),F):t(m)}function F(m){return m===null||P(m)?I(m):v(m)?(e.consume(m),F):t(m)}function I(m){return m===45&&r===2?(e.consume(m),Z):m===60&&r===1?(e.consume(m),Y):m===62&&r===4?(e.consume(m),pe):m===63&&r===3?(e.consume(m),g):m===93&&r===5?(e.consume(m),Te):P(m)&&(r===6||r===7)?(e.exit("htmlFlowData"),e.check(Vu,Fe,U)(m)):m===null||P(m)?(e.exit("htmlFlowData"),U(m)):(e.consume(m),I)}function U(m){return e.check(Uu,G,Fe)(m)}function G(m){return e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),z}function z(m){return m===null||P(m)?U(m):(e.enter("htmlFlowData"),I(m))}function Z(m){return m===45?(e.consume(m),g):I(m)}function Y(m){return m===47?(e.consume(m),u="",he):I(m)}function he(m){if(m===62){const de=u.toLowerCase();return Rr.includes(de)?(e.consume(m),pe):I(m)}return X(m)&&u.length<8?(e.consume(m),u+=String.fromCharCode(m),he):I(m)}function Te(m){return m===93?(e.consume(m),g):I(m)}function g(m){return m===62?(e.consume(m),pe):m===45&&r===2?(e.consume(m),g):I(m)}function pe(m){return m===null||P(m)?(e.exit("htmlFlowData"),Fe(m)):(e.consume(m),pe)}function Fe(m){return e.exit("htmlFlow"),n(m)}}function qu(e,n,t){const i=this;return r;function r(u){return P(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l):t(u)}function l(u){return i.parser.lazy[i.now().line]?t(u):n(u)}}function Gu(e,n,t){return i;function i(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(lt,n,t)}}const Ku={name:"htmlText",tokenize:Qu};function Qu(e,n,t){const i=this;let r,l,u;return a;function a(g){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(g),s}function s(g){return g===33?(e.consume(g),c):g===47?(e.consume(g),_):g===63?(e.consume(g),w):X(g)?(e.consume(g),L):t(g)}function c(g){return g===45?(e.consume(g),f):g===91?(e.consume(g),l=0,d):X(g)?(e.consume(g),C):t(g)}function f(g){return g===45?(e.consume(g),h):t(g)}function o(g){return g===null?t(g):g===45?(e.consume(g),p):P(g)?(u=o,Y(g)):(e.consume(g),o)}function p(g){return g===45?(e.consume(g),h):o(g)}function h(g){return g===62?Z(g):g===45?p(g):o(g)}function d(g){const pe="CDATA[";return g===pe.charCodeAt(l++)?(e.consume(g),l===pe.length?y:d):t(g)}function y(g){return g===null?t(g):g===93?(e.consume(g),x):P(g)?(u=y,Y(g)):(e.consume(g),y)}function x(g){return g===93?(e.consume(g),b):y(g)}function b(g){return g===62?Z(g):g===93?(e.consume(g),b):y(g)}function C(g){return g===null||g===62?Z(g):P(g)?(u=C,Y(g)):(e.consume(g),C)}function w(g){return g===null?t(g):g===63?(e.consume(g),O):P(g)?(u=w,Y(g)):(e.consume(g),w)}function O(g){return g===62?Z(g):w(g)}function _(g){return X(g)?(e.consume(g),k):t(g)}function k(g){return g===45||te(g)?(e.consume(g),k):S(g)}function S(g){return P(g)?(u=S,Y(g)):v(g)?(e.consume(g),S):Z(g)}function L(g){return g===45||te(g)?(e.consume(g),L):g===47||g===62||V(g)?N(g):t(g)}function N(g){return g===47?(e.consume(g),Z):g===58||g===95||X(g)?(e.consume(g),E):P(g)?(u=N,Y(g)):v(g)?(e.consume(g),N):Z(g)}function E(g){return g===45||g===46||g===58||g===95||te(g)?(e.consume(g),E):F(g)}function F(g){return g===61?(e.consume(g),I):P(g)?(u=F,Y(g)):v(g)?(e.consume(g),F):N(g)}function I(g){return g===null||g===60||g===61||g===62||g===96?t(g):g===34||g===39?(e.consume(g),r=g,U):P(g)?(u=I,Y(g)):v(g)?(e.consume(g),I):(e.consume(g),G)}function U(g){return g===r?(e.consume(g),r=void 0,z):g===null?t(g):P(g)?(u=U,Y(g)):(e.consume(g),U)}function G(g){return g===null||g===34||g===39||g===60||g===61||g===96?t(g):g===47||g===62||V(g)?N(g):(e.consume(g),G)}function z(g){return g===47||g===62||V(g)?N(g):t(g)}function Z(g){return g===62?(e.consume(g),e.exit("htmlTextData"),e.exit("htmlText"),n):t(g)}function Y(g){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),he}function he(g){return v(g)?M(e,Te,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(g):Te(g)}function Te(g){return e.enter("htmlTextData"),u(g)}}const rn={name:"labelEnd",tokenize:ta,resolveTo:ea,resolveAll:Xu},Yu={tokenize:na},Ju={tokenize:ra},Zu={tokenize:ia};function Xu(e){let n=-1;for(;++n<e.length;){const t=e[n][1];(t.type==="labelImage"||t.type==="labelLink"||t.type==="labelEnd")&&(e.splice(n+1,t.type==="labelImage"?4:2),t.type="data",n++)}return e}function ea(e,n){let t=e.length,i=0,r,l,u,a;for(;t--;)if(r=e[t][1],l){if(r.type==="link"||r.type==="labelLink"&&r._inactive)break;e[t][0]==="enter"&&r.type==="labelLink"&&(r._inactive=!0)}else if(u){if(e[t][0]==="enter"&&(r.type==="labelImage"||r.type==="labelLink")&&!r._balanced&&(l=t,r.type!=="labelLink")){i=2;break}}else r.type==="labelEnd"&&(u=t);const s={type:e[l][1].type==="labelLink"?"link":"image",start:Object.assign({},e[l][1].start),end:Object.assign({},e[e.length-1][1].end)},c={type:"label",start:Object.assign({},e[l][1].start),end:Object.assign({},e[u][1].end)},f={type:"labelText",start:Object.assign({},e[l+i+2][1].end),end:Object.assign({},e[u-2][1].start)};return a=[["enter",s,n],["enter",c,n]],a=ue(a,e.slice(l+1,l+i+3)),a=ue(a,[["enter",f,n]]),a=ue(a,At(n.parser.constructs.insideSpan.null,e.slice(l+i+4,u-3),n)),a=ue(a,[["exit",f,n],e[u-2],e[u-1],["exit",c,n]]),a=ue(a,e.slice(u+1)),a=ue(a,[["exit",s,n]]),re(e,l,e.length,a),e}function ta(e,n,t){const i=this;let r=i.events.length,l,u;for(;r--;)if((i.events[r][1].type==="labelImage"||i.events[r][1].type==="labelLink")&&!i.events[r][1]._balanced){l=i.events[r][1];break}return a;function a(p){return l?l._inactive?o(p):(u=i.parser.defined.includes(ce(i.sliceSerialize({start:l.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),s):t(p)}function s(p){return p===40?e.attempt(Yu,f,u?f:o)(p):p===91?e.attempt(Ju,f,u?c:o)(p):u?f(p):o(p)}function c(p){return e.attempt(Zu,f,o)(p)}function f(p){return n(p)}function o(p){return l._balanced=!0,t(p)}}function na(e,n,t){return i;function i(o){return e.enter("resource"),e.enter("resourceMarker"),e.consume(o),e.exit("resourceMarker"),r}function r(o){return V(o)?ut(e,l)(o):l(o)}function l(o){return o===41?f(o):Ir(e,u,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(o)}function u(o){return V(o)?ut(e,s)(o):f(o)}function a(o){return t(o)}function s(o){return o===34||o===39||o===40?_r(e,c,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(o):f(o)}function c(o){return V(o)?ut(e,f)(o):f(o)}function f(o){return o===41?(e.enter("resourceMarker"),e.consume(o),e.exit("resourceMarker"),e.exit("resource"),n):t(o)}}function ra(e,n,t){const i=this;return r;function r(a){return Pr.call(i,e,l,u,"reference","referenceMarker","referenceString")(a)}function l(a){return i.parser.defined.includes(ce(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(a):t(a)}function u(a){return t(a)}}function ia(e,n,t){return i;function i(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),r}function r(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),n):t(l)}}const la={name:"labelStartImage",tokenize:ua,resolveAll:rn.resolveAll};function ua(e,n,t){const i=this;return r;function r(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),l}function l(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),u):t(a)}function u(a){return a===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(a):n(a)}}const aa={name:"labelStartLink",tokenize:sa,resolveAll:rn.resolveAll};function sa(e,n,t){const i=this;return r;function r(u){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(u),e.exit("labelMarker"),e.exit("labelLink"),l}function l(u){return u===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(u):n(u)}}const ln={name:"lineEnding",tokenize:oa};function oa(e,n){return t;function t(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),M(e,n,"linePrefix")}}const St={name:"thematicBreak",tokenize:ca};function ca(e,n,t){let i=0,r;return l;function l(c){return e.enter("thematicBreak"),u(c)}function u(c){return r=c,a(c)}function a(c){return c===r?(e.enter("thematicBreakSequence"),s(c)):i>=3&&(c===null||P(c))?(e.exit("thematicBreak"),n(c)):t(c)}function s(c){return c===r?(e.consume(c),i++,s):(e.exit("thematicBreakSequence"),v(c)?M(e,a,"whitespace")(c):a(c))}}const ne={name:"list",tokenize:pa,continuation:{tokenize:da},exit:ma},fa={tokenize:ya,partial:!0},ha={tokenize:ga,partial:!0};function pa(e,n,t){const i=this,r=i.events[i.events.length-1];let l=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0,u=0;return a;function a(h){const d=i.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(d==="listUnordered"?!i.containerState.marker||h===i.containerState.marker:Xt(h)){if(i.containerState.type||(i.containerState.type=d,e.enter(d,{_container:!0})),d==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(St,t,c)(h):c(h);if(!i.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),s(h)}return t(h)}function s(h){return Xt(h)&&++u<10?(e.consume(h),s):(!i.interrupt||u<2)&&(i.containerState.marker?h===i.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),c(h)):t(h)}function c(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||h,e.check(lt,i.interrupt?t:f,e.attempt(fa,p,o))}function f(h){return i.containerState.initialBlankLine=!0,l++,p(h)}function o(h){return v(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):t(h)}function p(h){return i.containerState.size=l+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(h)}}function da(e,n,t){const i=this;return i.containerState._closeFlow=void 0,e.check(lt,r,l);functio