@gui-chat-plugin/markdown 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +2 -2
- package/dist/core.js +21 -22
- package/dist/style.css +1 -1
- package/dist/vue/Preview.vue.d.ts +2 -1
- package/dist/vue/Preview.vue.d.ts.map +1 -1
- package/dist/vue/View.vue.d.ts +2 -1
- package/dist/vue/View.vue.d.ts.map +1 -1
- package/dist/vue.cjs +58 -55
- package/dist/vue.js +874 -1353
- package/package.json +14 -7
package/dist/vue.cjs
CHANGED
|
@@ -1,59 +1,62 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
]`).replace("lheading",
|
|
3
|
-
`).map(i=>{
|
|
4
|
-
`)}var
|
|
5
|
-
`)}}}fences(
|
|
6
|
-
`)}}blockquote(
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("./core.cjs"),p=require("vue");function j(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var S=j();function ae(s){S=s}var E={exec:()=>null};function g(s,e=""){let r=typeof s=="string"?s:s.source,n={replace:(t,i)=>{let l=typeof i=="string"?i:i.source;return l=l.replace(b.caret,"$1"),r=r.replace(t,l),n},getRegex:()=>new RegExp(r,e)};return n}var $e=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),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]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ 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:s=>new RegExp(`^( {0,3}${s})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}#`),htmlBeginRegex:s=>new RegExp(`^ {0,${Math.min(3,s-1)}}<(?:[a-z].*>|!--)`,"i")},Se=/^(?:[ \t]*(?:\n|$))+/,Te=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,_e=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,P=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ze=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Q=/(?:[*+-]|\d{1,9}[.)])/,oe=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ce=g(oe).replace(/bull/g,Q).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(),Ae=g(oe).replace(/bull/g,Q).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(),H=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ve=/^[^\n]+/,G=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ee=g(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",G).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Pe=g(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Q).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",U=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ie=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",U).replace("tag",N).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),he=g(H).replace("hr",P).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(),Ce=g(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",he).getRegex(),F={blockquote:Ce,code:Te,def:Ee,fences:_e,heading:ze,hr:P,html:Ie,lheading:ce,list:Pe,newline:Se,paragraph:he,table:E,text:ve},te=g("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",P).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(),Le={...F,lheading:Ae,table:te,paragraph:g(H).replace("hr",P).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",te).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()},Be={...F,html:g(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",U).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:E,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:g(H).replace("hr",P).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",ce).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ne=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,qe=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,pe=/^( {2,}|\\)\n(?!\s*$)/,Me=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,q=/[\p{P}\p{S}]/u,X=/[\s\p{P}\p{S}]/u,ue=/[^\s\p{P}\p{S}]/u,Oe=g(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,X).getRegex(),de=/(?!~)[\p{P}\p{S}]/u,De=/(?!~)[\s\p{P}\p{S}]/u,Ze=/(?:[^\s\p{P}\p{S}]|~)/u,Ve=g(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",$e?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ge=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,je=g(ge,"u").replace(/punct/g,q).getRegex(),Qe=g(ge,"u").replace(/punct/g,de).getRegex(),ke="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",He=g(ke,"gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,X).replace(/punct/g,q).getRegex(),Ge=g(ke,"gu").replace(/notPunctSpace/g,Ze).replace(/punctSpace/g,De).replace(/punct/g,de).getRegex(),Ue=g("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,X).replace(/punct/g,q).getRegex(),Fe=g(/\\(punct)/,"gu").replace(/punct/g,q).getRegex(),Xe=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(),We=g(U).replace("(?:-->|$)","-->").getRegex(),Ye=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",We).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),C=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Je=g(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",C).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),fe=g(/^!?\[(label)\]\[(ref)\]/).replace("label",C).replace("ref",G).getRegex(),xe=g(/^!?\[(ref)\](?:\[\])?/).replace("ref",G).getRegex(),Ke=g("reflink|nolink(?!\\()","g").replace("reflink",fe).replace("nolink",xe).getRegex(),re=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,W={_backpedal:E,anyPunctuation:Fe,autolink:Xe,blockSkip:Ve,br:pe,code:qe,del:E,emStrongLDelim:je,emStrongRDelimAst:He,emStrongRDelimUnd:Ue,escape:Ne,link:Je,nolink:xe,punctuation:Oe,reflink:fe,reflinkSearch:Ke,tag:Ye,text:Me,url:E},et={...W,link:g(/^!?\[(label)\]\((.*?)\)/).replace("label",C).getRegex(),reflink:g(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",C).getRegex()},O={...W,emStrongRDelimAst:Ge,emStrongLDelim:Qe,url:g(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",re).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\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:g(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",re).getRegex()},tt={...O,br:g(pe).replace("{2,}","*").getRegex(),text:g(O.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},I={normal:F,gfm:Le,pedantic:Be},z={normal:W,gfm:O,breaks:tt,pedantic:et},rt={"&":"&","<":"<",">":">",'"':""","'":"'"},se=s=>rt[s];function R(s,e){if(e){if(b.escapeTest.test(s))return s.replace(b.escapeReplace,se)}else if(b.escapeTestNoEncode.test(s))return s.replace(b.escapeReplaceNoEncode,se);return s}function ne(s){try{s=encodeURI(s).replace(b.percentDecode,"%")}catch{return null}return s}function le(s,e){let r=s.replace(b.findPipe,(i,l,c)=>{let a=!1,h=l;for(;--h>=0&&c[h]==="\\";)a=!a;return a?"|":" |"}),n=r.split(b.splitPipe),t=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(;t<n.length;t++)n[t]=n[t].trim().replace(b.slashPipe,"|");return n}function A(s,e,r){let n=s.length;if(n===0)return"";let t=0;for(;t<n&&s.charAt(n-t-1)===e;)t++;return s.slice(0,n-t)}function st(s,e){if(s.indexOf(e[1])===-1)return-1;let r=0;for(let n=0;n<s.length;n++)if(s[n]==="\\")n++;else if(s[n]===e[0])r++;else if(s[n]===e[1]&&(r--,r<0))return n;return r>0?-2:-1}function ie(s,e,r,n,t){let i=e.href,l=e.title||null,c=s[1].replace(t.other.outputLinkReplace,"$1");n.state.inLink=!0;let a={type:s[0].charAt(0)==="!"?"image":"link",raw:r,href:i,title:l,text:c,tokens:n.inlineTokens(c)};return n.state.inLink=!1,a}function nt(s,e,r){let n=s.match(r.other.indentCodeCompensation);if(n===null)return e;let t=n[1];return e.split(`
|
|
3
|
+
`).map(i=>{let l=i.match(r.other.beginningSpace);if(l===null)return i;let[c]=l;return c.length>=t.length?i.slice(t.length):i}).join(`
|
|
4
|
+
`)}var L=class{options;rules;lexer;constructor(s){this.options=s||S}space(s){let e=this.rules.block.newline.exec(s);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(s){let e=this.rules.block.code.exec(s);if(e){let r=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?r:A(r,`
|
|
5
|
+
`)}}}fences(s){let e=this.rules.block.fences.exec(s);if(e){let r=e[0],n=nt(r,e[3]||"",this.rules);return{type:"code",raw:r,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:n}}}heading(s){let e=this.rules.block.heading.exec(s);if(e){let r=e[2].trim();if(this.rules.other.endingHash.test(r)){let n=A(r,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(r=n.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(s){let e=this.rules.block.hr.exec(s);if(e)return{type:"hr",raw:A(e[0],`
|
|
6
|
+
`)}}blockquote(s){let e=this.rules.block.blockquote.exec(s);if(e){let r=A(e[0],`
|
|
7
7
|
`).split(`
|
|
8
|
-
`),
|
|
9
|
-
`),o=
|
|
10
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");
|
|
11
|
-
${
|
|
12
|
-
${o}`:o;
|
|
13
|
-
`+
|
|
14
|
-
`),
|
|
15
|
-
`+
|
|
16
|
-
`),
|
|
17
|
-
`);continue}}return{type:"blockquote",raw:
|
|
18
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,
|
|
19
|
-
`,1)[0],
|
|
20
|
-
`,
|
|
21
|
-
`,1)[0];
|
|
22
|
-
`+
|
|
23
|
-
`+
|
|
24
|
-
`,
|
|
25
|
-
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(
|
|
26
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:
|
|
27
|
-
`),this.blockTokens(e,this.tokens);for(let
|
|
28
|
-
`:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
`+l.raw,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
`+
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
`
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
`}
|
|
44
|
-
|
|
45
|
-
`}
|
|
46
|
-
`}
|
|
47
|
-
`}
|
|
8
|
+
`),n="",t="",i=[];for(;r.length>0;){let l=!1,c=[],a;for(a=0;a<r.length;a++)if(this.rules.other.blockquoteStart.test(r[a]))c.push(r[a]),l=!0;else if(!l)c.push(r[a]);else break;r=r.slice(a);let h=c.join(`
|
|
9
|
+
`),o=h.replace(this.rules.other.blockquoteSetextReplace,`
|
|
10
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
|
|
11
|
+
${h}`:h,t=t?`${t}
|
|
12
|
+
${o}`:o;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(o,i,!0),this.lexer.state.top=u,r.length===0)break;let d=i.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let x=d,f=x.raw+`
|
|
13
|
+
`+r.join(`
|
|
14
|
+
`),m=this.blockquote(f);i[i.length-1]=m,n=n.substring(0,n.length-x.raw.length)+m.raw,t=t.substring(0,t.length-x.text.length)+m.text;break}else if(d?.type==="list"){let x=d,f=x.raw+`
|
|
15
|
+
`+r.join(`
|
|
16
|
+
`),m=this.list(f);i[i.length-1]=m,n=n.substring(0,n.length-d.raw.length)+m.raw,t=t.substring(0,t.length-x.raw.length)+m.raw,r=f.substring(i.at(-1).raw.length).split(`
|
|
17
|
+
`);continue}}return{type:"blockquote",raw:n,tokens:i,text:t}}}list(s){let e=this.rules.block.list.exec(s);if(e){let r=e[1].trim(),n=r.length>1,t={type:"list",raw:"",ordered:n,start:n?+r.slice(0,-1):"",loose:!1,items:[]};r=n?`\\d{1,9}\\${r.slice(-1)}`:`\\${r}`,this.options.pedantic&&(r=n?r:"[*+-]");let i=this.rules.other.listItemRegex(r),l=!1;for(;s;){let a=!1,h="",o="";if(!(e=i.exec(s))||this.rules.block.hr.test(s))break;h=e[0],s=s.substring(h.length);let u=e[2].split(`
|
|
18
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,m=>" ".repeat(3*m.length)),d=s.split(`
|
|
19
|
+
`,1)[0],x=!u.trim(),f=0;if(this.options.pedantic?(f=2,o=u.trimStart()):x?f=e[1].length+1:(f=e[2].search(this.rules.other.nonSpaceChar),f=f>4?1:f,o=u.slice(f),f+=e[1].length),x&&this.rules.other.blankLine.test(d)&&(h+=d+`
|
|
20
|
+
`,s=s.substring(d.length+1),a=!0),!a){let m=this.rules.other.nextBulletRegex(f),J=this.rules.other.hrRegex(f),K=this.rules.other.fencesBeginRegex(f),ee=this.rules.other.headingBeginRegex(f),Re=this.rules.other.htmlBeginRegex(f);for(;s;){let M=s.split(`
|
|
21
|
+
`,1)[0],_;if(d=M,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),_=d):_=d.replace(this.rules.other.tabCharGlobal," "),K.test(d)||ee.test(d)||Re.test(d)||m.test(d)||J.test(d))break;if(_.search(this.rules.other.nonSpaceChar)>=f||!d.trim())o+=`
|
|
22
|
+
`+_.slice(f);else{if(x||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||K.test(u)||ee.test(u)||J.test(u))break;o+=`
|
|
23
|
+
`+d}!x&&!d.trim()&&(x=!0),h+=M+`
|
|
24
|
+
`,s=s.substring(M.length+1),u=_.slice(f)}}t.loose||(l?t.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(l=!0)),t.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(o),loose:!1,text:o,tokens:[]}),t.raw+=h}let c=t.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;t.raw=t.raw.trimEnd();for(let a of t.items){if(this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]),a.task){if(a.text=a.text.replace(this.rules.other.listReplaceTask,""),a.tokens[0]?.type==="text"||a.tokens[0]?.type==="paragraph"){a.tokens[0].raw=a.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),a.tokens[0].text=a.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let o=this.lexer.inlineQueue.length-1;o>=0;o--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[o].src)){this.lexer.inlineQueue[o].src=this.lexer.inlineQueue[o].src.replace(this.rules.other.listReplaceTask,"");break}}let h=this.rules.other.listTaskCheckbox.exec(a.raw);if(h){let o={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};a.checked=o.checked,t.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=o.raw+a.tokens[0].raw,a.tokens[0].text=o.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(o)):a.tokens.unshift({type:"paragraph",raw:o.raw,text:o.raw,tokens:[o]}):a.tokens.unshift(o)}}if(!t.loose){let h=a.tokens.filter(u=>u.type==="space"),o=h.length>0&&h.some(u=>this.rules.other.anyLine.test(u.raw));t.loose=o}}if(t.loose)for(let a of t.items){a.loose=!0;for(let h of a.tokens)h.type==="text"&&(h.type="paragraph")}return t}}html(s){let e=this.rules.block.html.exec(s);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(s){let e=this.rules.block.def.exec(s);if(e){let r=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",t=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:r,raw:e[0],href:n,title:t}}}table(s){let e=this.rules.block.table.exec(s);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let r=le(e[1]),n=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),t=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
25
|
+
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(r.length===n.length){for(let l of n)this.rules.other.tableAlignRight.test(l)?i.align.push("right"):this.rules.other.tableAlignCenter.test(l)?i.align.push("center"):this.rules.other.tableAlignLeft.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<r.length;l++)i.header.push({text:r[l],tokens:this.lexer.inline(r[l]),header:!0,align:i.align[l]});for(let l of t)i.rows.push(le(l,i.header.length).map((c,a)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:i.align[a]})));return i}}lheading(s){let e=this.rules.block.lheading.exec(s);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(s){let e=this.rules.block.paragraph.exec(s);if(e){let r=e[1].charAt(e[1].length-1)===`
|
|
26
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:r,tokens:this.lexer.inline(r)}}}text(s){let e=this.rules.block.text.exec(s);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(s){let e=this.rules.inline.escape.exec(s);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(s){let e=this.rules.inline.tag.exec(s);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(s){let e=this.rules.inline.link.exec(s);if(e){let r=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let i=A(r.slice(0,-1),"\\");if((r.length-i.length)%2===0)return}else{let i=st(e[2],"()");if(i===-2)return;if(i>-1){let l=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let n=e[2],t="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(n);i&&(n=i[1],t=i[3])}else t=e[3]?e[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?n=n.slice(1):n=n.slice(1,-1)),ie(e,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:t&&t.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(s,e){let r;if((r=this.rules.inline.reflink.exec(s))||(r=this.rules.inline.nolink.exec(s))){let n=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),t=e[n.toLowerCase()];if(!t){let i=r[0].charAt(0);return{type:"text",raw:i,text:i}}return ie(r,t,r[0],this.lexer,this.rules)}}emStrong(s,e,r=""){let n=this.rules.inline.emStrongLDelim.exec(s);if(!(!n||n[3]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[2])||!r||this.rules.inline.punctuation.exec(r))){let t=[...n[0]].length-1,i,l,c=t,a=0,h=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*s.length+t);(n=h.exec(e))!=null;){if(i=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!i)continue;if(l=[...i].length,n[3]||n[4]){c+=l;continue}else if((n[5]||n[6])&&t%3&&!((t+l)%3)){a+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+a);let o=[...n[0]][0].length,u=s.slice(0,t+n.index+o+l);if(Math.min(t,l)%2){let x=u.slice(1,-1);return{type:"em",raw:u,text:x,tokens:this.lexer.inlineTokens(x)}}let d=u.slice(2,-2);return{type:"strong",raw:u,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(s){let e=this.rules.inline.code.exec(s);if(e){let r=e[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(r),t=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return n&&t&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:e[0],text:r}}}br(s){let e=this.rules.inline.br.exec(s);if(e)return{type:"br",raw:e[0]}}del(s){let e=this.rules.inline.del.exec(s);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(s){let e=this.rules.inline.autolink.exec(s);if(e){let r,n;return e[2]==="@"?(r=e[1],n="mailto:"+r):(r=e[1],n=r),{type:"link",raw:e[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}}}url(s){let e;if(e=this.rules.inline.url.exec(s)){let r,n;if(e[2]==="@")r=e[0],n="mailto:"+r;else{let t;do t=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(t!==e[0]);r=e[0],e[1]==="www."?n="http://"+e[0]:n=e[0]}return{type:"link",raw:e[0],text:r,href:n,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(s){let e=this.rules.inline.text.exec(s);if(e){let r=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:r}}}},w=class D{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||S,this.options.tokenizer=this.options.tokenizer||new L,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 r={other:b,block:I.normal,inline:z.normal};this.options.pedantic?(r.block=I.pedantic,r.inline=z.pedantic):this.options.gfm&&(r.block=I.gfm,this.options.breaks?r.inline=z.breaks:r.inline=z.gfm),this.tokenizer.rules=r}static get rules(){return{block:I,inline:z}}static lex(e,r){return new D(r).lex(e)}static lexInline(e,r){return new D(r).inlineTokens(e)}lex(e){e=e.replace(b.carriageReturn,`
|
|
27
|
+
`),this.blockTokens(e,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let n=this.inlineQueue[r];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,r=[],n=!1){for(this.options.pedantic&&(e=e.replace(b.tabCharGlobal," ").replace(b.spaceLine,""));e;){let t;if(this.options.extensions?.block?.some(l=>(t=l.call({lexer:this},e,r))?(e=e.substring(t.raw.length),r.push(t),!0):!1))continue;if(t=this.tokenizer.space(e)){e=e.substring(t.raw.length);let l=r.at(-1);t.raw.length===1&&l!==void 0?l.raw+=`
|
|
28
|
+
`:r.push(t);continue}if(t=this.tokenizer.code(e)){e=e.substring(t.raw.length);let l=r.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
|
|
29
|
+
`)?"":`
|
|
30
|
+
`)+t.raw,l.text+=`
|
|
31
|
+
`+t.text,this.inlineQueue.at(-1).src=l.text):r.push(t);continue}if(t=this.tokenizer.fences(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.heading(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.hr(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.blockquote(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.list(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.html(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.def(e)){e=e.substring(t.raw.length);let l=r.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
|
|
32
|
+
`)?"":`
|
|
33
|
+
`)+t.raw,l.text+=`
|
|
34
|
+
`+t.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[t.tag]||(this.tokens.links[t.tag]={href:t.href,title:t.title},r.push(t));continue}if(t=this.tokenizer.table(e)){e=e.substring(t.raw.length),r.push(t);continue}if(t=this.tokenizer.lheading(e)){e=e.substring(t.raw.length),r.push(t);continue}let i=e;if(this.options.extensions?.startBlock){let l=1/0,c=e.slice(1),a;this.options.extensions.startBlock.forEach(h=>{a=h.call({lexer:this},c),typeof a=="number"&&a>=0&&(l=Math.min(l,a))}),l<1/0&&l>=0&&(i=e.substring(0,l+1))}if(this.state.top&&(t=this.tokenizer.paragraph(i))){let l=r.at(-1);n&&l?.type==="paragraph"?(l.raw+=(l.raw.endsWith(`
|
|
35
|
+
`)?"":`
|
|
36
|
+
`)+t.raw,l.text+=`
|
|
37
|
+
`+t.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):r.push(t),n=i.length!==e.length,e=e.substring(t.raw.length);continue}if(t=this.tokenizer.text(e)){e=e.substring(t.raw.length);let l=r.at(-1);l?.type==="text"?(l.raw+=(l.raw.endsWith(`
|
|
38
|
+
`)?"":`
|
|
39
|
+
`)+t.raw,l.text+=`
|
|
40
|
+
`+t.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):r.push(t);continue}if(e){let l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,r}inline(e,r=[]){return this.inlineQueue.push({src:e,tokens:r}),r}inlineTokens(e,r=[]){let n=e,t=null;if(this.tokens.links){let a=Object.keys(this.tokens.links);if(a.length>0)for(;(t=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)a.includes(t[0].slice(t[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,t.index)+"["+"a".repeat(t[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(t=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,t.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(t=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=t[2]?t[2].length:0,n=n.slice(0,t.index+i)+"["+"a".repeat(t[0].length-i-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let l=!1,c="";for(;e;){l||(c=""),l=!1;let a;if(this.options.extensions?.inline?.some(o=>(a=o.call({lexer:this},e,r))?(e=e.substring(a.raw.length),r.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let o=r.at(-1);a.type==="text"&&o?.type==="text"?(o.raw+=a.raw,o.text+=a.text):r.push(a);continue}if(a=this.tokenizer.emStrong(e,n,c)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.del(e)){e=e.substring(a.raw.length),r.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),r.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),r.push(a);continue}let h=e;if(this.options.extensions?.startInline){let o=1/0,u=e.slice(1),d;this.options.extensions.startInline.forEach(x=>{d=x.call({lexer:this},u),typeof d=="number"&&d>=0&&(o=Math.min(o,d))}),o<1/0&&o>=0&&(h=e.substring(0,o+1))}if(a=this.tokenizer.inlineText(h)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(c=a.raw.slice(-1)),l=!0;let o=r.at(-1);o?.type==="text"?(o.raw+=a.raw,o.text+=a.text):r.push(a);continue}if(e){let o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return r}},B=class{options;parser;constructor(s){this.options=s||S}space(s){return""}code({text:s,lang:e,escaped:r}){let n=(e||"").match(b.notSpaceStart)?.[0],t=s.replace(b.endingNewline,"")+`
|
|
41
|
+
`;return n?'<pre><code class="language-'+R(n)+'">'+(r?t:R(t,!0))+`</code></pre>
|
|
42
|
+
`:"<pre><code>"+(r?t:R(t,!0))+`</code></pre>
|
|
43
|
+
`}blockquote({tokens:s}){return`<blockquote>
|
|
44
|
+
${this.parser.parse(s)}</blockquote>
|
|
45
|
+
`}html({text:s}){return s}def(s){return""}heading({tokens:s,depth:e}){return`<h${e}>${this.parser.parseInline(s)}</h${e}>
|
|
46
|
+
`}hr(s){return`<hr>
|
|
47
|
+
`}list(s){let e=s.ordered,r=s.start,n="";for(let l=0;l<s.items.length;l++){let c=s.items[l];n+=this.listitem(c)}let t=e?"ol":"ul",i=e&&r!==1?' start="'+r+'"':"";return"<"+t+i+`>
|
|
48
|
+
`+n+"</"+t+`>
|
|
49
|
+
`}listitem(s){return`<li>${this.parser.parse(s.tokens)}</li>
|
|
50
|
+
`}checkbox({checked:s}){return"<input "+(s?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:s}){return`<p>${this.parser.parseInline(s)}</p>
|
|
51
|
+
`}table(s){let e="",r="";for(let t=0;t<s.header.length;t++)r+=this.tablecell(s.header[t]);e+=this.tablerow({text:r});let n="";for(let t=0;t<s.rows.length;t++){let i=s.rows[t];r="";for(let l=0;l<i.length;l++)r+=this.tablecell(i[l]);n+=this.tablerow({text:r})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
|
|
48
52
|
<thead>
|
|
49
53
|
`+e+`</thead>
|
|
50
|
-
`+
|
|
51
|
-
`}tablerow({text:
|
|
52
|
-
${
|
|
53
|
-
`}tablecell(
|
|
54
|
-
`}strong({tokens:
|
|
55
|
-
|
|
56
|
-
Please report this to https://github.com/markedjs/marked.`,n){const r="<p>An error occurred:</p><pre>"+y(t.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(t);throw t}}},S=new ct;function k(n,e){return S.parse(n,e)}k.options=k.setOptions=function(n){return S.setOptions(n),k.defaults=S.defaults,pe(k.defaults),k};k.getDefaults=Q;k.defaults=$;k.use=function(...n){return S.use(...n),k.defaults=S.defaults,pe(k.defaults),k};k.walkTokens=function(n,e){return S.walkTokens(n,e)};k.parseInline=S.parseInline;k.Parser=R;k.parser=R.parse;k.Renderer=N;k.TextRenderer=ee;k.Lexer=v;k.lexer=v.lex;k.Tokenizer=B;k.Hooks=P;k.parse=k;k.options;k.setOptions;k.use;k.walkTokens;k.parseInline;R.parse;v.lex;const pt={class:"markdown-container"},ht={key:0,class:"min-h-full p-8 flex items-center justify-center"},ut={class:"markdown-content-wrapper"},dt={class:"p-4"},gt={class:"header-row"},ft={class:"document-title"},kt=["innerHTML"],mt={class:"markdown-source"},bt=["disabled"],xt=d.defineComponent({__name:"View",props:{selectedResult:{}},emits:["updateResult"],setup(n,{emit:e}){var a;const t=n,r=e,s=d.ref(((a=t.selectedResult.data)==null?void 0:a.markdown)||""),i=d.computed(()=>{var o;return s.value!==((o=t.selectedResult.data)==null?void 0:o.markdown)}),c=d.computed(()=>{var o;return(o=t.selectedResult.data)!=null&&o.markdown?k(t.selectedResult.data.markdown):(console.error("No markdown data in result:",t.selectedResult),"")});d.watch(()=>{var o,u;return(u=(o=t.selectedResult)==null?void 0:o.viewState)==null?void 0:u.scrollToAnchor},o=>{o&&d.nextTick(()=>{const u=document.getElementById(o);u?u.scrollIntoView({behavior:"smooth",block:"start"}):console.warn(`Anchor element with id "${o}" not found`)})});const l=()=>{var g,x;if(!((x=(g=t.selectedResult)==null?void 0:g.data)!=null&&x.markdown))return;const o=new Blob([t.selectedResult.data.markdown],{type:"text/markdown"}),u=URL.createObjectURL(o),h=document.createElement("a");h.href=u;const b=t.selectedResult.title?`${t.selectedResult.title.replace(/[^a-z0-9]/gi,"_").toLowerCase()}.md`:"document.md";h.download=b,document.body.appendChild(h),h.click(),document.body.removeChild(h),URL.revokeObjectURL(u)};function p(){const o={...t.selectedResult,data:{...t.selectedResult.data,markdown:s.value,pdfPath:void 0}};r("updateResult",o)}return d.watch(()=>{var o;return(o=t.selectedResult.data)==null?void 0:o.markdown},o=>{s.value=o||""}),(o,u)=>{var h;return d.openBlock(),d.createElementBlock("div",pt,[(h=n.selectedResult.data)!=null&&h.markdown?(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createElementVNode("div",ut,[d.createElementVNode("div",dt,[d.createElementVNode("div",gt,[d.createElementVNode("h1",ft,d.toDisplayString(n.selectedResult.title||"Document"),1),d.createElementVNode("div",{class:"button-group"},[d.createElementVNode("button",{onClick:l,class:"download-btn download-btn-green"},[...u[2]||(u[2]=[d.createElementVNode("span",{class:"material-icons"},"download",-1),d.createTextVNode(" MD ",-1)])])])]),d.createElementVNode("div",{class:"markdown-content prose prose-slate max-w-none",innerHTML:c.value},null,8,kt)])]),d.createElementVNode("details",mt,[u[3]||(u[3]=d.createElementVNode("summary",null,"Edit Markdown Source",-1)),d.withDirectives(d.createElementVNode("textarea",{"onUpdate:modelValue":u[0]||(u[0]=b=>s.value=b),class:"markdown-editor",spellcheck:"false"},null,512),[[d.vModelText,s.value]]),d.createElementVNode("button",{onClick:p,class:"apply-btn",disabled:!i.value}," Apply Changes ",8,bt)])],64)):(d.openBlock(),d.createElementBlock("div",ht,[...u[1]||(u[1]=[d.createElementVNode("div",{class:"text-gray-500"},"No markdown content available",-1)])]))])}}}),wt=(n,e)=>{const t=n.__vccOpts||n;for(const[r,s]of e)t[r]=s;return t},ye=wt(xt,[["__scopeId","data-v-7bea9557"]]),yt={class:"text-center p-4 bg-purple-100 rounded"},vt={class:"text-sm text-gray-800 mt-1 font-medium truncate"},ve=d.defineComponent({__name:"Preview",props:{result:{}},setup(n){const e=n,t=d.computed(()=>{var r;if(e.result.title)return e.result.title;if((r=e.result.data)!=null&&r.markdown){const s=e.result.data.markdown.match(/^#\s+(.+)$/m);if(s)return s[1]}return"Markdown Document"});return(r,s)=>(d.openBlock(),d.createElementBlock("div",yt,[s[0]||(s[0]=d.createElementVNode("div",{class:"text-purple-600 font-medium"},"Document",-1)),d.createElementVNode("div",vt,d.toDisplayString(t.value),1)]))}}),H="presentDocument",Re=`Use the ${H} tool to create structured documents with text and embedded images. This tool is ideal for:
|
|
54
|
+
`+n+`</table>
|
|
55
|
+
`}tablerow({text:s}){return`<tr>
|
|
56
|
+
${s}</tr>
|
|
57
|
+
`}tablecell(s){let e=this.parser.parseInline(s.tokens),r=s.header?"th":"td";return(s.align?`<${r} align="${s.align}">`:`<${r}>`)+e+`</${r}>
|
|
58
|
+
`}strong({tokens:s}){return`<strong>${this.parser.parseInline(s)}</strong>`}em({tokens:s}){return`<em>${this.parser.parseInline(s)}</em>`}codespan({text:s}){return`<code>${R(s,!0)}</code>`}br(s){return"<br>"}del({tokens:s}){return`<del>${this.parser.parseInline(s)}</del>`}link({href:s,title:e,tokens:r}){let n=this.parser.parseInline(r),t=ne(s);if(t===null)return n;s=t;let i='<a href="'+s+'"';return e&&(i+=' title="'+R(e)+'"'),i+=">"+n+"</a>",i}image({href:s,title:e,text:r,tokens:n}){n&&(r=this.parser.parseInline(n,this.parser.textRenderer));let t=ne(s);if(t===null)return R(r);s=t;let i=`<img src="${s}" alt="${r}"`;return e&&(i+=` title="${R(e)}"`),i+=">",i}text(s){return"tokens"in s&&s.tokens?this.parser.parseInline(s.tokens):"escaped"in s&&s.escaped?s.text:R(s.text)}},Y=class{strong({text:s}){return s}em({text:s}){return s}codespan({text:s}){return s}del({text:s}){return s}html({text:s}){return s}text({text:s}){return s}link({text:s}){return""+s}image({text:s}){return""+s}br(){return""}checkbox({raw:s}){return s}},y=class Z{options;renderer;textRenderer;constructor(e){this.options=e||S,this.options.renderer=this.options.renderer||new B,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Y}static parse(e,r){return new Z(r).parse(e)}static parseInline(e,r){return new Z(r).parseInline(e)}parse(e){let r="";for(let n=0;n<e.length;n++){let t=e[n];if(this.options.extensions?.renderers?.[t.type]){let l=t,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){r+=c||"";continue}}let i=t;switch(i.type){case"space":{r+=this.renderer.space(i);break}case"hr":{r+=this.renderer.hr(i);break}case"heading":{r+=this.renderer.heading(i);break}case"code":{r+=this.renderer.code(i);break}case"table":{r+=this.renderer.table(i);break}case"blockquote":{r+=this.renderer.blockquote(i);break}case"list":{r+=this.renderer.list(i);break}case"checkbox":{r+=this.renderer.checkbox(i);break}case"html":{r+=this.renderer.html(i);break}case"def":{r+=this.renderer.def(i);break}case"paragraph":{r+=this.renderer.paragraph(i);break}case"text":{r+=this.renderer.text(i);break}default:{let l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}parseInline(e,r=this.renderer){let n="";for(let t=0;t<e.length;t++){let i=e[t];if(this.options.extensions?.renderers?.[i.type]){let c=this.options.extensions.renderers[i.type].call({parser:this},i);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=c||"";continue}}let l=i;switch(l.type){case"escape":{n+=r.text(l);break}case"html":{n+=r.html(l);break}case"link":{n+=r.link(l);break}case"image":{n+=r.image(l);break}case"checkbox":{n+=r.checkbox(l);break}case"strong":{n+=r.strong(l);break}case"em":{n+=r.em(l);break}case"codespan":{n+=r.codespan(l);break}case"br":{n+=r.br(l);break}case"del":{n+=r.del(l);break}case"text":{n+=r.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return n}},v=class{options;block;constructor(s){this.options=s||S}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(s){return s}postprocess(s){return s}processAllTokens(s){return s}emStrongMask(s){return s}provideLexer(){return this.block?w.lex:w.lexInline}provideParser(){return this.block?y.parse:y.parseInline}},lt=class{defaults=j();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=y;Renderer=B;TextRenderer=Y;Lexer=w;Tokenizer=L;Hooks=v;constructor(...s){this.use(...s)}walkTokens(s,e){let r=[];for(let n of s)switch(r=r.concat(e.call(this,n)),n.type){case"table":{let t=n;for(let i of t.header)r=r.concat(this.walkTokens(i.tokens,e));for(let i of t.rows)for(let l of i)r=r.concat(this.walkTokens(l.tokens,e));break}case"list":{let t=n;r=r.concat(this.walkTokens(t.items,e));break}default:{let t=n;this.defaults.extensions?.childTokens?.[t.type]?this.defaults.extensions.childTokens[t.type].forEach(i=>{let l=t[i].flat(1/0);r=r.concat(this.walkTokens(l,e))}):t.tokens&&(r=r.concat(this.walkTokens(t.tokens,e)))}}return r}use(...s){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return s.forEach(r=>{let n={...r};if(n.async=this.defaults.async||n.async||!1,r.extensions&&(r.extensions.forEach(t=>{if(!t.name)throw new Error("extension name required");if("renderer"in t){let i=e.renderers[t.name];i?e.renderers[t.name]=function(...l){let c=t.renderer.apply(this,l);return c===!1&&(c=i.apply(this,l)),c}:e.renderers[t.name]=t.renderer}if("tokenizer"in t){if(!t.level||t.level!=="block"&&t.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[t.level];i?i.unshift(t.tokenizer):e[t.level]=[t.tokenizer],t.start&&(t.level==="block"?e.startBlock?e.startBlock.push(t.start):e.startBlock=[t.start]:t.level==="inline"&&(e.startInline?e.startInline.push(t.start):e.startInline=[t.start]))}"childTokens"in t&&t.childTokens&&(e.childTokens[t.name]=t.childTokens)}),n.extensions=e),r.renderer){let t=this.defaults.renderer||new B(this.defaults);for(let i in r.renderer){if(!(i in t))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let l=i,c=r.renderer[l],a=t[l];t[l]=(...h)=>{let o=c.apply(t,h);return o===!1&&(o=a.apply(t,h)),o||""}}n.renderer=t}if(r.tokenizer){let t=this.defaults.tokenizer||new L(this.defaults);for(let i in r.tokenizer){if(!(i in t))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let l=i,c=r.tokenizer[l],a=t[l];t[l]=(...h)=>{let o=c.apply(t,h);return o===!1&&(o=a.apply(t,h)),o}}n.tokenizer=t}if(r.hooks){let t=this.defaults.hooks||new v;for(let i in r.hooks){if(!(i in t))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let l=i,c=r.hooks[l],a=t[l];v.passThroughHooks.has(i)?t[l]=h=>{if(this.defaults.async&&v.passThroughHooksRespectAsync.has(i))return(async()=>{let u=await c.call(t,h);return a.call(t,u)})();let o=c.call(t,h);return a.call(t,o)}:t[l]=(...h)=>{if(this.defaults.async)return(async()=>{let u=await c.apply(t,h);return u===!1&&(u=await a.apply(t,h)),u})();let o=c.apply(t,h);return o===!1&&(o=a.apply(t,h)),o}}n.hooks=t}if(r.walkTokens){let t=this.defaults.walkTokens,i=r.walkTokens;n.walkTokens=function(l){let c=[];return c.push(i.call(this,l)),t&&(c=c.concat(t.call(this,l))),c}}this.defaults={...this.defaults,...n}}),this}setOptions(s){return this.defaults={...this.defaults,...s},this}lexer(s,e){return w.lex(s,e??this.defaults)}parser(s,e){return y.parse(s,e??this.defaults)}parseMarkdown(s){return(e,r)=>{let n={...r},t={...this.defaults,...n},i=this.onError(!!t.silent,!!t.async);if(this.defaults.async===!0&&n.async===!1)return i(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 e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(t.hooks&&(t.hooks.options=t,t.hooks.block=s),t.async)return(async()=>{let l=t.hooks?await t.hooks.preprocess(e):e,c=await(t.hooks?await t.hooks.provideLexer():s?w.lex:w.lexInline)(l,t),a=t.hooks?await t.hooks.processAllTokens(c):c;t.walkTokens&&await Promise.all(this.walkTokens(a,t.walkTokens));let h=await(t.hooks?await t.hooks.provideParser():s?y.parse:y.parseInline)(a,t);return t.hooks?await t.hooks.postprocess(h):h})().catch(i);try{t.hooks&&(e=t.hooks.preprocess(e));let l=(t.hooks?t.hooks.provideLexer():s?w.lex:w.lexInline)(e,t);t.hooks&&(l=t.hooks.processAllTokens(l)),t.walkTokens&&this.walkTokens(l,t.walkTokens);let c=(t.hooks?t.hooks.provideParser():s?y.parse:y.parseInline)(l,t);return t.hooks&&(c=t.hooks.postprocess(c)),c}catch(l){return i(l)}}}onError(s,e){return r=>{if(r.message+=`
|
|
59
|
+
Please report this to https://github.com/markedjs/marked.`,s){let n="<p>An error occurred:</p><pre>"+R(r.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(r);throw r}}},$=new lt;function k(s,e){return $.parse(s,e)}k.options=k.setOptions=function(s){return $.setOptions(s),k.defaults=$.defaults,ae(k.defaults),k};k.getDefaults=j;k.defaults=S;k.use=function(...s){return $.use(...s),k.defaults=$.defaults,ae(k.defaults),k};k.walkTokens=function(s,e){return $.walkTokens(s,e)};k.parseInline=$.parseInline;k.Parser=y;k.parser=y.parse;k.Renderer=B;k.TextRenderer=Y;k.Lexer=w;k.lexer=w.lex;k.Tokenizer=L;k.Hooks=v;k.parse=k;k.options;k.setOptions;k.use;k.walkTokens;k.parseInline;y.parse;w.lex;const it={class:"markdown-container"},at={key:0,class:"min-h-full p-8 flex items-center justify-center"},ot={class:"markdown-content-wrapper"},ct={class:"p-4"},ht={class:"header-row"},pt={class:"document-title"},ut=["innerHTML"],dt={class:"markdown-source"},gt=["disabled"],kt=p.defineComponent({__name:"View",props:{selectedResult:{}},emits:["updateResult"],setup(s,{emit:e}){const r=s,n=e,t=p.ref(r.selectedResult.data?.markdown||""),i=p.computed(()=>t.value!==r.selectedResult.data?.markdown),l=p.computed(()=>r.selectedResult.data?.markdown?k(r.selectedResult.data.markdown):(console.error("No markdown data in result:",r.selectedResult),""));p.watch(()=>r.selectedResult?.viewState?.scrollToAnchor,h=>{h&&p.nextTick(()=>{const o=document.getElementById(h);o?o.scrollIntoView({behavior:"smooth",block:"start"}):console.warn(`Anchor element with id "${h}" not found`)})});const c=()=>{if(!r.selectedResult?.data?.markdown)return;const h=new Blob([r.selectedResult.data.markdown],{type:"text/markdown"}),o=URL.createObjectURL(h),u=document.createElement("a");u.href=o;const d=r.selectedResult.title?`${r.selectedResult.title.replace(/[^a-z0-9]/gi,"_").toLowerCase()}.md`:"document.md";u.download=d,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(o)};function a(){const h={...r.selectedResult,data:{...r.selectedResult.data,markdown:t.value,pdfPath:void 0}};n("updateResult",h)}return p.watch(()=>r.selectedResult.data?.markdown,h=>{t.value=h||""}),(h,o)=>(p.openBlock(),p.createElementBlock("div",it,[s.selectedResult.data?.markdown?(p.openBlock(),p.createElementBlock(p.Fragment,{key:1},[p.createElementVNode("div",ot,[p.createElementVNode("div",ct,[p.createElementVNode("div",ht,[p.createElementVNode("h1",pt,p.toDisplayString(s.selectedResult.title||"Document"),1),p.createElementVNode("div",{class:"button-group"},[p.createElementVNode("button",{onClick:c,class:"download-btn download-btn-green"},[...o[2]||(o[2]=[p.createElementVNode("span",{class:"material-icons"},"download",-1),p.createTextVNode(" MD ",-1)])])])]),p.createElementVNode("div",{class:"markdown-content prose prose-slate max-w-none",innerHTML:l.value},null,8,ut)])]),p.createElementVNode("details",dt,[o[3]||(o[3]=p.createElementVNode("summary",null,"Edit Markdown Source",-1)),p.withDirectives(p.createElementVNode("textarea",{"onUpdate:modelValue":o[0]||(o[0]=u=>t.value=u),class:"markdown-editor",spellcheck:"false"},null,512),[[p.vModelText,t.value]]),p.createElementVNode("button",{onClick:a,class:"apply-btn",disabled:!i.value}," Apply Changes ",8,gt)])],64)):(p.openBlock(),p.createElementBlock("div",at,[...o[1]||(o[1]=[p.createElementVNode("div",{class:"text-gray-500"},"No markdown content available",-1)])]))]))}}),ft=(s,e)=>{const r=s.__vccOpts||s;for(const[n,t]of e)r[n]=t;return r},be=ft(kt,[["__scopeId","data-v-7bea9557"]]),xt={class:"text-center p-4 bg-purple-100 rounded"},bt={class:"text-sm text-gray-800 mt-1 font-medium truncate"},me=p.defineComponent({__name:"Preview",props:{result:{}},setup(s){const e=s,r=p.computed(()=>{if(e.result.title)return e.result.title;if(e.result.data?.markdown){const n=e.result.data.markdown.match(/^#\s+(.+)$/m);if(n)return n[1]}return"Markdown Document"});return(n,t)=>(p.openBlock(),p.createElementBlock("div",xt,[t[0]||(t[0]=p.createElementVNode("div",{class:"text-purple-600 font-medium"},"Document",-1)),p.createElementVNode("div",bt,p.toDisplayString(r.value),1)]))}}),V="presentDocument",we=`Use the ${V} tool to create structured documents with text and embedded images. This tool is ideal for:
|
|
57
60
|
- Guides, tutorials, and how-to content ("create a guide about...", "explain how to...")
|
|
58
61
|
- Educational content (lessons, explanations, timelines, concept visualizations)
|
|
59
62
|
- Reports and presentations (business reports, data analysis, infographics)
|
|
@@ -64,6 +67,6 @@ Please report this to https://github.com/markedjs/marked.`,n){const r="<p>An err
|
|
|
64
67
|
- Product presentations or lookbooks
|
|
65
68
|
- Any content that combines written information with supporting visuals
|
|
66
69
|
|
|
67
|
-
IMPORTANT: Use this tool instead of just generating standalone images when the user wants informational or educational content with visuals. This creates a cohesive document with formatted text (markdown) AND images embedded at appropriate locations. For example, if asked to "create a guide about photosynthesis with a diagram", use ${
|
|
70
|
+
IMPORTANT: Use this tool instead of just generating standalone images when the user wants informational or educational content with visuals. This creates a cohesive document with formatted text (markdown) AND images embedded at appropriate locations. For example, if asked to "create a guide about photosynthesis with a diagram", use ${V} to create a full guide with explanatory text and the diagram embedded, rather than just generating the diagram image alone.
|
|
68
71
|
|
|
69
|
-
Format embedded images as: `,
|
|
72
|
+
Format embedded images as: `,ye={...T.pluginCore,viewComponent:be,previewComponent:me,samples:T.samples,systemPrompt:we},mt={plugin:ye};exports.TOOL_DEFINITION=T.TOOL_DEFINITION;exports.executeMarkdown=T.executeMarkdown;exports.pluginCore=T.pluginCore;exports.samples=T.samples;exports.Preview=me;exports.SYSTEM_PROMPT=we;exports.TOOL_NAME=V;exports.View=be;exports.default=mt;exports.plugin=ye;
|