6)throw new Error(`${this.constructor.name} requires heading level 1 to 6`);this.level=e}toHTML(e){return this._simplePairedTagHTML(e,`h${this.level}`)}}class MDSubtextNode extends MDBlockNode{toHTML(e){return this.cssClasses.indexOf("subtext")<0&&this.cssClasses.push("subtext"),this._simplePairedTagHTML(e,"div")}}class MDHorizontalRuleNode extends MDBlockNode{toHTML(e){return`
`}}class MDBlockquoteNode extends MDBlockNode{toHTML(e){return this._simplePairedTagHTML(e,"blockquote")}}class MDUnorderedListNode extends MDBlockNode{constructor(e){super(e)}toHTML(e){return this._simplePairedTagHTML(e,"ul")}}class MDOrderedListNode extends MDBlockNode{startOrdinal;constructor(e,t=null){super(e),this.startOrdinal=t}toHTML(e){return null!==this.startOrdinal&&1!=this.startOrdinal&&(this.attributes.start=this.startOrdinal),this._simplePairedTagHTML(e,"ol")}}class MDListItemNode extends MDBlockNode{ordinal;constructor(e,t=null){super(e),this.ordinal=t}toHTML(e){return this._simplePairedTagHTML(e,"li")}}class MDCodeBlockNode extends MDBlockNode{text;language;constructor(e,t=null){super([]),this.text=e,this.language=t}toHTML(e){const t=null!==this.language?` class="language-${this.language}"`:"";return`${MDUtils.escapeHTML(this.text)}
\n`}}class MDTableNode extends MDBlockNode{get headerRow(){return this.#te}set headerRow(e){this.#te=e,this.#ne()}#te;get bodyRows(){return this.#se}set bodyRows(e){this.#se=e,this.#ne()}#se;columnAlignments=[];constructor(e,t){super([e,...t]),this.#te=e,this.#se=t}#ne(){this.children=[this.#te,...this.#se]}#re(){this.children.forEach((e=>this.#ie(e)))}#ie(e){for(const[t,n]of e.children.entries()){const e=t\n`,t+="\n",t+=this.headerRow.toHTML(e)+"\n",t+="\n",t+="\n",t+=MDNode.toHTML(this.bodyRows,e)+"\n",t+="\n",t+="\n"}}class MDTableRowNode extends MDBlockNode{toHTML(e){return this._simplePairedTagHTML(e,"tr")}}class MDTableCellNode extends MDBlockNode{toHTML(e){return this._simplePairedTagHTML(e,"td")}}class MDTableHeaderCellNode extends MDBlockNode{toHTML(e){return this._simplePairedTagHTML(e,"th")}}class MDDefinitionListNode extends MDBlockNode{toHTML(e){return this._simplePairedTagHTML(e,"dl")}}class MDDefinitionListTermNode extends MDBlockNode{toHTML(e){return this._simplePairedTagHTML(e,"dt")}}class MDDefinitionListDefinitionNode extends MDBlockNode{toHTML(e){return this._simplePairedTagHTML(e,"dd")}}class MDFootnoteListNode extends MDBlockNode{#ae(e,t){const n=e.root.footnoteIds;return n?n[t]??null:null}toHTML(e){const t=e.footnotes;var n=Object.keys(t);if(0==Object.keys(t).length)return"";const s=e.root.footnoteInstances;var r="";r+='"}toPlaintext(e){const t=e.footnotes;var n=Object.keys(t);if(0==Object.keys(t).length)return"";var s="";for(const r of n){let n=t[r];n&&(s+=`${r}. ${n.toPlaintext(e)}\n`)}return s.trim()}}class MDInlineNode extends MDNode{}class MDTextNode extends MDInlineNode{text;constructor(e){super([]),this.text=e}toHTML(e){return MDUtils.escapeHTML(this.text)}toPlaintext(e){return this.text}}class MDObfuscatedTextNode extends MDTextNode{toHTML(e){return MDUtils.escapeObfuscated(this.text)}}class MDEmphasisNode extends MDInlineNode{toHTML(e){return this._simplePairedTagHTML(e,"em")}}class MDStrongNode extends MDInlineNode{toHTML(e){return this._simplePairedTagHTML(e,"strong")}}class MDStrikethroughNode extends MDInlineNode{toHTML(e){return this._simplePairedTagHTML(e,"s")}}class MDUnderlineNode extends MDInlineNode{toHTML(e){return this._simplePairedTagHTML(e,"u")}}class MDHighlightNode extends MDInlineNode{toHTML(e){return this._simplePairedTagHTML(e,"mark")}}class MDSuperscriptNode extends MDInlineNode{toHTML(e){return this._simplePairedTagHTML(e,"sup")}}class MDSubscriptNode extends MDInlineNode{toHTML(e){return this._simplePairedTagHTML(e,"sub")}}class MDCodeNode extends MDInlineNode{text;constructor(e){super([]),this.text=e}toHTML(e){return`${MDUtils.escapeHTML(this.text)}`}}class MDFootnoteNode extends MDInlineNode{symbol;displaySymbol=null;footnoteId=null;occurrenceId=null;constructor(e,t=null){super([]),this.symbol=e,t&&(this.attributes.title=t)}toHTML(e){return null!==this.differentiator?``:`\x3c!--FNREF:{${this.symbol}}--\x3e`}}class MDLinkNode extends MDInlineNode{href;constructor(e,t,n=null){super(t),this.href=e,null!==n&&(this.attributes.title=n)}toHTML(e){return`${this._childHTML(e)}`}}class MDReferencedLinkNode extends MDLinkNode{reference;constructor(e,t){super("",t),this.reference=e}toHTML(e){if(""===this.href){const t=e.urlForReference(this.reference);t&&(this.href=t);const n=e.urlTitleForReference(this.reference);n&&(this.attributes.title=n)}return super.toHTML(e)}}class MDImageNode extends MDInlineNode{src;alt;constructor(e,t){super([]),this.src=e,this.alt=t}toHTML(e){var t=`
`}}class MDReferencedImageNode extends MDImageNode{reference;constructor(e,t=""){super("",t,[]),this.reference=e}toHTML(e){return""===this.src&&(this.src=e.urlForReference(this.reference),this.attributes.title=e.urlTitleForReference(this.reference)),super.toHTML(e)}}class MDAbbreviationNode extends MDInlineNode{abbreviation;get definition(){return this.attributes.title??null}set definition(e){this.attributes.title=e}constructor(e,t){super([]),this.abbreviation=e,this.attributes.title=t}toHTML(e){return`${MDUtils.escapeHTML(this.abbreviation)}`}}class MDLineBreakNode extends MDInlineNode{toHTML(e){return"
"}toPlaintext(e){return"\n"}}class MDHTMLTagNode extends MDInlineNode{tag;constructor(e){super([]),this.tag=e}toHTML(e){return this.tag.toString()}}class Markdown{static standardReaders=[new MDUnderlinedHeadingReader,new MDHashHeadingReader,new MDBlockQuoteReader,new MDHorizontalRuleReader,new MDUnorderedListReader,new MDOrderedListReader,new MDFencedCodeBlockReader,new MDIndentedCodeBlockReader,new MDParagraphReader,new MDStrongReader,new MDEmphasisReader,new MDCodeSpanReader,new MDImageReader,new MDLinkReader,new MDHTMLTagReader];static allReaders=[...this.standardReaders,new MDSubtextReader,new MDTableReader,new MDDefinitionListReader,new MDFootnoteReader,new MDAbbreviationReader,new MDUnderlineReader,new MDSubscriptReader,new MDStrikethroughReader,new MDHighlightReader,new MDSuperscriptReader,new MDReferencedImageReader,new MDReferencedLinkReader,new MDModifierReader];static standardParser=new Markdown(this.standardReaders);static completeParser=new Markdown(this.allReaders);tagFilter=new MDHTMLFilter;#le;#ce;#de;#ue;constructor(e=Markdown.allReaders){this.#le=e,this.#ce=MDReader.sortReaderForBlocks(e),this.#de=MDReader.sortReadersForTokenizing(e),this.#ue=MDReader.sortReadersForSubstitution(e)}toHTML(e,t=""){const n=e.split(/(?:\n|\r|\r\n)/);try{return this.#he(n,t)}catch(e){throw this.#Me(n,t),e}}#he(e,t){const n=new MDState(e);n.readersByBlockPriority=this.#ce,n.readersByTokenPriority=this.#de,n.readersBySubstitutePriority=this.#ue,n.tagFilter=this.tagFilter,n.elementIdPrefix=t;for(const e of this.#le)e.preProcess(n);const s=n.readBlocks();for(const e of this.#le)e.postProcess(n,s);return MDNode.toHTML(s,n)}#Me(e,t){for(var n=0,s=e.length,r=0;rn;r--)try{this.#he(e.slice(n,r),t);break}catch(e){s=r}const i=e.slice(n,s).join("\n");console.error(`This portion of markdown caused an unexpected exception: ${i}`)}}