[^\r]+?<\/pre>)/gm, function(_, f) { - var j = f; - return j = j.replace(/^ /mg, "¨0"), j = j.replace(/¨0/g, ""), j; - }), a.subParser("hashBlock")(`-` + u + ` -`, s, o); - }), r = o.converter._dispatch("blockQuotes.after", r, s, o), r; - }), a.subParser("codeBlocks", function(r, s, o) { - r = o.converter._dispatch("codeBlocks.before", r, s, o), r += "¨0"; - var c = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g; - return r = r.replace(c, function(u, _, f) { - var j = _, F = f, U = ` -`; - return j = a.subParser("outdent")(j, s, o), j = a.subParser("encodeCode")(j, s, o), j = a.subParser("detab")(j, s, o), j = j.replace(/^\n+/g, ""), j = j.replace(/\n+$/g, ""), s.omitExtraWLInCodeBlocks && (U = ""), j = "", a.subParser("hashBlock")(j, s, o) + F; - }), r = r.replace(/¨0/, ""), r = o.converter._dispatch("codeBlocks.after", r, s, o), r; - }), a.subParser("codeSpans", function(r, s, o) { - return r = o.converter._dispatch("codeSpans.before", r, s, o), typeof r > "u" && (r = ""), r = r.replace( - /(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, - function(c, u, _, f) { - var j = f; - return j = j.replace(/^([ \t]*)/g, ""), j = j.replace(/[ \t]*$/g, ""), j = a.subParser("encodeCode")(j, s, o), j = u + "" + j + U + "
" + j + "
", j = a.subParser("hashHTMLSpans")(j, s, o), j; - } - ), r = o.converter._dispatch("codeSpans.after", r, s, o), r; - }), a.subParser("completeHTMLDocument", function(r, s, o) { - if (!s.completeHTMLDocument) - return r; - r = o.converter._dispatch("completeHTMLDocument.before", r, s, o); - var c = "html", u = ` -`, _ = "", f = ` -`, j = "", F = ""; - typeof o.metadata.parsed.doctype < "u" && (u = " -`, c = o.metadata.parsed.doctype.toString().toLowerCase(), (c === "html" || c === "html5") && (f = '')); - for (var U in o.metadata.parsed) - if (o.metadata.parsed.hasOwnProperty(U)) - switch (U.toLowerCase()) { - case "doctype": - break; - case "title": - _ = "" + o.metadata.parsed.title + ` -`; - break; - case "charset": - c === "html" || c === "html5" ? f = ' -` : f = ' -`; - break; - case "language": - case "lang": - j = ' lang="' + o.metadata.parsed[U] + '"', F += ' -`; - break; - default: - F += ' -`; - } - return r = u + " - -` + _ + f + F + ` - -` + r.trim() + ` - -`, r = o.converter._dispatch("completeHTMLDocument.after", r, s, o), r; - }), a.subParser("detab", function(r, s, o) { - return r = o.converter._dispatch("detab.before", r, s, o), r = r.replace(/\t(?=\t)/g, " "), r = r.replace(/\t/g, "¨A¨B"), r = r.replace(/¨B(.+?)¨A/g, function(c, u) { - for (var _ = u, f = 4 - _.length % 4, j = 0; j < f; j++) - _ += " "; - return _; - }), r = r.replace(/¨A/g, " "), r = r.replace(/¨B/g, ""), r = o.converter._dispatch("detab.after", r, s, o), r; - }), a.subParser("ellipsis", function(r, s, o) { - return s.ellipsis && (r = o.converter._dispatch("ellipsis.before", r, s, o), r = r.replace(/\.\.\./g, "…"), r = o.converter._dispatch("ellipsis.after", r, s, o)), r; - }), a.subParser("emoji", function(r, s, o) { - if (!s.emoji) - return r; - r = o.converter._dispatch("emoji.before", r, s, o); - var c = /:([\S]+?):/g; - return r = r.replace(c, function(u, _) { - return a.helper.emojis.hasOwnProperty(_) ? a.helper.emojis[_] : u; - }), r = o.converter._dispatch("emoji.after", r, s, o), r; - }), a.subParser("encodeAmpsAndAngles", function(r, s, o) { - return r = o.converter._dispatch("encodeAmpsAndAngles.before", r, s, o), r = r.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, "&"), r = r.replace(/<(?![a-z\/?$!])/gi, "<"), r = r.replace(//g, ">"), r = o.converter._dispatch("encodeAmpsAndAngles.after", r, s, o), r; - }), a.subParser("encodeBackslashEscapes", function(r, s, o) { - return r = o.converter._dispatch("encodeBackslashEscapes.before", r, s, o), r = r.replace(/\\(\\)/g, a.helper.escapeCharactersCallback), r = r.replace(/\\([`*_{}\[\]()>#+.!~=|:-])/g, a.helper.escapeCharactersCallback), r = o.converter._dispatch("encodeBackslashEscapes.after", r, s, o), r; - }), a.subParser("encodeCode", function(r, s, o) { - return r = o.converter._dispatch("encodeCode.before", r, s, o), r = r.replace(/&/g, "&").replace(//g, ">").replace(/([*_{}\[\]\\=~-])/g, a.helper.escapeCharactersCallback), r = o.converter._dispatch("encodeCode.after", r, s, o), r; - }), a.subParser("escapeSpecialCharsWithinTagAttributes", function(r, s, o) { - r = o.converter._dispatch("escapeSpecialCharsWithinTagAttributes.before", r, s, o); - var c = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi, u = /-]|-[^>])(?:[^-]|-[^-])*)--)>/gi; - return r = r.replace(c, function(_) { - return _.replace(/(.)<\/?code>(?=.)/g, "$1`").replace(/([\\`*_~=|])/g, a.helper.escapeCharactersCallback); - }), r = r.replace(u, function(_) { - return _.replace(/([\\`*_~=|])/g, a.helper.escapeCharactersCallback); - }), r = o.converter._dispatch("escapeSpecialCharsWithinTagAttributes.after", r, s, o), r; - }), a.subParser("githubCodeBlocks", function(r, s, o) { - return s.ghCodeBlocks ? (r = o.converter._dispatch("githubCodeBlocks.before", r, s, o), r += "¨0", r = r.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function(c, u, _, f) { - var j = s.omitExtraWLInCodeBlocks ? "" : ` -`; - return f = a.subParser("encodeCode")(f, s, o), f = a.subParser("detab")(f, s, o), f = f.replace(/^\n+/g, ""), f = f.replace(/\n+$/g, ""), f = "", f = a.subParser("hashBlock")(f, s, o), ` - -¨G` + (o.ghCodeBlocks.push({ text: c, codeblock: f }) - 1) + `G - -`; - }), r = r.replace(/¨0/, ""), o.converter._dispatch("githubCodeBlocks.after", r, s, o)) : r; - }), a.subParser("hashBlock", function(r, s, o) { - return r = o.converter._dispatch("hashBlock.before", r, s, o), r = r.replace(/(^\n+|\n+$)/g, ""), r = ` - -¨K` + (o.gHtmlBlocks.push(r) - 1) + `K - -`, r = o.converter._dispatch("hashBlock.after", r, s, o), r; - }), a.subParser("hashCodeTags", function(r, s, o) { - r = o.converter._dispatch("hashCodeTags.before", r, s, o); - var c = function(u, _, f, j) { - var F = f + a.subParser("encodeCode")(_, s, o) + j; - return "¨C" + (o.gHtmlSpans.push(F) - 1) + "C"; - }; - return r = a.helper.replaceRecursiveRegExp(r, c, "" + f + j + "
]*>", "
", "gim"), r = o.converter._dispatch("hashCodeTags.after", r, s, o), r; - }), a.subParser("hashElement", function(r, s, o) { - return function(c, u) { - var _ = u; - return _ = _.replace(/\n\n/g, ` -`), _ = _.replace(/^\n/, ""), _ = _.replace(/\n+$/g, ""), _ = ` - -¨K` + (o.gHtmlBlocks.push(_) - 1) + `K - -`, _; - }; - }), a.subParser("hashHTMLBlocks", function(r, s, o) { - r = o.converter._dispatch("hashHTMLBlocks.before", r, s, o); - var c = [ - "pre", - "div", - "h1", - "h2", - "h3", - "h4", - "h5", - "h6", - "blockquote", - "table", - "dl", - "ol", - "ul", - "script", - "noscript", - "form", - "fieldset", - "iframe", - "math", - "style", - "section", - "header", - "footer", - "nav", - "article", - "aside", - "address", - "audio", - "canvas", - "figure", - "hgroup", - "output", - "video", - "p" - ], u = function(w, G, Q, ee) { - var q = w; - return Q.search(/\bmarkdown\b/) !== -1 && (q = Q + o.converter.makeHtml(G) + ee), ` - -¨K` + (o.gHtmlBlocks.push(q) - 1) + `K - -`; - }; - s.backslashEscapesHTMLTags && (r = r.replace(/\\<(\/?[^>]+?)>/g, function(w, G) { - return "<" + G + ">"; - })); - for (var _ = 0; _ < c.length; ++_) - for (var f, j = new RegExp("^ {0,3}(<" + c[_] + "\\b[^>]*>)", "im"), F = "<" + c[_] + "\\b[^>]*>", U = "" + c[_] + ">"; (f = a.helper.regexIndexOf(r, j)) !== -1; ) { - var D = a.helper.splitAtIndex(r, f), W = a.helper.replaceRecursiveRegExp(D[1], u, F, U, "im"); - if (W === D[1]) - break; - r = D[0].concat(W); - } - return r = r.replace( - /(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g, - a.subParser("hashElement")(r, s, o) - ), r = a.helper.replaceRecursiveRegExp(r, function(w) { - return ` - -¨K` + (o.gHtmlBlocks.push(w) - 1) + `K - -`; - }, "^ {0,3}", "gm"), r = r.replace( - /(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g, - a.subParser("hashElement")(r, s, o) - ), r = o.converter._dispatch("hashHTMLBlocks.after", r, s, o), r; - }), a.subParser("hashHTMLSpans", function(r, s, o) { - r = o.converter._dispatch("hashHTMLSpans.before", r, s, o); - function c(u) { - return "¨C" + (o.gHtmlSpans.push(u) - 1) + "C"; - } - return r = r.replace(/<[^>]+?\/>/gi, function(u) { - return c(u); - }), r = r.replace(/<([^>]+?)>[\s\S]*?<\/\1>/g, function(u) { - return c(u); - }), r = r.replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g, function(u) { - return c(u); - }), r = r.replace(/<[^>]+?>/gi, function(u) { - return c(u); - }), r = o.converter._dispatch("hashHTMLSpans.after", r, s, o), r; - }), a.subParser("unhashHTMLSpans", function(r, s, o) { - r = o.converter._dispatch("unhashHTMLSpans.before", r, s, o); - for (var c = 0; c < o.gHtmlSpans.length; ++c) { - for (var u = o.gHtmlSpans[c], _ = 0; /¨C(\d+)C/.test(u); ) { - var f = RegExp.$1; - if (u = u.replace("¨C" + f + "C", o.gHtmlSpans[f]), _ === 10) { - console.error("maximum nesting of 10 spans reached!!!"); - break; - } - ++_; - } - r = r.replace("¨C" + c + "C", u); - } - return r = o.converter._dispatch("unhashHTMLSpans.after", r, s, o), r; - }), a.subParser("hashPreCodeTags", function(r, s, o) { - r = o.converter._dispatch("hashPreCodeTags.before", r, s, o); - var c = function(u, _, f, j) { - var F = f + a.subParser("encodeCode")(_, s, o) + j; - return ` - -¨G` + (o.ghCodeBlocks.push({ text: u, codeblock: F }) - 1) + `G - -`; - }; - return r = a.helper.replaceRecursiveRegExp(r, c, "^ {0,3}]*>\\s*", "gim"), r = o.converter._dispatch("hashPreCodeTags.after", r, s, o), r; - }), a.subParser("headers", function(r, s, o) { - r = o.converter._dispatch("headers.before", r, s, o); - var c = isNaN(parseInt(s.headerLevelStart)) ? 1 : parseInt(s.headerLevelStart), u = s.smoothLivePreview ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm, _ = s.smoothLivePreview ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm; - r = r.replace(u, function(F, U) { - var D = a.subParser("spanGamut")(U, s, o), W = s.noHeaderId ? "" : ' id="' + j(U) + '"', w = c, G = "]*>", "^ {0,3}
\\s*" + D + " "; - return a.subParser("hashBlock")(G, s, o); - }), r = r.replace(_, function(F, U) { - var D = a.subParser("spanGamut")(U, s, o), W = s.noHeaderId ? "" : ' id="' + j(U) + '"', w = c + 1, G = "" + D + " "; - return a.subParser("hashBlock")(G, s, o); - }); - var f = s.requireSpaceBeforeHeadingText ? /^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm : /^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm; - r = r.replace(f, function(F, U, D) { - var W = D; - s.customizedHeaderId && (W = D.replace(/\s?\{([^{]+?)}\s*$/, "")); - var w = a.subParser("spanGamut")(W, s, o), G = s.noHeaderId ? "" : ' id="' + j(D) + '"', Q = c - 1 + U.length, ee = "" + w + " "; - return a.subParser("hashBlock")(ee, s, o); - }); - function j(F) { - var U, D; - if (s.customizedHeaderId) { - var W = F.match(/\{([^{]+?)}\s*$/); - W && W[1] && (F = W[1]); - } - return U = F, a.helper.isString(s.prefixHeaderId) ? D = s.prefixHeaderId : s.prefixHeaderId === !0 ? D = "section-" : D = "", s.rawPrefixHeaderId || (U = D + U), s.ghCompatibleHeaderId ? U = U.replace(/ /g, "-").replace(/&/g, "").replace(/¨T/g, "").replace(/¨D/g, "").replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, "").toLowerCase() : s.rawHeaderId ? U = U.replace(/ /g, "-").replace(/&/g, "&").replace(/¨T/g, "¨").replace(/¨D/g, "$").replace(/["']/g, "-").toLowerCase() : U = U.replace(/[^\w]/g, "").toLowerCase(), s.rawPrefixHeaderId && (U = D + U), o.hashLinkCounts[U] ? U = U + "-" + o.hashLinkCounts[U]++ : o.hashLinkCounts[U] = 1, U; - } - return r = o.converter._dispatch("headers.after", r, s, o), r; - }), a.subParser("horizontalRule", function(r, s, o) { - r = o.converter._dispatch("horizontalRule.before", r, s, o); - var c = a.subParser("hashBlock")("
", s, o); - return r = r.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, c), r = r.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, c), r = r.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, c), r = o.converter._dispatch("horizontalRule.after", r, s, o), r; - }), a.subParser("images", function(r, s, o) { - r = o.converter._dispatch("images.before", r, s, o); - var c = /!\[([^\]]*?)][ \t]*()\([ \t]?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g, u = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g, _ = /!\[([^\]]*?)][ \t]*()\([ \t]?(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g, f = /!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g, j = /!\[([^\[\]]+)]()()()()()/g; - function F(D, W, w, G, Q, ee, q, P) { - return G = G.replace(/\s/g, ""), U(D, W, w, G, Q, ee, q, P); - } - function U(D, W, w, G, Q, ee, q, P) { - var H = o.gUrls, N = o.gTitles, d = o.gDimensions; - if (w = w.toLowerCase(), P || (P = ""), D.search(/\(\s*>? ?(['"].*['"])?\)$/m) > -1) - G = ""; - else if (G === "" || G === null) - if ((w === "" || w === null) && (w = W.toLowerCase().replace(/ ?\n/g, " ")), G = "#" + w, !a.helper.isUndefined(H[w])) - G = H[w], a.helper.isUndefined(N[w]) || (P = N[w]), a.helper.isUndefined(d[w]) || (Q = d[w].width, ee = d[w].height); - else - return D; - W = W.replace(/"/g, """).replace(a.helper.regexes.asteriskDashAndColon, a.helper.escapeCharactersCallback), G = G.replace(a.helper.regexes.asteriskDashAndColon, a.helper.escapeCharactersCallback); - var y = '", y; - } - return r = r.replace(f, U), r = r.replace(_, F), r = r.replace(u, U), r = r.replace(c, U), r = r.replace(j, U), r = o.converter._dispatch("images.after", r, s, o), r; - }), a.subParser("italicsAndBold", function(r, s, o) { - r = o.converter._dispatch("italicsAndBold.before", r, s, o); - function c(u, _, f) { - return _ + u + f; - } - return s.literalMidWordUnderscores ? (r = r.replace(/\b___(\S[\s\S]*?)___\b/g, function(u, _) { - return c(_, "", ""); - }), r = r.replace(/\b__(\S[\s\S]*?)__\b/g, function(u, _) { - return c(_, "", ""); - }), r = r.replace(/\b_(\S[\s\S]*?)_\b/g, function(u, _) { - return c(_, "", ""); - })) : (r = r.replace(/___(\S[\s\S]*?)___/g, function(u, _) { - return /\S$/.test(_) ? c(_, "", "") : u; - }), r = r.replace(/__(\S[\s\S]*?)__/g, function(u, _) { - return /\S$/.test(_) ? c(_, "", "") : u; - }), r = r.replace(/_([^\s_][\s\S]*?)_/g, function(u, _) { - return /\S$/.test(_) ? c(_, "", "") : u; - })), s.literalMidWordAsterisks ? (r = r.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g, function(u, _, f) { - return c(f, _ + "", ""); - }), r = r.replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g, function(u, _, f) { - return c(f, _ + "", ""); - }), r = r.replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g, function(u, _, f) { - return c(f, _ + "", ""); - })) : (r = r.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function(u, _) { - return /\S$/.test(_) ? c(_, "", "") : u; - }), r = r.replace(/\*\*(\S[\s\S]*?)\*\*/g, function(u, _) { - return /\S$/.test(_) ? c(_, "", "") : u; - }), r = r.replace(/\*([^\s*][\s\S]*?)\*/g, function(u, _) { - return /\S$/.test(_) ? c(_, "", "") : u; - })), r = o.converter._dispatch("italicsAndBold.after", r, s, o), r; - }), a.subParser("lists", function(r, s, o) { - function c(f, j) { - o.gListLevel++, f = f.replace(/\n{2,}$/, ` -`), f += "¨0"; - var F = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm, U = /\n[ \t]*\n(?!¨0)/.test(f); - return s.disableForced4SpacesIndentedSublists && (F = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm), f = f.replace(F, function(D, W, w, G, Q, ee, q) { - q = q && q.trim() !== ""; - var P = a.subParser("outdent")(Q, s, o), H = ""; - return ee && s.tasklists && (H = ' class="task-list-item" style="list-style-type: none;"', P = P.replace(/^[ \t]*\[(x|X| )?]/m, function() { - var N = '", N; - })), P = P.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g, function(N) { - return "¨A" + N; - }), W || P.search(/\n{2,}/) > -1 ? (P = a.subParser("githubCodeBlocks")(P, s, o), P = a.subParser("blockGamut")(P, s, o)) : (P = a.subParser("lists")(P, s, o), P = P.replace(/\n$/, ""), P = a.subParser("hashHTMLBlocks")(P, s, o), P = P.replace(/\n\n+/g, ` - -`), U ? P = a.subParser("paragraphs")(P, s, o) : P = a.subParser("spanGamut")(P, s, o)), P = P.replace("¨A", ""), P = "
"), j += "
", u.push(j)); - } - for (_ = u.length, f = 0; f < _; f++) { - for (var F = "", U = u[f], D = !1; /¨(K|G)(\d+)\1/.test(U); ) { - var W = RegExp.$1, w = RegExp.$2; - W === "K" ? F = o.gHtmlBlocks[w] : D ? F = a.subParser("encodeCode")(o.ghCodeBlocks[w].text, s, o) : F = o.ghCodeBlocks[w].codeblock, F = F.replace(/\$/g, "$$$$"), U = U.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/, F), /^]*>\s*]*>/.test(U) && (D = !0);
- }
- u[f] = U;
- }
- return r = u.join(`
-`), r = r.replace(/^\n+/g, ""), r = r.replace(/\n+$/g, ""), o.converter._dispatch("paragraphs.after", r, s, o);
- }), a.subParser("runExtension", function(r, s, o, c) {
- if (r.filter)
- s = r.filter(s, c.converter, o);
- else if (r.regex) {
- var u = r.regex;
- u instanceof RegExp || (u = new RegExp(u, "g")), s = s.replace(u, r.replace);
- }
- return s;
- }), a.subParser("spanGamut", function(r, s, o) {
- return r = o.converter._dispatch("spanGamut.before", r, s, o), r = a.subParser("codeSpans")(r, s, o), r = a.subParser("escapeSpecialCharsWithinTagAttributes")(r, s, o), r = a.subParser("encodeBackslashEscapes")(r, s, o), r = a.subParser("images")(r, s, o), r = a.subParser("anchors")(r, s, o), r = a.subParser("autoLinks")(r, s, o), r = a.subParser("simplifiedAutoLinks")(r, s, o), r = a.subParser("emoji")(r, s, o), r = a.subParser("underline")(r, s, o), r = a.subParser("italicsAndBold")(r, s, o), r = a.subParser("strikethrough")(r, s, o), r = a.subParser("ellipsis")(r, s, o), r = a.subParser("hashHTMLSpans")(r, s, o), r = a.subParser("encodeAmpsAndAngles")(r, s, o), s.simpleLineBreaks ? /\n\n¨K/.test(r) || (r = r.replace(/\n+/g, `
-`)) : r = r.replace(/ +\n/g, `
-`), r = o.converter._dispatch("spanGamut.after", r, s, o), r;
- }), a.subParser("strikethrough", function(r, s, o) {
- function c(u) {
- return s.simplifiedAutoLink && (u = a.subParser("simplifiedAutoLinks")(u, s, o)), "" + u + "";
- }
- return s.strikethrough && (r = o.converter._dispatch("strikethrough.before", r, s, o), r = r.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function(u, _) {
- return c(_);
- }), r = o.converter._dispatch("strikethrough.after", r, s, o)), r;
- }), a.subParser("stripLinkDefinitions", function(r, s, o) {
- var c = /^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*([^>\s]+)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=¨0))/gm, u = /^ {0,3}\[([^\]]+)]:[ \t]*\n?[ \t]*(data:.+?\/.+?;base64,[A-Za-z0-9+/=\n]+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n\n|(?=¨0)|(?=\n\[))/gm;
- r += "¨0";
- var _ = function(f, j, F, U, D, W, w) {
- return j = j.toLowerCase(), r.toLowerCase().split(j).length - 1 < 2 ? f : (F.match(/^data:.+?\/.+?;base64,/) ? o.gUrls[j] = F.replace(/\s/g, "") : o.gUrls[j] = a.subParser("encodeAmpsAndAngles")(F, s, o), W ? W + w : (w && (o.gTitles[j] = w.replace(/"|'/g, """)), s.parseImgDimensions && U && D && (o.gDimensions[j] = {
- width: U,
- height: D
- }), ""));
- };
- return r = r.replace(u, _), r = r.replace(c, _), r = r.replace(/¨0/, ""), r;
- }), a.subParser("tables", function(r, s, o) {
- if (!s.tables)
- return r;
- var c = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm, u = /^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm;
- function _(D) {
- return /^:[ \t]*--*$/.test(D) ? ' style="text-align:left;"' : /^--*[ \t]*:[ \t]*$/.test(D) ? ' style="text-align:right;"' : /^:[ \t]*--*[ \t]*:$/.test(D) ? ' style="text-align:center;"' : "";
- }
- function f(D, W) {
- var w = "";
- return D = D.trim(), (s.tablesHeaderId || s.tableHeaderId) && (w = ' id="' + D.replace(/ /g, "_").toLowerCase() + '"'), D = a.subParser("spanGamut")(D, s, o), "" + D + `
-`;
- }
- function j(D, W) {
- var w = a.subParser("spanGamut")(D, s, o);
- return "" + w + `
-`;
- }
- function F(D, W) {
- for (var w = `
-
-
-`, G = D.length, Q = 0; Q < G; ++Q)
- w += D[Q];
- for (w += `
-
-
-`, Q = 0; Q < W.length; ++Q) {
- w += `
-`;
- for (var ee = 0; ee < G; ++ee)
- w += W[Q][ee];
- w += `
-`;
- }
- return w += `
-
-`, w;
- }
- function U(D) {
- var W, w = D.split(`
-`);
- for (W = 0; W < w.length; ++W)
- /^ {0,3}\|/.test(w[W]) && (w[W] = w[W].replace(/^ {0,3}\|/, "")), /\|[ \t]*$/.test(w[W]) && (w[W] = w[W].replace(/\|[ \t]*$/, "")), w[W] = a.subParser("codeSpans")(w[W], s, o);
- var G = w[0].split("|").map(function(y) {
- return y.trim();
- }), Q = w[1].split("|").map(function(y) {
- return y.trim();
- }), ee = [], q = [], P = [], H = [];
- for (w.shift(), w.shift(), W = 0; W < w.length; ++W)
- w[W].trim() !== "" && ee.push(
- w[W].split("|").map(function(y) {
- return y.trim();
- })
- );
- if (G.length < Q.length)
- return D;
- for (W = 0; W < Q.length; ++W)
- P.push(_(Q[W]));
- for (W = 0; W < G.length; ++W)
- a.helper.isUndefined(P[W]) && (P[W] = ""), q.push(f(G[W], P[W]));
- for (W = 0; W < ee.length; ++W) {
- for (var N = [], d = 0; d < q.length; ++d)
- a.helper.isUndefined(ee[W][d]), N.push(j(ee[W][d], P[d]));
- H.push(N);
- }
- return F(q, H);
- }
- return r = o.converter._dispatch("tables.before", r, s, o), r = r.replace(/\\(\|)/g, a.helper.escapeCharactersCallback), r = r.replace(c, U), r = r.replace(u, U), r = o.converter._dispatch("tables.after", r, s, o), r;
- }), a.subParser("underline", function(r, s, o) {
- return s.underline && (r = o.converter._dispatch("underline.before", r, s, o), s.literalMidWordUnderscores ? (r = r.replace(/\b___(\S[\s\S]*?)___\b/g, function(c, u) {
- return "" + u + "";
- }), r = r.replace(/\b__(\S[\s\S]*?)__\b/g, function(c, u) {
- return "" + u + "";
- })) : (r = r.replace(/___(\S[\s\S]*?)___/g, function(c, u) {
- return /\S$/.test(u) ? "" + u + "" : c;
- }), r = r.replace(/__(\S[\s\S]*?)__/g, function(c, u) {
- return /\S$/.test(u) ? "" + u + "" : c;
- })), r = r.replace(/(_)/g, a.helper.escapeCharactersCallback), r = o.converter._dispatch("underline.after", r, s, o)), r;
- }), a.subParser("unescapeSpecialChars", function(r, s, o) {
- return r = o.converter._dispatch("unescapeSpecialChars.before", r, s, o), r = r.replace(/¨E(\d+)E/g, function(c, u) {
- var _ = parseInt(u);
- return String.fromCharCode(_);
- }), r = o.converter._dispatch("unescapeSpecialChars.after", r, s, o), r;
- }), a.subParser("makeMarkdown.blockquote", function(r, s) {
- var o = "";
- if (r.hasChildNodes())
- for (var c = r.childNodes, u = c.length, _ = 0; _ < u; ++_) {
- var f = a.subParser("makeMarkdown.node")(c[_], s);
- f !== "" && (o += f);
- }
- return o = o.trim(), o = "> " + o.split(`
-`).join(`
-> `), o;
- }), a.subParser("makeMarkdown.codeBlock", function(r, s) {
- var o = r.getAttribute("language"), c = r.getAttribute("precodenum");
- return "```" + o + `
-` + s.preList[c] + "\n```";
- }), a.subParser("makeMarkdown.codeSpan", function(r) {
- return "`" + r.innerHTML + "`";
- }), a.subParser("makeMarkdown.emphasis", function(r, s) {
- var o = "";
- if (r.hasChildNodes()) {
- o += "*";
- for (var c = r.childNodes, u = c.length, _ = 0; _ < u; ++_)
- o += a.subParser("makeMarkdown.node")(c[_], s);
- o += "*";
- }
- return o;
- }), a.subParser("makeMarkdown.header", function(r, s, o) {
- var c = new Array(o + 1).join("#"), u = "";
- if (r.hasChildNodes()) {
- u = c + " ";
- for (var _ = r.childNodes, f = _.length, j = 0; j < f; ++j)
- u += a.subParser("makeMarkdown.node")(_[j], s);
- }
- return u;
- }), a.subParser("makeMarkdown.hr", function() {
- return "---";
- }), a.subParser("makeMarkdown.image", function(r) {
- var s = "";
- return r.hasAttribute("src") && (s += "![" + r.getAttribute("alt") + "](", s += "<" + r.getAttribute("src") + ">", r.hasAttribute("width") && r.hasAttribute("height") && (s += " =" + r.getAttribute("width") + "x" + r.getAttribute("height")), r.hasAttribute("title") && (s += ' "' + r.getAttribute("title") + '"'), s += ")"), s;
- }), a.subParser("makeMarkdown.links", function(r, s) {
- var o = "";
- if (r.hasChildNodes() && r.hasAttribute("href")) {
- var c = r.childNodes, u = c.length;
- o = "[";
- for (var _ = 0; _ < u; ++_)
- o += a.subParser("makeMarkdown.node")(c[_], s);
- o += "](", o += "<" + r.getAttribute("href") + ">", r.hasAttribute("title") && (o += ' "' + r.getAttribute("title") + '"'), o += ")";
- }
- return o;
- }), a.subParser("makeMarkdown.list", function(r, s, o) {
- var c = "";
- if (!r.hasChildNodes())
- return "";
- for (var u = r.childNodes, _ = u.length, f = r.getAttribute("start") || 1, j = 0; j < _; ++j)
- if (!(typeof u[j].tagName > "u" || u[j].tagName.toLowerCase() !== "li")) {
- var F = "";
- o === "ol" ? F = f.toString() + ". " : F = "- ", c += F + a.subParser("makeMarkdown.listItem")(u[j], s), ++f;
- }
- return c += `
-
-`, c.trim();
- }), a.subParser("makeMarkdown.listItem", function(r, s) {
- for (var o = "", c = r.childNodes, u = c.length, _ = 0; _ < u; ++_)
- o += a.subParser("makeMarkdown.node")(c[_], s);
- return /\n$/.test(o) ? o = o.split(`
-`).join(`
- `).replace(/^ {4}$/gm, "").replace(/\n\n+/g, `
-
-`) : o += `
-`, o;
- }), a.subParser("makeMarkdown.node", function(r, s, o) {
- o = o || !1;
- var c = "";
- if (r.nodeType === 3)
- return a.subParser("makeMarkdown.txt")(r, s);
- if (r.nodeType === 8)
- return "
-
-`;
- if (r.nodeType !== 1)
- return "";
- var u = r.tagName.toLowerCase();
- switch (u) {
- case "h1":
- o || (c = a.subParser("makeMarkdown.header")(r, s, 1) + `
-
-`);
- break;
- case "h2":
- o || (c = a.subParser("makeMarkdown.header")(r, s, 2) + `
-
-`);
- break;
- case "h3":
- o || (c = a.subParser("makeMarkdown.header")(r, s, 3) + `
-
-`);
- break;
- case "h4":
- o || (c = a.subParser("makeMarkdown.header")(r, s, 4) + `
-
-`);
- break;
- case "h5":
- o || (c = a.subParser("makeMarkdown.header")(r, s, 5) + `
-
-`);
- break;
- case "h6":
- o || (c = a.subParser("makeMarkdown.header")(r, s, 6) + `
-
-`);
- break;
- case "p":
- o || (c = a.subParser("makeMarkdown.paragraph")(r, s) + `
-
-`);
- break;
- case "blockquote":
- o || (c = a.subParser("makeMarkdown.blockquote")(r, s) + `
-
-`);
- break;
- case "hr":
- o || (c = a.subParser("makeMarkdown.hr")(r, s) + `
-
-`);
- break;
- case "ol":
- o || (c = a.subParser("makeMarkdown.list")(r, s, "ol") + `
-
-`);
- break;
- case "ul":
- o || (c = a.subParser("makeMarkdown.list")(r, s, "ul") + `
-
-`);
- break;
- case "precode":
- o || (c = a.subParser("makeMarkdown.codeBlock")(r, s) + `
-
-`);
- break;
- case "pre":
- o || (c = a.subParser("makeMarkdown.pre")(r, s) + `
-
-`);
- break;
- case "table":
- o || (c = a.subParser("makeMarkdown.table")(r, s) + `
-
-`);
- break;
- case "code":
- c = a.subParser("makeMarkdown.codeSpan")(r, s);
- break;
- case "em":
- case "i":
- c = a.subParser("makeMarkdown.emphasis")(r, s);
- break;
- case "strong":
- case "b":
- c = a.subParser("makeMarkdown.strong")(r, s);
- break;
- case "del":
- c = a.subParser("makeMarkdown.strikethrough")(r, s);
- break;
- case "a":
- c = a.subParser("makeMarkdown.links")(r, s);
- break;
- case "img":
- c = a.subParser("makeMarkdown.image")(r, s);
- break;
- default:
- c = r.outerHTML + `
-
-`;
- }
- return c;
- }), a.subParser("makeMarkdown.paragraph", function(r, s) {
- var o = "";
- if (r.hasChildNodes())
- for (var c = r.childNodes, u = c.length, _ = 0; _ < u; ++_)
- o += a.subParser("makeMarkdown.node")(c[_], s);
- return o = o.trim(), o;
- }), a.subParser("makeMarkdown.pre", function(r, s) {
- var o = r.getAttribute("prenum");
- return "" + s.preList[o] + "
";
- }), a.subParser("makeMarkdown.strikethrough", function(r, s) {
- var o = "";
- if (r.hasChildNodes()) {
- o += "~~";
- for (var c = r.childNodes, u = c.length, _ = 0; _ < u; ++_)
- o += a.subParser("makeMarkdown.node")(c[_], s);
- o += "~~";
- }
- return o;
- }), a.subParser("makeMarkdown.strong", function(r, s) {
- var o = "";
- if (r.hasChildNodes()) {
- o += "**";
- for (var c = r.childNodes, u = c.length, _ = 0; _ < u; ++_)
- o += a.subParser("makeMarkdown.node")(c[_], s);
- o += "**";
- }
- return o;
- }), a.subParser("makeMarkdown.table", function(r, s) {
- var o = "", c = [[], []], u = r.querySelectorAll("thead>tr>th"), _ = r.querySelectorAll("tbody>tr"), f, j;
- for (f = 0; f < u.length; ++f) {
- var F = a.subParser("makeMarkdown.tableCell")(u[f], s), U = "---";
- if (u[f].hasAttribute("style")) {
- var D = u[f].getAttribute("style").toLowerCase().replace(/\s/g, "");
- switch (D) {
- case "text-align:left;":
- U = ":---";
- break;
- case "text-align:right;":
- U = "---:";
- break;
- case "text-align:center;":
- U = ":---:";
- break;
- }
- }
- c[0][f] = F.trim(), c[1][f] = U;
- }
- for (f = 0; f < _.length; ++f) {
- var W = c.push([]) - 1, w = _[f].getElementsByTagName("td");
- for (j = 0; j < u.length; ++j) {
- var G = " ";
- typeof w[j] < "u" && (G = a.subParser("makeMarkdown.tableCell")(w[j], s)), c[W].push(G);
- }
- }
- var Q = 3;
- for (f = 0; f < c.length; ++f)
- for (j = 0; j < c[f].length; ++j) {
- var ee = c[f][j].length;
- ee > Q && (Q = ee);
- }
- for (f = 0; f < c.length; ++f) {
- for (j = 0; j < c[f].length; ++j)
- f === 1 ? c[f][j].slice(-1) === ":" ? c[f][j] = a.helper.padEnd(c[f][j].slice(-1), Q - 1, "-") + ":" : c[f][j] = a.helper.padEnd(c[f][j], Q, "-") : c[f][j] = a.helper.padEnd(c[f][j], Q);
- o += "| " + c[f].join(" | ") + ` |
-`;
- }
- return o.trim();
- }), a.subParser("makeMarkdown.tableCell", function(r, s) {
- var o = "";
- if (!r.hasChildNodes())
- return "";
- for (var c = r.childNodes, u = c.length, _ = 0; _ < u; ++_)
- o += a.subParser("makeMarkdown.node")(c[_], s, !0);
- return o.trim();
- }), a.subParser("makeMarkdown.txt", function(r) {
- var s = r.nodeValue;
- return s = s.replace(/ +/g, " "), s = s.replace(/¨NBSP;/g, " "), s = a.helper.unescapeHTMLEntities(s), s = s.replace(/([*_~|`])/g, "\\$1"), s = s.replace(/^(\s*)>/g, "\\$1>"), s = s.replace(/^#/gm, "\\#"), s = s.replace(/^(\s*)([-=]{3,})(\s*)$/, "$1\\$2$3"), s = s.replace(/^( {0,3}\d+)\./gm, "$1\\."), s = s.replace(/^( {0,3})([+-])/gm, "$1\\$2"), s = s.replace(/]([\s]*)\(/g, "\\]$1\\("), s = s.replace(/^ {0,3}\[([\S \t]*?)]:/gm, "\\[$1]:"), s;
- });
- var L = this;
- e.exports ? e.exports = a : L.showdown = a;
- }).call(gn);
-})(Kn);
-var Hc = Kn.exports;
-const pn = /* @__PURE__ */ _n(Hc);
-class fn {
- constructor() {
- xe(this, "logger"), xe(this, "converter"), this.logger = Pa.zhiLog("showdown-adaptor"), this.converter = new pn.Converter();
- }
- isAvailable() {
- return typeof pn < "u";
- }
- renderMarkdownStr(t) {
- if (!this.isAvailable())
- throw new Error("Showdown is not available");
- return this.logger.info("Showdown is rendering md to HTML..."), Promise.resolve(this.converter.makeHtml(t));
- }
-}
-class Gn {
- constructor() {
- xe(this, "logger"), xe(this, "mdAdaptor", new fn()), this.logger = Pa.zhiLog("markdown-util");
- }
- /**
- * 获取当前 MD 解析器名称
- */
- getCurrentAdaptorName() {
- return this.mdAdaptor instanceof hn ? "Lute" : this.mdAdaptor instanceof fn ? "Showdown" : "None";
- }
- /**
- * 渲染Markdown
- *
- * @param md - Markdown文本
- */
- async renderHTML(t) {
- const n = new hn();
- return this.logger.debug("Lute status =>", n.isAvailable()), n.isAvailable() && (this.mdAdaptor = n), this.logger.info(`Using ${this.getCurrentAdaptorName()} as markdown renderer`), await this.mdAdaptor.renderMarkdownStr(t);
- }
-}
-class Kc {
- constructor() {
- xe(this, "mdUtil"), this.mdUtil = new Gn();
- }
- /**
- * 移除标题数字
- *
- * @param str - 字符串
- */
- removeTitleNumber(t) {
- let n = t;
- const a = /([0-9]*)\./;
- return n = n.replace(a, ""), n;
- }
- /**
- * 删除挂件的HTML
- *
- * @param str - 原字符
- */
- removeWidgetTag(t) {
- let n = t.toString();
- const a = //g;
- n = n.replace(a, "");
- const i = //g;
- n = n.replace(i, "");
- const l = //g;
- return n = n.replace(l, ""), n;
- }
- /**
- * 删除Markdown文本的挂件的HTML
- *
- * @param str - 原字符
- */
- removeMdWidgetTag(t) {
- let n = t.toString();
- return n = this.removeWidgetTag(n), n;
- }
- /**
- * 去除html标签,残缺不全也可以
- *
- * @param str - 字符串
- */
- filterHtml(t) {
- t = t.replace(/
- `
-
- new Dialog({
- title: this.i18n.siyuanBlog,
- transparent: false,
- content: contentHtml,
- width: "90%",
- height: "750px",
- } as any)
- }
-
- private showWidgetPublisherWindow(type?: "blog" | "detail" | "picgo") {
- const win = window as any
- const deviceType = this.zhiDevice.DeviceDetection.getDevice()
- this.logger.info(`you are from ${deviceType}`)
-
- let pageId: string | undefined = PageUtil.getPageId()
- if (pageId == "") {
- pageId = undefined
- }
- this.logger.debug("pageId=>", pageId)
-
- if (deviceType == this.zhiDevice.DeviceTypeEnum.DeviceType_Siyuan_MainWin) {
- this.importDep("./libs/plugin-publisher-bridge/index.js").then((bridge) => {
- const publisherBridge = new bridge.default()
- publisherBridge.init().then(() => {
- let pageUrl
- switch (type) {
- case "blog":
- // 博客首页
- pageUrl = "blog/index.html"
- break
- case "detail":
- // 详情
- pageUrl = "detail/index.html"
- break
- case "picgo":
- pageUrl = "picgo/index.html"
- break
- default:
- // 发布首页
- pageUrl = "index.html"
- break
- }
- if (!pageId && pageUrl === "index.html") {
- pageUrl = "blog/index.html"
- }
-
- win.syp.renderPublishHelper(pageId, pageUrl, win, isDev)
- this.logger.debug("publisherHook inited")
- })
- })
- } else {
- const publisherIndex = `/widgets/sy-post-publisher/index.html`
- this.showWidgetPublisherDialog(publisherIndex)
- }
+/*
+ * Copyright (c) 2023, Terwer . All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Terwer designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Terwer in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
+ * or visit www.terwer.space if you need additional information or have any
+ * questions.
+ */
+
+import { App, IObject, Plugin } from "siyuan"
+import { simpleLogger } from "zhi-lib-base"
+
+import "../index.styl"
+import { isDev } from "./Constants"
+
+export default class ImporterPlugin extends Plugin {
+ private logger
+
+ constructor(options: { app: App; id: string; name: string; i18n: IObject }) {
+ super(options)
+
+ this.logger = simpleLogger("index", "demo", isDev)
+ }
+
+ onload() {
+ this.logger.info("Demo loaded")
+ }
+
+ onunload() {
+ this.logger.info("Demo loaded")
}
}
diff --git a/src/lib/preferences/GeneralSetting.svelte b/src/lib/preferences/GeneralSetting.svelte
deleted file mode 100644
index 71c1be56..00000000
--- a/src/lib/preferences/GeneralSetting.svelte
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-General Setting
diff --git a/src/lib/preferences/PicgoSetting.svelte b/src/lib/preferences/PicgoSetting.svelte
deleted file mode 100644
index cf3ad088..00000000
--- a/src/lib/preferences/PicgoSetting.svelte
+++ /dev/null
@@ -1,25 +0,0 @@
-
-PicgoSetting
diff --git a/src/lib/preferences/PublishSetting.svelte b/src/lib/preferences/PublishSetting.svelte
deleted file mode 100644
index f4683067..00000000
--- a/src/lib/preferences/PublishSetting.svelte
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-Publish Setting
diff --git a/src/loader.ts b/src/loader.ts
deleted file mode 100644
index e44cb897..00000000
--- a/src/loader.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import PublisherPlugin from "~/src/index"
-import { moduleBase } from "~/src/constants"
-
-export const initLibs = async (pluginInstance: PublisherPlugin) => {
- // polyfills
- pluginInstance.fs = (await import(`${moduleBase}/polyfills/fs.js`))["default"]
- pluginInstance.path = (await import(`${moduleBase}/polyfills/path.js`))["default"]
- pluginInstance.importDep = async (moduleName) => {
- return await import(pluginInstance.path.join(moduleBase, moduleName))
- }
-
- // libs
-
- // zhi-device
- const zhiDevice = (await pluginInstance.importDep("./libs/zhi-device/index.js")) as any
- pluginInstance.zhiDevice = {
- DeviceDetection: zhiDevice["DeviceDetection"],
- SiyuanDevice: zhiDevice["SiyuanDevice"],
- DeviceTypeEnum: zhiDevice["DeviceTypeEnum"],
- }
-
- // zhi-env
- const zhiEnv = (await pluginInstance.importDep("./libs/zhi-env/index.js")) as any
- pluginInstance.zhiEnv = {
- Env: zhiEnv["Env"],
- }
-
- // zhi-log
- const zhiLog = (await pluginInstance.importDep("./libs/zhi-log/index.js")) as any
- pluginInstance.zhiLog = {
- LogFactory: zhiLog["LogFactory"],
- DefaultLogger: zhiLog["DefaultLogger"],
- crossChalk: zhiLog["crossChalk"],
- }
-
- // zhi-common
- const zhiCommon = (await pluginInstance.importDep("./libs/zhi-common/index.js")) as any
- pluginInstance.zhiCommon = {
- ZhiCommon: zhiCommon["ZhiCommon"],
- ZhiUtil: zhiCommon["ZhiUtil"],
- }
-
- // zhi-blog-api
- const zhiBlogApi = (await pluginInstance.importDep("./libs/zhi-blog-api/index.js")) as any
- pluginInstance.zhiBlogApi = {
- BlogConstants: zhiBlogApi["BlogConstants"],
- BlogTypeEnum: zhiBlogApi["BlogTypeEnum"],
- BlogApi: zhiBlogApi["BlogApi"],
- }
-
- // zhi-siyuan-api
- const zhiSiyuanApi = (await pluginInstance.importDep("./libs/zhi-siyuan-api/index.js")) as any
- pluginInstance.zhiSiyuanApi = {
- SiyuanConstants: zhiSiyuanApi["SiyuanConstants"],
- SiyuanConfig: zhiSiyuanApi["SiyuanConfig"],
- SiYuanApiAdaptor: zhiSiyuanApi["SiYuanApiAdaptor"],
- SiyuanKernelApi: zhiSiyuanApi["SiyuanKernelApi"]
- }
-
- // zhi-publisher-sdk
- const zhiPublisherSdk = (await pluginInstance.importDep("./libs/zhi-publisher-sdk/index.js")) as any
- pluginInstance.zhiPublisherSdk = {
- PublishSdk: zhiPublisherSdk["PublishSdk"],
- }
-}
diff --git a/src/routes/Picbed.svelte b/src/routes/Picbed.svelte
deleted file mode 100644
index 1a7bd5bf..00000000
--- a/src/routes/Picbed.svelte
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Picbed
diff --git a/src/routes/Preferences.svelte b/src/routes/Preferences.svelte
deleted file mode 100644
index 295a5be6..00000000
--- a/src/routes/Preferences.svelte
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-Preferences
-
-
-
diff --git a/src/routes/Publish.svelte b/src/routes/Publish.svelte
deleted file mode 100644
index de2286e3..00000000
--- a/src/routes/Publish.svelte
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-Publish
diff --git a/src/siyuan.d.ts b/src/siyuan.d.ts
deleted file mode 100644
index a3c22c21..00000000
--- a/src/siyuan.d.ts
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2023, Terwer . All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Terwer designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Terwer in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
- * or visit www.terwer.space if you need additional information or have any
- * questions.
- */
-
-declare module "siyuan" {
- type TEventBus = "ws-main"
-
- interface IObject {
- [key: string]: string;
- }
-
- interface IWebSocketData {
- cmd: string
- callback?: string
- data: any
- msg: string
- code: number
- sid: string
- }
-
- interface IPluginDockTab {
- position: "LeftTop" | "LeftBottom" | "RightTop" | "RightBottom" | "BottomLeft" | "BottomRight",
- size: { width: number, height: number },
- icon: string,
- hotkey?: string,
- title: string,
- }
-
- interface IMenuItemOption {
- label?: string,
- click?: (element: HTMLElement) => void,
- type?: "separator" | "submenu" | "readonly",
- accelerator?: string,
- action?: string,
- id?: string,
- submenu?: IMenuItemOption[]
- disabled?: boolean
- icon?: string
- iconHTML?: string
- current?: boolean
- bind?: (element: HTMLElement) => void
- }
-
- export function fetchPost(url: string, data?: any, cb?: (response: IWebSocketData) => void, headers?: IObject): void;
-
- export function fetchSyncPost(url: string, data?: any): Promise;
-
- export function fetchGet(url: string, cb: (response: IWebSocketData) => void): void;
-
- export function openTab(options: {
- custom?: {
- title: string,
- icon: string,
- data?: any
- fn?: () => any,
- } // card 和自定义页签 必填
- position?: "right" | "bottom",
- keepCursor?: boolean // 是否跳转到新 tab 上
- removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签
- afterOpen?: () => void // 打开后回调
- }): void
-
- export function isMobile(): boolean;
-
- export function adaptHotkey(hotkey: string): string;
-
- export function confirm(title: string, text: string, confirmCB?: () => void, cancelCB?: () => void): void;
-
- /**
- * @param timeout - ms. 0: manual close;-1: always show; 6000: default
- * @param {string} [type=info]
- */
- export function showMessage(text: string, timeout?: number, type?: "info" | "error", id?: string): void;
-
- export class App {
- plugins: Plugin[];
- }
-
- export abstract class Plugin {
- eventBus: EventBus;
- i18n: IObject;
- data: any;
- name: string;
-
- constructor(options: {
- app: App,
- id: string,
- name: string,
- i18n: IObject
- })
-
- onload(): void;
-
- onunload(): void;
-
- /*
- * @param {string} [options.position=right]
- */
- addTopBar(options: {
- icon: string,
- title: string,
- callback: (evt: MouseEvent) => void
- position?: "right" | "left"
- }): HTMLDivElement;
-
- openSetting(): void
-
- // registerCommand(command: IPluginCommand): void;
-
- // registerSettingRender(settingRender: SettingRender): void;
-
- loadData(storageName: string): Promise;
-
- saveData(storageName: string, content: any): Promise;
-
- removeData(storageName: string): Promise;
-
- addTab(options: {
- type: string,
- destroy?: () => void,
- resize?: () => void,
- update?: () => void,
- init: () => void
- }): () => any
-
- addDock(options: {
- config: IPluginDockTab,
- data: any,
- type: string,
- destroy?: () => void,
- resize?: () => void,
- update?: () => void,
- init: () => void
- }): any
- }
-
- export class EventBus {
- on(type: TEventBus, listener: (event: CustomEvent) => void): void;
-
- once(type: TEventBus, listener: (event: CustomEvent) => void): void;
-
- off(type: TEventBus, listener: (event: CustomEvent) => void): void;
-
- emit(type: TEventBus, detail?: any): boolean;
- }
-
- export class Dialog {
-
- element: HTMLElement;
-
- constructor(options: {
- title?: string,
- transparent?: boolean,
- content: string,
- width?: string
- height?: string,
- destroyCallback?: (options?: IObject) => void
- disableClose?: boolean
- disableAnimation?: boolean
- });
-
- destroy(options?: IObject): void;
-
- bindInput(inputElement: HTMLInputElement | HTMLTextAreaElement, enterEvent?: () => void): void;
- }
-
- export class Menu {
- constructor(id?: string, closeCB?: () => void);
-
- showSubMenu(subMenuElement: HTMLElement): void;
-
- addItem(options: IMenuItemOption): HTMLElement;
-
- addSeparator(): void;
-
- open(options: { x: number, y: number, h?: number, w?: number, isLeft?: boolean }): void;
-
- /*
- * @param {string} [position=all]
- */
- fullscreen(position?: "bottom" | "all"): void;
-
- close(): void;
- }
-}
\ No newline at end of file
diff --git a/src/tools.ts b/src/tools.ts
deleted file mode 100644
index 77842556..00000000
--- a/src/tools.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { Utils } from "~/src/utils/utils"
-import PublisherPlugin from "~/src/index"
-
-/**
- * 初始化工具类
- *
- * @param appInstance - 应用实例
- */
-export const initTools = async (appInstance: PublisherPlugin) => {
- // this.env = Utils.zhiEnv(this)
- appInstance.logger = Utils.zhiLog(appInstance, "publisher-index")
- // this.common = Utils.zhiCommon(appInstance)
-
- // kernelApi
- appInstance.kernelApi = Utils.kernelApi(appInstance)
-
- // blogApi
- appInstance.blogApi = Utils.blogApi(appInstance)
-}
diff --git a/src/utils/pageUtil.ts b/src/utils/pageUtil.ts
index cab7d140..7e21681e 100644
--- a/src/utils/pageUtil.ts
+++ b/src/utils/pageUtil.ts
@@ -23,30 +23,17 @@
* questions.
*/
-import App from "../App.svelte"
-
/**
- * 页面统一入口,根据路由创建不同页面
+ * 文档工具类
*/
class PageUtil {
public static getPageId() {
- const element = document.querySelector(".protyle-title")
- const result = element ? element.getAttribute("data-node-id") : null
- return result ?? ""
- }
-
- public static getElementId(pageId: string) {
- return pageId === "" ? "home" : `publisher-${pageId}`
- }
-
- public static createApp(pageId: string): App {
- const elementId = this.getElementId(pageId)
- return new App({
- target: document.getElementById(elementId) as HTMLElement,
- props: {
- url: `/${pageId}`,
- },
- })
+ // 查找包含 protyle 类但不包含 fn__none 的 div 元素
+ const protyleElement = document.querySelector("div.protyle:not(.fn__none)")
+ // 在该 div 元素下查找包含 protyle-title 类的 div 元素,并查找 data-node-id 属性
+ const protyleTitleElement = protyleElement?.querySelector("div.protyle-title")
+ // 如果该元素存在 data-node-id 属性,则获取其值并返回,否则返回空字符串
+ return protyleTitleElement?.hasAttribute("data-node-id") ? protyleTitleElement.getAttribute("data-node-id") : ""
}
}
diff --git a/src/utils/svg.ts b/src/utils/svg.ts
index 756a94d4..6c90447d 100644
--- a/src/utils/svg.ts
+++ b/src/utils/svg.ts
@@ -23,24 +23,4 @@
* questions.
*/
-/**
- * 图标
- */
-const iconPublish = {
- iconPlane: ``,
- iconPicture: ``,
- iconOl: ``,
- iconPreference: ``,
- iconPicbed: ``,
- iconPublish: ``,
- iconCnblogs: ``,
- iconTypecho: ``,
- iconWordpress: ``,
- iconYuque: ``,
- iconGithub: ``,
- iconHexo: ``,
- iconHugo: ``,
- iconVue: ``,
-}
-
-export default iconPublish
+export const icons = {}
diff --git a/src/utils/utils.ts b/src/utils/utils.ts
index f34408d6..7401aae9 100644
--- a/src/utils/utils.ts
+++ b/src/utils/utils.ts
@@ -1,78 +1,24 @@
-import PublisherPlugin from "~/src"
-
-/**
- * 通用工具类
+/*
+ * Copyright (c) 2023, Terwer . All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * @author terwer
- * @version 1.0.0
- * @since 1.0.0
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Terwer designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Terwer in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
+ * or visit www.terwer.space if you need additional information or have any
+ * questions.
*/
-export class Utils {
- private static env
- private static kApi
- private static bApi
-
- /**
- * 通用环境变量
- *
- * @param pluginInstance - 插件实例
- */
- public static zhiEnv(pluginInstance: PublisherPlugin) {
- if (!this.env) {
- // 环境变量需要在使用的时候显式指定
- this.env = new pluginInstance.zhiEnv.Env(import.meta.env)
- }
- return this.env
- }
-
- /**
- * 通用日志
- *
- * @param pluginInstance - 插件实例
- * @param loggerName - 日志名称
- */
- public static zhiLog(pluginInstance: PublisherPlugin, loggerName: string) {
- const env = this.zhiEnv(pluginInstance)
- pluginInstance.zhiCommon.ZhiUtil.initEnv(env)
-
- // 用 common 里面的,这里面我封装了日志缓存
- return pluginInstance.zhiCommon.ZhiUtil.zhiLogWithSign("publisher", loggerName)
- }
-
- /**
- * 通用工具入口
- *
- * @param pluginInstance - 插件实例
- */
- public static zhiCommon(pluginInstance: PublisherPlugin) {
- return pluginInstance.zhiCommon.ZhiUtil.zhiCommon()
- }
-
- public static kernelApi(appInstance: PublisherPlugin) {
- if (!this.kApi) {
- const cfg = new appInstance.zhiSiyuanApi.SiyuanConfig("", "")
- this.kApi = new appInstance.zhiSiyuanApi.SiyuanKernelApi(cfg)
- this.kApi.init(appInstance)
- }
- return this.kApi
- }
- public static blogApi(appInstance: PublisherPlugin, blogType?: any, blogCfg?: any) {
- if (!this.bApi) {
- const publishSdk = appInstance.zhiPublisherSdk.PublishSdk
- publishSdk.init({
- appInstance: appInstance,
- Env: appInstance.zhiEnv.Env,
- BlogConstants: appInstance.zhiBlogApi.BlogConstants,
- BlogTypeEnum: appInstance.zhiBlogApi.BlogTypeEnum,
- SiyuanConstants: appInstance.zhiSiyuanApi.SiyuanConstants,
- SiyuanConfig: appInstance.zhiSiyuanApi.SiyuanConfig,
- SiYuanApiAdaptor: appInstance.zhiSiyuanApi.SiYuanApiAdaptor,
- BlogApi: appInstance.zhiBlogApi.BlogApi,
- })
- const type = blogType ?? appInstance.zhiBlogApi.BlogTypeEnum.BlogTypeEnum_Siyuan
- const cfg = blogCfg ?? new appInstance.zhiSiyuanApi.SiyuanConfig("", "")
- this.bApi = publishSdk.blogApi(type, cfg)
- }
- return this.bApi
- }
-}
diff --git a/svelte.config.js b/svelte.config.js
old mode 100755
new mode 100644
diff --git a/tsconfig.json b/tsconfig.json
index 30bf2b9d..08cfe0c6 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,6 +1,6 @@
{
"compilerOptions": {
- "target": "ESNext",
+ "target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": [
@@ -17,38 +17,19 @@
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
-
/* Linting */
- "strict": false,
- "noUnusedLocals": false,
- "noUnusedParameters": false,
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
-
- /* Svelte */
- /**
- * Typecheck JS in `.svelte` and `.js` files by default.
- * Disable checkJs if you'd like to use dynamic types in JS.
- * Note that setting allowJs false does not prevent the use
- * of JS in `.svelte` files.
- */
- "allowJs": true,
- "checkJs": true,
-
"types": [
"node",
- "vite/client",
- "svelte"
- ],
-
- "paths": {
- "~/*": ["./*"]
- }
+ "vite/client"
+ ]
},
"include": [
- "tools/**/*.ts",
"src/**/*.ts",
"src/**/*.d.ts",
- "public/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue"
],
diff --git a/vite.config.ts b/vite.config.ts
index 3767839a..d3c1299f 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,7 +1,5 @@
-///
-
-import path, { resolve } from "path"
-import { defineConfig } from "vite"
+import { resolve } from "path"
+import { defineConfig, loadEnv } from "vite"
import minimist from "minimist"
import { viteStaticCopy } from "vite-plugin-static-copy"
import livereload from "rollup-plugin-livereload"
@@ -10,7 +8,11 @@ import fg from "fast-glob"
const args = minimist(process.argv.slice(2))
const isWatch = args.watch || args.w || false
-const devDistDir = "/Users/terwer/Documents/mydocs/SiYuanWorkspace/public/data/plugins/siyuan-publisher"
+const isWindows = process.platform === "win32"
+let devDistDir = "/Users/terwer/Documents/mydocs/SiYuanWorkspace/public/data/plugins/siyuan-plugin-custom-slug"
+if (isWindows) {
+ devDistDir = "C:\\Users\\terwer\\Documents\\mydocs\\SiyuanWorkspace\\public\\data\\plugins\\siyuan-plugin-custom-slug"
+}
const distDir = isWatch ? devDistDir : "./dist"
console.log("isWatch=>", isWatch)
@@ -54,12 +56,6 @@ export default defineConfig({
"process.env.DEV_MODE": `"${isWatch}"`,
},
- resolve: {
- alias: {
- "~": path.resolve(__dirname, "./"),
- },
- },
-
build: {
// 输出路径
outDir: distDir,
@@ -115,10 +111,4 @@ export default defineConfig({
},
},
},
-
- test: {
- globals: true,
- environment: "jsdom",
- include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
- },
})