UNPKG

changelog-tools

Version:

A set of tools for changelog parsing and generation

119 lines (103 loc) 57.5 kB
"use strict";(()=>{var Oe=Object.create;var pe=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty;var qe=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var Ne=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of je(e))!De.call(o,s)&&s!==t&&pe(o,s,{get:()=>e[s],enumerable:!(n=Ge(e,s))||n.enumerable});return o};var He=(o,e,t)=>(t=o!=null?Oe(Me(o)):{},Ne(e||!o||!o.__esModule?pe(t,"default",{value:o,enumerable:!0}):t,o));var de=qe((It,ge)=>{ge.exports=function(o,e){e=e||{},e.listUnicodeChar=e.hasOwnProperty("listUnicodeChar")?e.listUnicodeChar:!1,e.stripListLeaders=e.hasOwnProperty("stripListLeaders")?e.stripListLeaders:!0,e.gfm=e.hasOwnProperty("gfm")?e.gfm:!0,e.useImgAltText=e.hasOwnProperty("useImgAltText")?e.useImgAltText:!0,e.abbr=e.hasOwnProperty("abbr")?e.abbr:!1,e.replaceLinksWithURL=e.hasOwnProperty("replaceLinksWithURL")?e.replaceLinksWithURL:!1,e.htmlTagsToSkip=e.hasOwnProperty("htmlTagsToSkip")?e.htmlTagsToSkip:[],e.throwError=e.hasOwnProperty("throwError")?e.throwError:!1;var t=o||"";t=t.replace(/^(-\s*?|\*\s*?|_\s*?){3,}\s*/gm,"");try{e.stripListLeaders&&(e.listUnicodeChar?t=t.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,e.listUnicodeChar+" $1"):t=t.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,"$1")),e.gfm&&(t=t.replace(/\n={2,}/g,` `).replace(/~{3}.*\n/g,"").replace(/~~/g,"").replace(/`{3}.*\n/g,"")),e.abbr&&(t=t.replace(/\*\[.*\]:.*\n/,"")),t=t.replace(/<[^>]*>/g,"");var n=new RegExp("<[^>]*>","g");if(e.htmlTagsToSkip.length>0){var s="(?!"+e.htmlTagsToSkip.join("|")+")";n=new RegExp("<"+s+"[^>]*>","ig")}t=t.replace(n,"").replace(/^[=\-]{2,}\s*$/g,"").replace(/\[\^.+?\](\: .*?$)?/g,"").replace(/\s{0,2}\[.*?\]: .*?$/g,"").replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g,e.useImgAltText?"$1":"").replace(/\[([^\]]*?)\][\[\(].*?[\]\)]/g,e.replaceLinksWithURL?"$2":"$1").replace(/^(\n)?\s{0,3}>\s?/gm,"$1").replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g,"").replace(/^(\n)?\s{0,}#{1,6}\s*( (.+))? +#+$|^(\n)?\s{0,}#{1,6}\s*( (.+))?$/gm,"$1$3$4$6").replace(/([\*]+)(\S)(.*?\S)??\1/g,"$2$3").replace(/(^|\W)([_]+)(\S)(.*?\S)??\2($|\W)/g,"$1$3$4$5").replace(/(`{3,})(.*?)\1/gm,"$2").replace(/`(.+?)`/g,"$1").replace(/~(.*?)~/g,"$1")}catch(i){if(e.throwError)throw i;return console.error("remove-markdown encountered error: %s",i),o}return t}});var j;(function(o){o.AUTO="auto",o.LF=` `,o.CRLF=`\r `,o.CR="\r"})(j||(j={}));var ue;(function(o){o.STAR="*",o.DASH="-",o.AUTO="auto"})(ue||(ue={}));var A=class{constructor(){this.body="",this.description="",this.parsed={_:[]}}get cleanedBody(){if(this._cleanedBody)return this._cleanedBody;let e="";return this.description&&(e+=`${this.description} `),e+=Object.entries(this.parsed).filter(([t])=>t!=="_").map(([t,n])=>`### ${t} `+n.map(s=>`* ${s}`).join(` `)).join(` `),e}set cleanedBody(e){this._cleanedBody=e}toJSON(){return Object.assign(Object.assign({},this),{cleanedBody:this.cleanedBody,_cleanedBody:void 0})}},W=class{constructor(e,t){this.text=e,this.version=t}toString(){return this.text}toNumber(){var e;return parseFloat((e=this.version)!==null&&e!==void 0?e:"")}[Symbol.toPrimitive](e){return e==="number"?this.toNumber():this.toString()}},S=class o{constructor(){this.versions=[]}filter(e){let t=new o;return t.title=this.title,t.description=this.description,t.versions=this.versions.filter(e),t}consolidate(){let e={};return this.versions.forEach(t=>{Object.entries(t.parsed).filter(([n])=>n!=="_").forEach(n=>{let[s,i]=n;e[s]||(e[s]=[]),e[s].push(...i.map(r=>new W(r,t.version)))})}),e}};var fe=He(de());var M=class o{get totalParsedLines(){var e,t;return(t=(e=this.state)===null||e===void 0?void 0:e.lineCounter)!==null&&t!==void 0?t:0}constructor(e={}){this.options=Object.assign(Object.assign(Object.assign({},o.defaultOptions),e),{patterns:Object.assign(Object.assign({},o.defaultOptions.patterns),e.patterns)})}start(){var e,t;this.state={log:new S,current:null,lineCounter:0},this.options.text&&this.options.newline===j.AUTO&&(this.options.newline=(t=(e=RegExp(this.options.patterns.eol).exec(this.options.text))===null||e===void 0?void 0:e[0])!==null&&t!==void 0?t:` `)}end(){if(!this.state)throw new Error("Parser not started");return this.state.current&&this.pushCurrent(),this.state.log.description=this.clean(this.state.log.description),this.state.log.description===""&&delete this.state.log.description,this.lastResult=this.state.log,this.lastResult}parse(e){var t,n;return this.start(),e&&(this.options.text=e),this.options.text?(this.options.text.split(new RegExp(this.options.patterns.eol,"gm")).forEach(s=>this.handleLine(s)),this.end()):(n=(t=this.state)===null||t===void 0?void 0:t.log)!==null&&n!==void 0?n:new S}handleLine(e){var t,n,s,i;if(!this.state)throw new Error("Parser not started");if(this.state.lineCounter++,!this.options.patterns.linkLabel.exec(e)){if(!this.state.log.title&&this.options.patterns.title.exec(e)){this.state.log.title=e.substring(1).trim();return}if(this.options.patterns.versionTitle.exec(e)){!((t=this.state.current)===null||t===void 0)&&t.title&&this.pushCurrent(),this.parseVersionTitle(e);return}if(this.state.current){this.state.current.body+=e+this.options.newline;let r=!1;if(this.options.patterns.subhead.exec(e)){let a=e.replace("###","").trim();this.state.current.parsed[a]||(this.state.current.parsed[a]=[]),this.state.current._private||(this.state.current._private={}),this.state.current._private.activeSubhead=a}else if(this.options.patterns.listItem.exec(e)){r=!0;let a=this.options.removeMarkdown?(0,fe.default)(e):e.replace(/^\s*[\s*-]\s*/,"");this.state.current.parsed._.push(a),!((n=this.state.current._private)===null||n===void 0)&&n.activeSubhead&&this.state.current.parsed[this.state.current._private.activeSubhead].push(a)}else if(!((s=this.state.current._private)===null||s===void 0)&&s.activeSubhead&&e.trim()!==""&&this.state.current._private.isListItem){r=!0;let a=this.state.current.parsed[this.state.current._private.activeSubhead];a[a.length-1]+=this.options.newline+e.trim(),this.state.current.parsed._[this.state.current.parsed._.length-1]+=this.options.newline+e.trim()}else e.trim()!==""&&(this.state.current.description=this.state.current.description?this.state.current.description+this.options.newline+e:e);this.state.current._private&&(this.state.current._private.isListItem=r)}else this.state.log.description=((i=this.state.log.description)!==null&&i!==void 0?i:"")+e+this.options.newline}}parseVersionTitle(e){if(!this.state)throw new Error("Parser not started");this.state.current=new A,this.state.current.line=this.state.lineCounter;let t=this.options.patterns.semver.exec(e);t&&(this.state.current.version=t[1]),this.state.current.title=e.substring(2).trim();let n=this.options.patterns.date.exec(this.state.current.title);this.state.current.title&&n&&(this.state.current.date=n[1])}pushCurrent(){var e;if(!(!((e=this.state)===null||e===void 0)&&e.current))throw new Error("Parser not started");delete this.state.current._private,this.state.current.body=this.clean(this.state.current.body),this.state.log.versions.push(this.state.current)}clean(e){if(!e)return"";let t=this.options.patterns.eol.source;return e=e.trim(),e=e.replace(new RegExp(`^(${t})*`),""),e=e.replace(new RegExp(`(${t})*$`),""),e=e.replace(new RegExp(t,"g"),this.options.newline),e}};M.defaultOptions={text:"",removeMarkdown:!0,newline:` `,patterns:{semver:/\[?v?([\w\d.-]+\.[\w\d.-]+[a-zA-Z0-9])\]?/,date:/.* \(?(\d\d?\d?\d?[-/.]\d\d?[-/.]\d\d?\d?\d?)\)?.*/,subhead:/^###/,listItem:/^\s{0,3}[*-]/,linkLabel:/^\[[^[\]]*\] *?:/,title:/^# ?[^#]/,versionTitle:/^## ?[^#]/,eol:/\r\n?|\n/}};function K(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var R=K();function ve(o){R=o}var B={exec:()=>null};function g(o,e=""){let t=typeof o=="string"?o:o.source,n={replace:(s,i)=>{let r=typeof i=="string"?i:i.source;return r=r.replace(b.caret,"$1"),t=t.replace(s,r),n},getRegex:()=>new RegExp(t,e)};return n}var b={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:o=>new RegExp(`^( {0,3}${o})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:o=>new RegExp(`^ {0,${Math.min(3,o-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:o=>new RegExp(`^ {0,${Math.min(3,o-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:o=>new RegExp(`^ {0,${Math.min(3,o-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:o=>new RegExp(`^ {0,${Math.min(3,o-1)}}#`),htmlBeginRegex:o=>new RegExp(`^ {0,${Math.min(3,o-1)}}<(?:[a-z].*>|!--)`,"i")},Fe=/^(?:[ \t]*(?:\n|$))+/,Ze=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ue=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,G=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,We=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,X=/(?:[*+-]|\d{1,9}[.)])/,ye=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Se=g(ye).replace(/bull/g,X).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Qe=g(ye).replace(/bull/g,X).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),J=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ve=/^[^\n]+/,Y=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ke=g(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Y).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Xe=g(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,X).getRegex(),N="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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ee=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Je=g("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ee).replace("tag",N).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Te=g(J).replace("hr",G).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",N).getRegex(),Ye=g(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Te).getRegex(),te={blockquote:Ye,code:Ze,def:Ke,fences:Ue,heading:We,hr:G,html:Je,lheading:Se,list:Xe,newline:Fe,paragraph:Te,table:B,text:Ve},ke=g("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",G).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",N).getRegex(),et={...te,lheading:Qe,table:ke,paragraph:g(J).replace("hr",G).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ke).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",N).getRegex()},tt={...te,html:g(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ee).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:B,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:g(J).replace("hr",G).replace("heading",` *#{1,6} *[^ ]`).replace("lheading",Se).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},nt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,st=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Re=/^( {2,}|\\)\n(?!\s*$)/,rt=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,H=/[\p{P}\p{S}]/u,ne=/[\s\p{P}\p{S}]/u,$e=/[^\s\p{P}\p{S}]/u,it=g(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ne).getRegex(),Ae=/(?!~)[\p{P}\p{S}]/u,at=/(?!~)[\s\p{P}\p{S}]/u,ot=/(?:[^\s\p{P}\p{S}]|~)/u,lt=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Ce=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ct=g(Ce,"u").replace(/punct/g,H).getRegex(),ht=g(Ce,"u").replace(/punct/g,Ae).getRegex(),ze="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",pt=g(ze,"gu").replace(/notPunctSpace/g,$e).replace(/punctSpace/g,ne).replace(/punct/g,H).getRegex(),ut=g(ze,"gu").replace(/notPunctSpace/g,ot).replace(/punctSpace/g,at).replace(/punct/g,Ae).getRegex(),gt=g("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,$e).replace(/punctSpace/g,ne).replace(/punct/g,H).getRegex(),dt=g(/\\(punct)/,"gu").replace(/punct/g,H).getRegex(),ft=g(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),kt=g(ee).replace("(?:-->|$)","-->").getRegex(),mt=g("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",kt).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),q=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,bt=g(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Le=g(/^!?\[(label)\]\[(ref)\]/).replace("label",q).replace("ref",Y).getRegex(),_e=g(/^!?\[(ref)\](?:\[\])?/).replace("ref",Y).getRegex(),xt=g("reflink|nolink(?!\\()","g").replace("reflink",Le).replace("nolink",_e).getRegex(),se={_backpedal:B,anyPunctuation:dt,autolink:ft,blockSkip:lt,br:Re,code:st,del:B,emStrongLDelim:ct,emStrongRDelimAst:pt,emStrongRDelimUnd:gt,escape:nt,link:bt,nolink:_e,punctuation:it,reflink:Le,reflinkSearch:xt,tag:mt,text:rt,url:B},wt={...se,link:g(/^!?\[(label)\]\((.*?)\)/).replace("label",q).getRegex(),reflink:g(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",q).getRegex()},Q={...se,emStrongRDelimAst:ut,emStrongLDelim:ht,url:g(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},vt={...Q,br:g(Re).replace("{2,}","*").getRegex(),text:g(Q.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},D={normal:te,gfm:et,pedantic:tt},E={normal:se,gfm:Q,breaks:vt,pedantic:wt},yt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},me=o=>yt[o];function y(o,e){if(e){if(b.escapeTest.test(o))return o.replace(b.escapeReplace,me)}else if(b.escapeTestNoEncode.test(o))return o.replace(b.escapeReplaceNoEncode,me);return o}function be(o){try{o=encodeURI(o).replace(b.percentDecode,"%")}catch{return null}return o}function xe(o,e){let t=o.replace(b.findPipe,(i,r,a)=>{let l=!1,c=r;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),n=t.split(b.splitPipe),s=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(b.slashPipe,"|");return n}function P(o,e,t){let n=o.length;if(n===0)return"";let s=0;for(;s<n&&o.charAt(n-s-1)===e;)s++;return o.slice(0,n-s)}function St(o,e){if(o.indexOf(e[1])===-1)return-1;let t=0;for(let n=0;n<o.length;n++)if(o[n]==="\\")n++;else if(o[n]===e[0])t++;else if(o[n]===e[1]&&(t--,t<0))return n;return-1}function we(o,e,t,n,s){let i=e.href,r=e.title||null,a=o[1].replace(s.other.outputLinkReplace,"$1");if(o[0].charAt(0)!=="!"){n.state.inLink=!0;let l={type:"link",raw:t,href:i,title:r,text:a,tokens:n.inlineTokens(a)};return n.state.inLink=!1,l}return{type:"image",raw:t,href:i,title:r,text:a}}function Tt(o,e,t){let n=o.match(t.other.indentCodeCompensation);if(n===null)return e;let s=n[1];return e.split(` `).map(i=>{let r=i.match(t.other.beginningSpace);if(r===null)return i;let[a]=r;return a.length>=s.length?i.slice(s.length):i}).join(` `)}var z=class{options;rules;lexer;constructor(e){this.options=e||R}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:P(n,` `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=Tt(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=P(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:P(t[0],` `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=P(t[0],` `).split(` `),s="",i="",r=[];for(;n.length>0;){let a=!1,l=[],c;for(c=0;c<n.length;c++)if(this.rules.other.blockquoteStart.test(n[c]))l.push(n[c]),a=!0;else if(!a)l.push(n[c]);else break;n=n.slice(c);let h=l.join(` `),p=h.replace(this.rules.other.blockquoteSetextReplace,` $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s} ${h}`:h,i=i?`${i} ${p}`:p;let k=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,r,!0),this.lexer.state.top=k,n.length===0)break;let u=r.at(-1);if(u?.type==="code")break;if(u?.type==="blockquote"){let m=u,f=m.raw+` `+n.join(` `),x=this.blockquote(f);r[r.length-1]=x,s=s.substring(0,s.length-m.raw.length)+x.raw,i=i.substring(0,i.length-m.text.length)+x.text;break}else if(u?.type==="list"){let m=u,f=m.raw+` `+n.join(` `),x=this.list(f);r[r.length-1]=x,s=s.substring(0,s.length-u.raw.length)+x.raw,i=i.substring(0,i.length-m.raw.length)+x.raw,n=f.substring(r.at(-1).raw.length).split(` `);continue}}return{type:"blockquote",raw:s,tokens:r,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,i={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let r=this.rules.other.listItemRegex(n),a=!1;for(;e;){let c=!1,h="",p="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let k=t[2].split(` `,1)[0].replace(this.rules.other.listReplaceTabs,Z=>" ".repeat(3*Z.length)),u=e.split(` `,1)[0],m=!k.trim(),f=0;if(this.options.pedantic?(f=2,p=k.trimStart()):m?f=t[1].length+1:(f=t[2].search(this.rules.other.nonSpaceChar),f=f>4?1:f,p=k.slice(f),f+=t[1].length),m&&this.rules.other.blankLine.test(u)&&(h+=u+` `,e=e.substring(u.length+1),c=!0),!c){let Z=this.rules.other.nextBulletRegex(f),le=this.rules.other.hrRegex(f),ce=this.rules.other.fencesBeginRegex(f),he=this.rules.other.headingBeginRegex(f),Be=this.rules.other.htmlBeginRegex(f);for(;e;){let U=e.split(` `,1)[0],I;if(u=U,this.options.pedantic?(u=u.replace(this.rules.other.listReplaceNesting," "),I=u):I=u.replace(this.rules.other.tabCharGlobal," "),ce.test(u)||he.test(u)||Be.test(u)||Z.test(u)||le.test(u))break;if(I.search(this.rules.other.nonSpaceChar)>=f||!u.trim())p+=` `+I.slice(f);else{if(m||k.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ce.test(k)||he.test(k)||le.test(k))break;p+=` `+u}!m&&!u.trim()&&(m=!0),h+=U+` `,e=e.substring(U.length+1),k=I.slice(f)}}i.loose||(a?i.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(a=!0));let x=null,oe;this.options.gfm&&(x=this.rules.other.listIsTask.exec(p),x&&(oe=x[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:h,task:!!x,checked:oe,loose:!1,text:p,tokens:[]}),i.raw+=h}let l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let c=0;c<i.items.length;c++)if(this.lexer.state.top=!1,i.items[c].tokens=this.lexer.blockTokens(i.items[c].text,[]),!i.loose){let h=i.items[c].tokens.filter(k=>k.type==="space"),p=h.length>0&&h.some(k=>this.rules.other.anyLine.test(k.raw));i.loose=p}if(i.loose)for(let c=0;c<i.items.length;c++)i.items[c].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=xe(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(` `):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?r.align.push("right"):this.rules.other.tableAlignCenter.test(a)?r.align.push("center"):this.rules.other.tableAlignLeft.test(a)?r.align.push("left"):r.align.push(null);for(let a=0;a<n.length;a++)r.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:r.align[a]});for(let a of i)r.rows.push(xe(a,r.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:r.align[c]})));return r}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===` `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let r=P(n.slice(0,-1),"\\");if((n.length-r.length)%2===0)return}else{let r=St(t[2],"()");if(r>-1){let l=(t[0].indexOf("!")===0?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,l).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let r=this.rules.other.pedanticHrefTitle.exec(s);r&&(s=r[1],i=r[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),we(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return we(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[2]||"")||!n||this.rules.inline.punctuation.exec(n)){let r=[...s[0]].length-1,a,l,c=r,h=0,p=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+r);(s=p.exec(t))!=null;){if(a=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!a)continue;if(l=[...a].length,s[3]||s[4]){c+=l;continue}else if((s[5]||s[6])&&r%3&&!((r+l)%3)){h+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+h);let k=[...s[0]][0].length,u=e.slice(0,r+s.index+k+l);if(Math.min(r,l)%2){let f=u.slice(1,-1);return{type:"em",raw:u,text:f,tokens:this.lexer.inlineTokens(f)}}let m=u.slice(2,-2);return{type:"strong",raw:u,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},w=class o{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||R,this.options.tokenizer=this.options.tokenizer||new z,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:b,block:D.normal,inline:E.normal};this.options.pedantic?(t.block=D.pedantic,t.inline=E.pedantic):this.options.gfm&&(t.block=D.gfm,this.options.breaks?t.inline=E.breaks:t.inline=E.gfm),this.tokenizer.rules=t}static get rules(){return{block:D,inline:E}}static lex(e,t){return new o(t).lex(e)}static lexInline(e,t){return new o(t).inlineTokens(e)}lex(e){e=e.replace(b.carriageReturn,` `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(b.tabCharGlobal," ").replace(b.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(r=>(s=r.call({lexer:this},e,t))?(e=e.substring(s.raw.length),t.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let r=t.at(-1);s.raw.length===1&&r!==void 0?r.raw+=` `:t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=` `+s.raw,r.text+=` `+s.text,this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=` `+s.raw,r.text+=` `+s.raw,this.inlineQueue.at(-1).src=r.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),t.push(s);continue}let i=e;if(this.options.extensions?.startBlock){let r=1/0,a=e.slice(1),l;this.options.extensions.startBlock.forEach(c=>{l=c.call({lexer:this},a),typeof l=="number"&&l>=0&&(r=Math.min(r,l))}),r<1/0&&r>=0&&(i=e.substring(0,r+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){let r=t.at(-1);n&&r?.type==="paragraph"?(r.raw+=` `+s.raw,r.text+=` `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s),n=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="text"?(r.raw+=` `+s.raw,r.text+=` `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if(e){let r="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(r);break}else throw new Error(r)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,s=null;if(this.tokens.links){let a=Object.keys(this.tokens.links);if(a.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)a.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,s.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i=!1,r="";for(;e;){i||(r=""),i=!1;let a;if(this.options.extensions?.inline?.some(c=>(a=c.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let c=t.at(-1);a.type==="text"&&c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):t.push(a);continue}if(a=this.tokenizer.emStrong(e,n,r)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.del(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),t.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),t.push(a);continue}let l=e;if(this.options.extensions?.startInline){let c=1/0,h=e.slice(1),p;this.options.extensions.startInline.forEach(k=>{p=k.call({lexer:this},h),typeof p=="number"&&p>=0&&(c=Math.min(c,p))}),c<1/0&&c>=0&&(l=e.substring(0,c+1))}if(a=this.tokenizer.inlineText(l)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(r=a.raw.slice(-1)),i=!0;let c=t.at(-1);c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):t.push(a);continue}if(e){let c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return t}},L=class{options;parser;constructor(e){this.options=e||R}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(b.notSpaceStart)?.[0],i=e.replace(b.endingNewline,"")+` `;return s?'<pre><code class="language-'+y(s)+'">'+(n?i:y(i,!0))+`</code></pre> `:"<pre><code>"+(n?i:y(i,!0))+`</code></pre> `}blockquote({tokens:e}){return`<blockquote> ${this.parser.parse(e)}</blockquote> `}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}> `}hr(e){return`<hr> `}list(e){let t=e.ordered,n=e.start,s="";for(let a=0;a<e.items.length;a++){let l=e.items[a];s+=this.listitem(l)}let i=t?"ol":"ul",r=t&&n!==1?' start="'+n+'"':"";return"<"+i+r+`> `+s+"</"+i+`> `}listitem(e){let t="";if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type==="paragraph"?(e.tokens[0].text=n+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=n+" "+y(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):t+=n+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li> `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p> `}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let s="";for(let i=0;i<e.rows.length;i++){let r=e.rows[i];n="";for(let a=0;a<r.length;a++)n+=this.tablecell(r[a]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table> <thead> `+t+`</thead> `+s+`</table> `}tablerow({text:e}){return`<tr> ${e}</tr> `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}> `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${y(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=be(e);if(i===null)return s;e=i;let r='<a href="'+e+'"';return t&&(r+=' title="'+y(t)+'"'),r+=">"+s+"</a>",r}image({href:e,title:t,text:n}){let s=be(e);if(s===null)return y(n);e=s;let i=`<img src="${e}" alt="${n}"`;return t&&(i+=` title="${y(t)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:y(e.text)}},O=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}},v=class o{options;renderer;textRenderer;constructor(e){this.options=e||R,this.options.renderer=this.options.renderer||new L,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new O}static parse(e,t){return new o(t).parse(e)}static parseInline(e,t){return new o(t).parseInline(e)}parse(e,t=!0){let n="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let a=i,l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(a.type)){n+=l||"";continue}}let r=i;switch(r.type){case"space":{n+=this.renderer.space(r);continue}case"hr":{n+=this.renderer.hr(r);continue}case"heading":{n+=this.renderer.heading(r);continue}case"code":{n+=this.renderer.code(r);continue}case"table":{n+=this.renderer.table(r);continue}case"blockquote":{n+=this.renderer.blockquote(r);continue}case"list":{n+=this.renderer.list(r);continue}case"html":{n+=this.renderer.html(r);continue}case"paragraph":{n+=this.renderer.paragraph(r);continue}case"text":{let a=r,l=this.renderer.text(a);for(;s+1<e.length&&e[s+1].type==="text";)a=e[++s],l+=` `+this.renderer.text(a);t?n+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l,escaped:!0}]}):n+=l;continue}default:{let a='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,t=this.renderer){let n="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=a||"";continue}}let r=i;switch(r.type){case"escape":{n+=t.text(r);break}case"html":{n+=t.html(r);break}case"link":{n+=t.link(r);break}case"image":{n+=t.image(r);break}case"strong":{n+=t.strong(r);break}case"em":{n+=t.em(r);break}case"codespan":{n+=t.codespan(r);break}case"br":{n+=t.br(r);break}case"del":{n+=t.del(r);break}case"text":{n+=t.text(r);break}default:{let a='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}},C=class{options;block;constructor(e){this.options=e||R}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?w.lex:w.lexInline}provideParser(){return this.block?v.parse:v.parseInline}},V=class{defaults=K();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=v;Renderer=L;TextRenderer=O;Lexer=w;Tokenizer=z;Hooks=C;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let i=s;for(let r of i.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of i.rows)for(let a of r)n=n.concat(this.walkTokens(a.tokens,t));break}case"list":{let i=s;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=s;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(r=>{let a=i[r].flat(1/0);n=n.concat(this.walkTokens(a,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let r=t.renderers[i.name];r?t.renderers[i.name]=function(...a){let l=i.renderer.apply(this,a);return l===!1&&(l=r.apply(this,a)),l}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let r=t[i.level];r?r.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),n.renderer){let i=this.defaults.renderer||new L(this.defaults);for(let r in n.renderer){if(!(r in i))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let a=r,l=n.renderer[a],c=i[a];i[a]=(...h)=>{let p=l.apply(i,h);return p===!1&&(p=c.apply(i,h)),p||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new z(this.defaults);for(let r in n.tokenizer){if(!(r in i))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let a=r,l=n.tokenizer[a],c=i[a];i[a]=(...h)=>{let p=l.apply(i,h);return p===!1&&(p=c.apply(i,h)),p}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new C;for(let r in n.hooks){if(!(r in i))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let a=r,l=n.hooks[a],c=i[a];C.passThroughHooks.has(r)?i[a]=h=>{if(this.defaults.async)return Promise.resolve(l.call(i,h)).then(k=>c.call(i,k));let p=l.call(i,h);return c.call(i,p)}:i[a]=(...h)=>{let p=l.apply(i,h);return p===!1&&(p=c.apply(i,h)),p}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,r=n.walkTokens;s.walkTokens=function(a){let l=[];return l.push(r.call(this,a)),i&&(l=l.concat(i.call(this,a))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return w.lex(e,t??this.defaults)}parser(e,t){return v.parse(e,t??this.defaults)}parseMarkdown(e){return(n,s)=>{let i={...s},r={...this.defaults,...i},a=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));r.hooks&&(r.hooks.options=r,r.hooks.block=e);let l=r.hooks?r.hooks.provideLexer():e?w.lex:w.lexInline,c=r.hooks?r.hooks.provideParser():e?v.parse:v.parseInline;if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(h=>l(h,r)).then(h=>r.hooks?r.hooks.processAllTokens(h):h).then(h=>r.walkTokens?Promise.all(this.walkTokens(h,r.walkTokens)).then(()=>h):h).then(h=>c(h,r)).then(h=>r.hooks?r.hooks.postprocess(h):h).catch(a);try{r.hooks&&(n=r.hooks.preprocess(n));let h=l(n,r);r.hooks&&(h=r.hooks.processAllTokens(h)),r.walkTokens&&this.walkTokens(h,r.walkTokens);let p=c(h,r);return r.hooks&&(p=r.hooks.postprocess(p)),p}catch(h){return a(h)}}}onError(e,t){return n=>{if(n.message+=` Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+y(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},T=new V;function d(o,e){return T.parse(o,e)}d.options=d.setOptions=function(o){return T.setOptions(o),d.defaults=T.defaults,ve(d.defaults),d};d.getDefaults=K;d.defaults=R;d.use=function(...o){return T.use(...o),d.defaults=T.defaults,ve(d.defaults),d};d.walkTokens=function(o,e){return T.walkTokens(o,e)};d.parseInline=T.parseInline;d.Parser=v;d.parser=v.parse;d.Renderer=L;d.TextRenderer=O;d.Lexer=w;d.lexer=w.lex;d.Tokenizer=z;d.Hooks=C;d.parse=d;var Bt=d.options,Ot=d.setOptions,Gt=d.use,jt=d.walkTokens,Mt=d.parseInline;var Dt=v.parse,Ie=w.lex;var Rt=/\[?v?([\w\d.-]+\.[\w\d.-]+[a-zA-Z0-9])\]?/,$t=[/(\d{4}[-\/.]\d{2}[-\/.]\d{2})/,/(\d{2}[-\/.]\d{2}[-\/.]\d{4})/],Ee={title:0,description:1,version:2,change:3},At=/\r\n|\r|\n/g,$=class o{get totalParsedLines(){return this._totalParsedLines}constructor(e={}){this._totalParsedLines=0,this.markedTokens=[],this.options=Object.assign(Object.assign({},o.defaultOptions),e)}parse(e){e=e??this.options.text;let t=new S,n=Ie(e),s=1,i=n.map(l=>{var c,h;let p=Object.assign(Object.assign({},l),{line:s});return s+=(h=(c=p.raw.match(At))===null||c===void 0?void 0:c.length)!==null&&h!==void 0?h:0,p});this.markedTokens=i,this._totalParsedLines=s;let r="title",a="";return i.forEach(l=>{if(Ct(l)&&r==="title"){t.title=_(l,this.options.removeMarkdown),r="description";return}if(!re(l)&&(r==="description"||r==="title")&&(t.description||(t.description=""),t.description+=l.raw),re(l)&&F(r,"title")){r="version",a="",t.versions.length>0&&(t.versions[t.versions.length-1].body=t.versions[t.versions.length-1].body.trim(),t.versions[t.versions.length-1].cleanedBody=t.versions[t.versions.length-1].cleanedBody.trim());let c=new A;if(c.line=l.line,"text"in l&&typeof l.text=="string"){let h=l.text.match(Rt),p=$t.reduce((k,u)=>k||l.text.match(u),null);h&&h.length>1&&(c.version=h[1]),p&&p.length>1&&(c.date=p[1]),c.title=l.text}t.versions.push(c)}!re(l)&&F(r,"version")&&(t.versions[t.versions.length-1].body+=l.raw,t.versions[t.versions.length-1].cleanedBody+=!ie(l)&&_(l,this.options.removeMarkdown)||ie(l)&&l.raw+` `||l.raw),ie(l)&&F(r,"version")&&(r="change",a=l.text,t.versions[t.versions.length-1].parsed[l.text]||(t.versions[t.versions.length-1].parsed[l.text]=[])),l.type==="list"&&F(r,"version")&&l.items.forEach(c=>{t.versions[t.versions.length-1].parsed._.push(_(c,this.options.removeMarkdown)),a&&t.versions[t.versions.length-1].parsed[a].push(_(c,this.options.removeMarkdown))})}),t.description&&(t.description=t.description.trim()),t}};$.defaultOptions={text:"",removeMarkdown:!0};function Ct(o){return o.type==="heading"&&o.depth===1}function re(o){return o.type==="heading"&&o.depth===2}function ie(o){return o.type==="heading"&&o.depth===3}function F(o,e){return Ee[o]>=Ee[e]}function _(o,e=!1){if(e){if("tokens"in o&&o.tokens)return o.tokens.map(t=>_(t,e)).join("");if("items"in o&&o.items)return o.items.map(t=>_(t,e)).join(` `)}return"text"in o?o.text:""}var ae=`<!-- This is an example of a CHANGELOG.md file that is used to test the package. This file is based on the Keep a Changelog project's CHANGELOG.md file. --> # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] ### Added - v1.1 Brazilian Portuguese translation. - v1.1 German Translation - v1.1 Spanish translation. - v1.1 Italian translation. - v1.1 Polish translation. - v1.1 Ukrainian translation. ### Changed - Use frontmatter title & description in each language version template - Replace broken OpenGraph image with an appropriately-sized Keep a Changelog image that will render properly (although in English for all languages) - Fix OpenGraph title & description for all languages so the title and description when links are shared are language-appropriate ### Removed - Trademark sign previously shown after the project description in version 0.3.0 ## [1.1.1] - 2023-03-05 ### Added - Arabic translation (#444). - v1.1 French translation. - v1.1 Dutch translation (#371). - v1.1 Russian translation (#410). - v1.1 Japanese translation (#363). - v1.1 Norwegian Bokm\xE5l translation (#383). - v1.1 "Inconsistent Changes" Turkish translation (#347). - Default to most recent versions available for each languages. - Display count of available translations (26 to date!). - Centralize all links into \\\`/data/links.json\\\