/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
__markAsModule(target);
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toModule = (module2) => {
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// node_modules/showdown/dist/showdown.js
var require_showdown = __commonJS({
"node_modules/showdown/dist/showdown.js"(exports, module2) {
(function() {
function getDefaultOpts(simple) {
"use strict";
var defaultOptions = {
omitExtraWLInCodeBlocks: {
defaultValue: false,
describe: "Omit the default extra whiteline added to code blocks",
type: "boolean"
},
noHeaderId: {
defaultValue: false,
describe: "Turn on/off generated header id",
type: "boolean"
},
prefixHeaderId: {
defaultValue: false,
describe: "Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to true will add a generic 'section-' prefix",
type: "string"
},
rawPrefixHeaderId: {
defaultValue: false,
describe: 'Setting this option to true will prevent showdown from modifying the prefix. This might result in malformed IDs (if, for instance, the " char is used in the prefix)',
type: "boolean"
},
ghCompatibleHeaderId: {
defaultValue: false,
describe: "Generate header ids compatible with github style (spaces are replaced with dashes, a bunch of non alphanumeric chars are removed)",
type: "boolean"
},
rawHeaderId: {
defaultValue: false,
describe: `Remove only spaces, ' and " from generated header ids (including prefixes), replacing them with dashes (-). WARNING: This might result in malformed ids`,
type: "boolean"
},
headerLevelStart: {
defaultValue: false,
describe: "The header blocks level start",
type: "integer"
},
parseImgDimensions: {
defaultValue: false,
describe: "Turn on/off image dimension parsing",
type: "boolean"
},
simplifiedAutoLink: {
defaultValue: false,
describe: "Turn on/off GFM autolink style",
type: "boolean"
},
excludeTrailingPunctuationFromURLs: {
defaultValue: false,
describe: "Excludes trailing punctuation from links generated with autoLinking",
type: "boolean"
},
literalMidWordUnderscores: {
defaultValue: false,
describe: "Parse midword underscores as literal underscores",
type: "boolean"
},
literalMidWordAsterisks: {
defaultValue: false,
describe: "Parse midword asterisks as literal asterisks",
type: "boolean"
},
strikethrough: {
defaultValue: false,
describe: "Turn on/off strikethrough support",
type: "boolean"
},
tables: {
defaultValue: false,
describe: "Turn on/off tables support",
type: "boolean"
},
tablesHeaderId: {
defaultValue: false,
describe: "Add an id to table headers",
type: "boolean"
},
ghCodeBlocks: {
defaultValue: true,
describe: "Turn on/off GFM fenced code blocks support",
type: "boolean"
},
tasklists: {
defaultValue: false,
describe: "Turn on/off GFM tasklist support",
type: "boolean"
},
smoothLivePreview: {
defaultValue: false,
describe: "Prevents weird effects in live previews due to incomplete input",
type: "boolean"
},
smartIndentationFix: {
defaultValue: false,
describe: "Tries to smartly fix indentation in es6 strings",
type: "boolean"
},
disableForced4SpacesIndentedSublists: {
defaultValue: false,
describe: "Disables the requirement of indenting nested sublists by 4 spaces",
type: "boolean"
},
simpleLineBreaks: {
defaultValue: false,
describe: "Parses simple line breaks as
(GFM Style)",
type: "boolean"
},
requireSpaceBeforeHeadingText: {
defaultValue: false,
describe: "Makes adding a space between `#` and the header text mandatory (GFM Style)",
type: "boolean"
},
ghMentions: {
defaultValue: false,
describe: "Enables github @mentions",
type: "boolean"
},
ghMentionsLink: {
defaultValue: "https://github.com/{u}",
describe: "Changes the link generated by @mentions. Only applies if ghMentions option is enabled.",
type: "string"
},
encodeEmails: {
defaultValue: true,
describe: "Encode e-mail addresses through the use of Character Entities, transforming ASCII e-mail addresses into its equivalent decimal entities",
type: "boolean"
},
openLinksInNewWindow: {
defaultValue: false,
describe: "Open all links in new windows",
type: "boolean"
},
backslashEscapesHTMLTags: {
defaultValue: false,
describe: "Support for HTML Tag escaping. ex:
[^\r]+?<\/pre>)/gm, function(wholeMatch, m1) {
var pre = m1;
pre = pre.replace(/^ /mg, "\xA80");
pre = pre.replace(/¨0/g, "");
return pre;
});
return showdown2.subParser("hashBlock")("\n" + bq + "\n
", options, globals);
});
text = globals.converter._dispatch("blockQuotes.after", text, options, globals);
return text;
});
showdown2.subParser("codeBlocks", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("codeBlocks.before", text, options, globals);
text += "\xA80";
var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=¨0))/g;
text = text.replace(pattern, function(wholeMatch, m1, m2) {
var codeblock = m1, nextChar = m2, end = "\n";
codeblock = showdown2.subParser("outdent")(codeblock, options, globals);
codeblock = showdown2.subParser("encodeCode")(codeblock, options, globals);
codeblock = showdown2.subParser("detab")(codeblock, options, globals);
codeblock = codeblock.replace(/^\n+/g, "");
codeblock = codeblock.replace(/\n+$/g, "");
if (options.omitExtraWLInCodeBlocks) {
end = "";
}
codeblock = "" + codeblock + end + "
";
return showdown2.subParser("hashBlock")(codeblock, options, globals) + nextChar;
});
text = text.replace(/¨0/, "");
text = globals.converter._dispatch("codeBlocks.after", text, options, globals);
return text;
});
showdown2.subParser("codeSpans", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("codeSpans.before", text, options, globals);
if (typeof text === "undefined") {
text = "";
}
text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, function(wholeMatch, m1, m2, m3) {
var c = m3;
c = c.replace(/^([ \t]*)/g, "");
c = c.replace(/[ \t]*$/g, "");
c = showdown2.subParser("encodeCode")(c, options, globals);
c = m1 + "" + c + "";
c = showdown2.subParser("hashHTMLSpans")(c, options, globals);
return c;
});
text = globals.converter._dispatch("codeSpans.after", text, options, globals);
return text;
});
showdown2.subParser("completeHTMLDocument", function(text, options, globals) {
"use strict";
if (!options.completeHTMLDocument) {
return text;
}
text = globals.converter._dispatch("completeHTMLDocument.before", text, options, globals);
var doctype = "html", doctypeParsed = "\n", title = "", charset = '\n', lang = "", metadata = "";
if (typeof globals.metadata.parsed.doctype !== "undefined") {
doctypeParsed = "\n";
doctype = globals.metadata.parsed.doctype.toString().toLowerCase();
if (doctype === "html" || doctype === "html5") {
charset = '';
}
}
for (var meta in globals.metadata.parsed) {
if (globals.metadata.parsed.hasOwnProperty(meta)) {
switch (meta.toLowerCase()) {
case "doctype":
break;
case "title":
title = "" + globals.metadata.parsed.title + " \n";
break;
case "charset":
if (doctype === "html" || doctype === "html5") {
charset = '\n';
} else {
charset = '\n';
}
break;
case "language":
case "lang":
lang = ' lang="' + globals.metadata.parsed[meta] + '"';
metadata += '\n';
break;
default:
metadata += '\n';
}
}
}
text = doctypeParsed + "\n\n" + title + charset + metadata + "\n\n" + text.trim() + "\n\n";
text = globals.converter._dispatch("completeHTMLDocument.after", text, options, globals);
return text;
});
showdown2.subParser("detab", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("detab.before", text, options, globals);
text = text.replace(/\t(?=\t)/g, " ");
text = text.replace(/\t/g, "\xA8A\xA8B");
text = text.replace(/¨B(.+?)¨A/g, function(wholeMatch, m1) {
var leadingText = m1, numSpaces = 4 - leadingText.length % 4;
for (var i = 0; i < numSpaces; i++) {
leadingText += " ";
}
return leadingText;
});
text = text.replace(/¨A/g, " ");
text = text.replace(/¨B/g, "");
text = globals.converter._dispatch("detab.after", text, options, globals);
return text;
});
showdown2.subParser("ellipsis", function(text, options, globals) {
"use strict";
if (!options.ellipsis) {
return text;
}
text = globals.converter._dispatch("ellipsis.before", text, options, globals);
text = text.replace(/\.\.\./g, "\u2026");
text = globals.converter._dispatch("ellipsis.after", text, options, globals);
return text;
});
showdown2.subParser("emoji", function(text, options, globals) {
"use strict";
if (!options.emoji) {
return text;
}
text = globals.converter._dispatch("emoji.before", text, options, globals);
var emojiRgx = /:([\S]+?):/g;
text = text.replace(emojiRgx, function(wm, emojiCode) {
if (showdown2.helper.emojis.hasOwnProperty(emojiCode)) {
return showdown2.helper.emojis[emojiCode];
}
return wm;
});
text = globals.converter._dispatch("emoji.after", text, options, globals);
return text;
});
showdown2.subParser("encodeAmpsAndAngles", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("encodeAmpsAndAngles.before", text, options, globals);
text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, "&");
text = text.replace(/<(?![a-z\/?$!])/gi, "<");
text = text.replace(//g, ">");
text = globals.converter._dispatch("encodeAmpsAndAngles.after", text, options, globals);
return text;
});
showdown2.subParser("encodeBackslashEscapes", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("encodeBackslashEscapes.before", text, options, globals);
text = text.replace(/\\(\\)/g, showdown2.helper.escapeCharactersCallback);
text = text.replace(/\\([`*_{}\[\]()>#+.!~=|:-])/g, showdown2.helper.escapeCharactersCallback);
text = globals.converter._dispatch("encodeBackslashEscapes.after", text, options, globals);
return text;
});
showdown2.subParser("encodeCode", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("encodeCode.before", text, options, globals);
text = text.replace(/&/g, "&").replace(//g, ">").replace(/([*_{}\[\]\\=~-])/g, showdown2.helper.escapeCharactersCallback);
text = globals.converter._dispatch("encodeCode.after", text, options, globals);
return text;
});
showdown2.subParser("escapeSpecialCharsWithinTagAttributes", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("escapeSpecialCharsWithinTagAttributes.before", text, options, globals);
var tags = /<\/?[a-z\d_:-]+(?:[\s]+[\s\S]+?)?>/gi, comments = /-]|-[^>])(?:[^-]|-[^-])*)--)>/gi;
text = text.replace(tags, function(wholeMatch) {
return wholeMatch.replace(/(.)<\/?code>(?=.)/g, "$1`").replace(/([\\`*_~=|])/g, showdown2.helper.escapeCharactersCallback);
});
text = text.replace(comments, function(wholeMatch) {
return wholeMatch.replace(/([\\`*_~=|])/g, showdown2.helper.escapeCharactersCallback);
});
text = globals.converter._dispatch("escapeSpecialCharsWithinTagAttributes.after", text, options, globals);
return text;
});
showdown2.subParser("githubCodeBlocks", function(text, options, globals) {
"use strict";
if (!options.ghCodeBlocks) {
return text;
}
text = globals.converter._dispatch("githubCodeBlocks.before", text, options, globals);
text += "\xA80";
text = text.replace(/(?:^|\n)(?: {0,3})(```+|~~~+)(?: *)([^\s`~]*)\n([\s\S]*?)\n(?: {0,3})\1/g, function(wholeMatch, delim, language, codeblock) {
var end = options.omitExtraWLInCodeBlocks ? "" : "\n";
codeblock = showdown2.subParser("encodeCode")(codeblock, options, globals);
codeblock = showdown2.subParser("detab")(codeblock, options, globals);
codeblock = codeblock.replace(/^\n+/g, "");
codeblock = codeblock.replace(/\n+$/g, "");
codeblock = "" + codeblock + end + "
";
codeblock = showdown2.subParser("hashBlock")(codeblock, options, globals);
return "\n\n\xA8G" + (globals.ghCodeBlocks.push({ text: wholeMatch, codeblock }) - 1) + "G\n\n";
});
text = text.replace(/¨0/, "");
return globals.converter._dispatch("githubCodeBlocks.after", text, options, globals);
});
showdown2.subParser("hashBlock", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("hashBlock.before", text, options, globals);
text = text.replace(/(^\n+|\n+$)/g, "");
text = "\n\n\xA8K" + (globals.gHtmlBlocks.push(text) - 1) + "K\n\n";
text = globals.converter._dispatch("hashBlock.after", text, options, globals);
return text;
});
showdown2.subParser("hashCodeTags", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("hashCodeTags.before", text, options, globals);
var repFunc = function(wholeMatch, match, left, right) {
var codeblock = left + showdown2.subParser("encodeCode")(match, options, globals) + right;
return "\xA8C" + (globals.gHtmlSpans.push(codeblock) - 1) + "C";
};
text = showdown2.helper.replaceRecursiveRegExp(text, repFunc, "]*>", "", "gim");
text = globals.converter._dispatch("hashCodeTags.after", text, options, globals);
return text;
});
showdown2.subParser("hashElement", function(text, options, globals) {
"use strict";
return function(wholeMatch, m1) {
var blockText = m1;
blockText = blockText.replace(/\n\n/g, "\n");
blockText = blockText.replace(/^\n/, "");
blockText = blockText.replace(/\n+$/g, "");
blockText = "\n\n\xA8K" + (globals.gHtmlBlocks.push(blockText) - 1) + "K\n\n";
return blockText;
};
});
showdown2.subParser("hashHTMLBlocks", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("hashHTMLBlocks.before", text, options, globals);
var blockTags = [
"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"
], repFunc = function(wholeMatch, match, left, right) {
var txt = wholeMatch;
if (left.search(/\bmarkdown\b/) !== -1) {
txt = left + globals.converter.makeHtml(match) + right;
}
return "\n\n\xA8K" + (globals.gHtmlBlocks.push(txt) - 1) + "K\n\n";
};
if (options.backslashEscapesHTMLTags) {
text = text.replace(/\\<(\/?[^>]+?)>/g, function(wm, inside) {
return "<" + inside + ">";
});
}
for (var i = 0; i < blockTags.length; ++i) {
var opTagPos, rgx1 = new RegExp("^ {0,3}(<" + blockTags[i] + "\\b[^>]*>)", "im"), patLeft = "<" + blockTags[i] + "\\b[^>]*>", patRight = "" + blockTags[i] + ">";
while ((opTagPos = showdown2.helper.regexIndexOf(text, rgx1)) !== -1) {
var subTexts = showdown2.helper.splitAtIndex(text, opTagPos), newSubText1 = showdown2.helper.replaceRecursiveRegExp(subTexts[1], repFunc, patLeft, patRight, "im");
if (newSubText1 === subTexts[1]) {
break;
}
text = subTexts[0].concat(newSubText1);
}
}
text = text.replace(/(\n {0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g, showdown2.subParser("hashElement")(text, options, globals));
text = showdown2.helper.replaceRecursiveRegExp(text, function(txt) {
return "\n\n\xA8K" + (globals.gHtmlBlocks.push(txt) - 1) + "K\n\n";
}, "^ {0,3}", "gm");
text = text.replace(/(?:\n\n)( {0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g, showdown2.subParser("hashElement")(text, options, globals));
text = globals.converter._dispatch("hashHTMLBlocks.after", text, options, globals);
return text;
});
showdown2.subParser("hashHTMLSpans", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("hashHTMLSpans.before", text, options, globals);
function hashHTMLSpan(html) {
return "\xA8C" + (globals.gHtmlSpans.push(html) - 1) + "C";
}
text = text.replace(/<[^>]+?\/>/gi, function(wm) {
return hashHTMLSpan(wm);
});
text = text.replace(/<([^>]+?)>[\s\S]*?<\/\1>/g, function(wm) {
return hashHTMLSpan(wm);
});
text = text.replace(/<([^>]+?)\s[^>]+?>[\s\S]*?<\/\1>/g, function(wm) {
return hashHTMLSpan(wm);
});
text = text.replace(/<[^>]+?>/gi, function(wm) {
return hashHTMLSpan(wm);
});
text = globals.converter._dispatch("hashHTMLSpans.after", text, options, globals);
return text;
});
showdown2.subParser("unhashHTMLSpans", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("unhashHTMLSpans.before", text, options, globals);
for (var i = 0; i < globals.gHtmlSpans.length; ++i) {
var repText = globals.gHtmlSpans[i], limit = 0;
while (/¨C(\d+)C/.test(repText)) {
var num = RegExp.$1;
repText = repText.replace("\xA8C" + num + "C", globals.gHtmlSpans[num]);
if (limit === 10) {
console.error("maximum nesting of 10 spans reached!!!");
break;
}
++limit;
}
text = text.replace("\xA8C" + i + "C", repText);
}
text = globals.converter._dispatch("unhashHTMLSpans.after", text, options, globals);
return text;
});
showdown2.subParser("hashPreCodeTags", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("hashPreCodeTags.before", text, options, globals);
var repFunc = function(wholeMatch, match, left, right) {
var codeblock = left + showdown2.subParser("encodeCode")(match, options, globals) + right;
return "\n\n\xA8G" + (globals.ghCodeBlocks.push({ text: wholeMatch, codeblock }) - 1) + "G\n\n";
};
text = showdown2.helper.replaceRecursiveRegExp(text, repFunc, "^ {0,3}]*>\\s*]*>", "^ {0,3}\\s*
", "gim");
text = globals.converter._dispatch("hashPreCodeTags.after", text, options, globals);
return text;
});
showdown2.subParser("headers", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("headers.before", text, options, globals);
var headerLevelStart = isNaN(parseInt(options.headerLevelStart)) ? 1 : parseInt(options.headerLevelStart), setextRegexH1 = options.smoothLivePreview ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm, setextRegexH2 = options.smoothLivePreview ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm;
text = text.replace(setextRegexH1, function(wholeMatch, m1) {
var spanGamut = showdown2.subParser("spanGamut")(m1, options, globals), hID = options.noHeaderId ? "" : ' id="' + headerId(m1) + '"', hLevel = headerLevelStart, hashBlock = "" + spanGamut + " ";
return showdown2.subParser("hashBlock")(hashBlock, options, globals);
});
text = text.replace(setextRegexH2, function(matchFound, m1) {
var spanGamut = showdown2.subParser("spanGamut")(m1, options, globals), hID = options.noHeaderId ? "" : ' id="' + headerId(m1) + '"', hLevel = headerLevelStart + 1, hashBlock = "" + spanGamut + " ";
return showdown2.subParser("hashBlock")(hashBlock, options, globals);
});
var atxStyle = options.requireSpaceBeforeHeadingText ? /^(#{1,6})[ \t]+(.+?)[ \t]*#*\n+/gm : /^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm;
text = text.replace(atxStyle, function(wholeMatch, m1, m2) {
var hText = m2;
if (options.customizedHeaderId) {
hText = m2.replace(/\s?\{([^{]+?)}\s*$/, "");
}
var span = showdown2.subParser("spanGamut")(hText, options, globals), hID = options.noHeaderId ? "" : ' id="' + headerId(m2) + '"', hLevel = headerLevelStart - 1 + m1.length, header = "" + span + " ";
return showdown2.subParser("hashBlock")(header, options, globals);
});
function headerId(m) {
var title, prefix;
if (options.customizedHeaderId) {
var match = m.match(/\{([^{]+?)}\s*$/);
if (match && match[1]) {
m = match[1];
}
}
title = m;
if (showdown2.helper.isString(options.prefixHeaderId)) {
prefix = options.prefixHeaderId;
} else if (options.prefixHeaderId === true) {
prefix = "section-";
} else {
prefix = "";
}
if (!options.rawPrefixHeaderId) {
title = prefix + title;
}
if (options.ghCompatibleHeaderId) {
title = title.replace(/ /g, "-").replace(/&/g, "").replace(/¨T/g, "").replace(/¨D/g, "").replace(/[&+$,\/:;=?@"#{}|^¨~\[\]`\\*)(%.!'<>]/g, "").toLowerCase();
} else if (options.rawHeaderId) {
title = title.replace(/ /g, "-").replace(/&/g, "&").replace(/¨T/g, "\xA8").replace(/¨D/g, "$").replace(/["']/g, "-").toLowerCase();
} else {
title = title.replace(/[^\w]/g, "").toLowerCase();
}
if (options.rawPrefixHeaderId) {
title = prefix + title;
}
if (globals.hashLinkCounts[title]) {
title = title + "-" + globals.hashLinkCounts[title]++;
} else {
globals.hashLinkCounts[title] = 1;
}
return title;
}
text = globals.converter._dispatch("headers.after", text, options, globals);
return text;
});
showdown2.subParser("horizontalRule", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("horizontalRule.before", text, options, globals);
var key = showdown2.subParser("hashBlock")("
", options, globals);
text = text.replace(/^ {0,2}( ?-){3,}[ \t]*$/gm, key);
text = text.replace(/^ {0,2}( ?\*){3,}[ \t]*$/gm, key);
text = text.replace(/^ {0,2}( ?_){3,}[ \t]*$/gm, key);
text = globals.converter._dispatch("horizontalRule.after", text, options, globals);
return text;
});
showdown2.subParser("images", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("images.before", text, options, globals);
var inlineRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?([\S]+?(?:\([\S]*?\)[\S]*?)?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(["'])([^"]*?)\6)?[ \t]?\)/g, crazyRegExp = /!\[([^\]]*?)][ \t]*()\([ \t]?<([^>]*)>(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(?:(["'])([^"]*?)\6))?[ \t]?\)/g, base64RegExp = /!\[([^\]]*?)][ \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, referenceRegExp = /!\[([^\]]*?)] ?(?:\n *)?\[([\s\S]*?)]()()()()()/g, refShortcutRegExp = /!\[([^\[\]]+)]()()()()()/g;
function writeImageTagBase64(wholeMatch, altText, linkId, url, width, height, m5, title) {
url = url.replace(/\s/g, "");
return writeImageTag(wholeMatch, altText, linkId, url, width, height, m5, title);
}
function writeImageTag(wholeMatch, altText, linkId, url, width, height, m5, title) {
var gUrls = globals.gUrls, gTitles = globals.gTitles, gDims = globals.gDimensions;
linkId = linkId.toLowerCase();
if (!title) {
title = "";
}
if (wholeMatch.search(/\(\s*>? ?(['"].*['"])?\)$/m) > -1) {
url = "";
} else if (url === "" || url === null) {
if (linkId === "" || linkId === null) {
linkId = altText.toLowerCase().replace(/ ?\n/g, " ");
}
url = "#" + linkId;
if (!showdown2.helper.isUndefined(gUrls[linkId])) {
url = gUrls[linkId];
if (!showdown2.helper.isUndefined(gTitles[linkId])) {
title = gTitles[linkId];
}
if (!showdown2.helper.isUndefined(gDims[linkId])) {
width = gDims[linkId].width;
height = gDims[linkId].height;
}
} else {
return wholeMatch;
}
}
altText = altText.replace(/"/g, """).replace(showdown2.helper.regexes.asteriskDashAndColon, showdown2.helper.escapeCharactersCallback);
url = url.replace(showdown2.helper.regexes.asteriskDashAndColon, showdown2.helper.escapeCharactersCallback);
var result = '
";
return result;
}
text = text.replace(referenceRegExp, writeImageTag);
text = text.replace(base64RegExp, writeImageTagBase64);
text = text.replace(crazyRegExp, writeImageTag);
text = text.replace(inlineRegExp, writeImageTag);
text = text.replace(refShortcutRegExp, writeImageTag);
text = globals.converter._dispatch("images.after", text, options, globals);
return text;
});
showdown2.subParser("italicsAndBold", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("italicsAndBold.before", text, options, globals);
function parseInside(txt, left, right) {
return left + txt + right;
}
if (options.literalMidWordUnderscores) {
text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function(wm, txt) {
return parseInside(txt, "", "");
});
text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function(wm, txt) {
return parseInside(txt, "", "");
});
text = text.replace(/\b_(\S[\s\S]*?)_\b/g, function(wm, txt) {
return parseInside(txt, "", "");
});
} else {
text = text.replace(/___(\S[\s\S]*?)___/g, function(wm, m) {
return /\S$/.test(m) ? parseInside(m, "", "") : wm;
});
text = text.replace(/__(\S[\s\S]*?)__/g, function(wm, m) {
return /\S$/.test(m) ? parseInside(m, "", "") : wm;
});
text = text.replace(/_([^\s_][\s\S]*?)_/g, function(wm, m) {
return /\S$/.test(m) ? parseInside(m, "", "") : wm;
});
}
if (options.literalMidWordAsterisks) {
text = text.replace(/([^*]|^)\B\*\*\*(\S[\s\S]*?)\*\*\*\B(?!\*)/g, function(wm, lead, txt) {
return parseInside(txt, lead + "", "");
});
text = text.replace(/([^*]|^)\B\*\*(\S[\s\S]*?)\*\*\B(?!\*)/g, function(wm, lead, txt) {
return parseInside(txt, lead + "", "");
});
text = text.replace(/([^*]|^)\B\*(\S[\s\S]*?)\*\B(?!\*)/g, function(wm, lead, txt) {
return parseInside(txt, lead + "", "");
});
} else {
text = text.replace(/\*\*\*(\S[\s\S]*?)\*\*\*/g, function(wm, m) {
return /\S$/.test(m) ? parseInside(m, "", "") : wm;
});
text = text.replace(/\*\*(\S[\s\S]*?)\*\*/g, function(wm, m) {
return /\S$/.test(m) ? parseInside(m, "", "") : wm;
});
text = text.replace(/\*([^\s*][\s\S]*?)\*/g, function(wm, m) {
return /\S$/.test(m) ? parseInside(m, "", "") : wm;
});
}
text = globals.converter._dispatch("italicsAndBold.after", text, options, globals);
return text;
});
showdown2.subParser("lists", function(text, options, globals) {
"use strict";
function processListItems(listStr, trimTrailing) {
globals.gListLevel++;
listStr = listStr.replace(/\n{2,}$/, "\n");
listStr += "\xA80";
var rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0| {0,3}([*+-]|\d+[.])[ \t]+))/gm, isParagraphed = /\n[ \t]*\n(?!¨0)/.test(listStr);
if (options.disableForced4SpacesIndentedSublists) {
rgx = /(\n)?(^ {0,3})([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(¨0|\2([*+-]|\d+[.])[ \t]+))/gm;
}
listStr = listStr.replace(rgx, function(wholeMatch, m1, m2, m3, m4, taskbtn, checked) {
checked = checked && checked.trim() !== "";
var item = showdown2.subParser("outdent")(m4, options, globals), bulletStyle = "";
if (taskbtn && options.tasklists) {
bulletStyle = ' class="task-list-item" style="list-style-type: none;"';
item = item.replace(/^[ \t]*\[(x|X| )?]/m, function() {
var otp = '";
return otp;
});
}
item = item.replace(/^([-*+]|\d\.)[ \t]+[\S\n ]*/g, function(wm2) {
return "\xA8A" + wm2;
});
if (m1 || item.search(/\n{2,}/) > -1) {
item = showdown2.subParser("githubCodeBlocks")(item, options, globals);
item = showdown2.subParser("blockGamut")(item, options, globals);
} else {
item = showdown2.subParser("lists")(item, options, globals);
item = item.replace(/\n$/, "");
item = showdown2.subParser("hashHTMLBlocks")(item, options, globals);
item = item.replace(/\n\n+/g, "\n\n");
if (isParagraphed) {
item = showdown2.subParser("paragraphs")(item, options, globals);
} else {
item = showdown2.subParser("spanGamut")(item, options, globals);
}
}
item = item.replace("\xA8A", "");
item = ""); str += "
"; grafsOut.push(str); } } end = grafsOut.length; for (i = 0; i < end; i++) { var blockText = "", grafsOutIt = grafsOut[i], codeFlag = false; while (/¨(K|G)(\d+)\1/.test(grafsOutIt)) { var delim = RegExp.$1, num = RegExp.$2; if (delim === "K") { blockText = globals.gHtmlBlocks[num]; } else { if (codeFlag) { blockText = showdown2.subParser("encodeCode")(globals.ghCodeBlocks[num].text, options, globals); } else { blockText = globals.ghCodeBlocks[num].codeblock; } } blockText = blockText.replace(/\$/g, "$$$$"); grafsOutIt = grafsOutIt.replace(/(\n\n)?¨(K|G)\d+\2(\n\n)?/, blockText); if (/^]*>\s*]*>/.test(grafsOutIt)) {
codeFlag = true;
}
}
grafsOut[i] = grafsOutIt;
}
text = grafsOut.join("\n");
text = text.replace(/^\n+/g, "");
text = text.replace(/\n+$/g, "");
return globals.converter._dispatch("paragraphs.after", text, options, globals);
});
showdown2.subParser("runExtension", function(ext, text, options, globals) {
"use strict";
if (ext.filter) {
text = ext.filter(text, globals.converter, options);
} else if (ext.regex) {
var re = ext.regex;
if (!(re instanceof RegExp)) {
re = new RegExp(re, "g");
}
text = text.replace(re, ext.replace);
}
return text;
});
showdown2.subParser("spanGamut", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("spanGamut.before", text, options, globals);
text = showdown2.subParser("codeSpans")(text, options, globals);
text = showdown2.subParser("escapeSpecialCharsWithinTagAttributes")(text, options, globals);
text = showdown2.subParser("encodeBackslashEscapes")(text, options, globals);
text = showdown2.subParser("images")(text, options, globals);
text = showdown2.subParser("anchors")(text, options, globals);
text = showdown2.subParser("autoLinks")(text, options, globals);
text = showdown2.subParser("simplifiedAutoLinks")(text, options, globals);
text = showdown2.subParser("emoji")(text, options, globals);
text = showdown2.subParser("underline")(text, options, globals);
text = showdown2.subParser("italicsAndBold")(text, options, globals);
text = showdown2.subParser("strikethrough")(text, options, globals);
text = showdown2.subParser("ellipsis")(text, options, globals);
text = showdown2.subParser("hashHTMLSpans")(text, options, globals);
text = showdown2.subParser("encodeAmpsAndAngles")(text, options, globals);
if (options.simpleLineBreaks) {
if (!/\n\n¨K/.test(text)) {
text = text.replace(/\n+/g, "
\n");
}
} else {
text = text.replace(/ +\n/g, "
\n");
}
text = globals.converter._dispatch("spanGamut.after", text, options, globals);
return text;
});
showdown2.subParser("strikethrough", function(text, options, globals) {
"use strict";
function parseInside(txt) {
if (options.simplifiedAutoLink) {
txt = showdown2.subParser("simplifiedAutoLinks")(txt, options, globals);
}
return "" + txt + "";
}
if (options.strikethrough) {
text = globals.converter._dispatch("strikethrough.before", text, options, globals);
text = text.replace(/(?:~){2}([\s\S]+?)(?:~){2}/g, function(wm, txt) {
return parseInside(txt);
});
text = globals.converter._dispatch("strikethrough.after", text, options, globals);
}
return text;
});
showdown2.subParser("stripLinkDefinitions", function(text, options, globals) {
"use strict";
var regex = /^ {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, base64Regex = /^ {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;
text += "\xA80";
var replaceFunc = function(wholeMatch, linkId, url, width, height, blankLines, title) {
linkId = linkId.toLowerCase();
if (text.toLowerCase().split(linkId).length - 1 < 2) {
return wholeMatch;
}
if (url.match(/^data:.+?\/.+?;base64,/)) {
globals.gUrls[linkId] = url.replace(/\s/g, "");
} else {
globals.gUrls[linkId] = showdown2.subParser("encodeAmpsAndAngles")(url, options, globals);
}
if (blankLines) {
return blankLines + title;
} else {
if (title) {
globals.gTitles[linkId] = title.replace(/"|'/g, """);
}
if (options.parseImgDimensions && width && height) {
globals.gDimensions[linkId] = {
width,
height
};
}
}
return "";
};
text = text.replace(base64Regex, replaceFunc);
text = text.replace(regex, replaceFunc);
text = text.replace(/¨0/, "");
return text;
});
showdown2.subParser("tables", function(text, options, globals) {
"use strict";
if (!options.tables) {
return text;
}
var tableRgx = /^ {0,3}\|?.+\|.+\n {0,3}\|?[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:[-=]){2,}[\s\S]+?(?:\n\n|¨0)/gm, singeColTblRgx = /^ {0,3}\|.+\|[ \t]*\n {0,3}\|[ \t]*:?[ \t]*(?:[-=]){2,}[ \t]*:?[ \t]*\|[ \t]*\n( {0,3}\|.+\|[ \t]*\n)*(?:\n|¨0)/gm;
function parseStyles(sLine) {
if (/^:[ \t]*--*$/.test(sLine)) {
return ' style="text-align:left;"';
} else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
return ' style="text-align:right;"';
} else if (/^:[ \t]*--*[ \t]*:$/.test(sLine)) {
return ' style="text-align:center;"';
} else {
return "";
}
}
function parseHeaders(header, style) {
var id = "";
header = header.trim();
if (options.tablesHeaderId || options.tableHeaderId) {
id = ' id="' + header.replace(/ /g, "_").toLowerCase() + '"';
}
header = showdown2.subParser("spanGamut")(header, options, globals);
return "" + header + " \n";
}
function parseCells(cell, style) {
var subText = showdown2.subParser("spanGamut")(cell, options, globals);
return "" + subText + " \n";
}
function buildTable(headers, cells) {
var tb = "\n\n\n", tblLgn = headers.length;
for (var i = 0; i < tblLgn; ++i) {
tb += headers[i];
}
tb += " \n\n\n";
for (i = 0; i < cells.length; ++i) {
tb += "\n";
for (var ii = 0; ii < tblLgn; ++ii) {
tb += cells[i][ii];
}
tb += " \n";
}
tb += "\n
\n";
return tb;
}
function parseTable(rawTable) {
var i, tableLines = rawTable.split("\n");
for (i = 0; i < tableLines.length; ++i) {
if (/^ {0,3}\|/.test(tableLines[i])) {
tableLines[i] = tableLines[i].replace(/^ {0,3}\|/, "");
}
if (/\|[ \t]*$/.test(tableLines[i])) {
tableLines[i] = tableLines[i].replace(/\|[ \t]*$/, "");
}
tableLines[i] = showdown2.subParser("codeSpans")(tableLines[i], options, globals);
}
var rawHeaders = tableLines[0].split("|").map(function(s) {
return s.trim();
}), rawStyles = tableLines[1].split("|").map(function(s) {
return s.trim();
}), rawCells = [], headers = [], styles = [], cells = [];
tableLines.shift();
tableLines.shift();
for (i = 0; i < tableLines.length; ++i) {
if (tableLines[i].trim() === "") {
continue;
}
rawCells.push(tableLines[i].split("|").map(function(s) {
return s.trim();
}));
}
if (rawHeaders.length < rawStyles.length) {
return rawTable;
}
for (i = 0; i < rawStyles.length; ++i) {
styles.push(parseStyles(rawStyles[i]));
}
for (i = 0; i < rawHeaders.length; ++i) {
if (showdown2.helper.isUndefined(styles[i])) {
styles[i] = "";
}
headers.push(parseHeaders(rawHeaders[i], styles[i]));
}
for (i = 0; i < rawCells.length; ++i) {
var row = [];
for (var ii = 0; ii < headers.length; ++ii) {
if (showdown2.helper.isUndefined(rawCells[i][ii])) {
}
row.push(parseCells(rawCells[i][ii], styles[ii]));
}
cells.push(row);
}
return buildTable(headers, cells);
}
text = globals.converter._dispatch("tables.before", text, options, globals);
text = text.replace(/\\(\|)/g, showdown2.helper.escapeCharactersCallback);
text = text.replace(tableRgx, parseTable);
text = text.replace(singeColTblRgx, parseTable);
text = globals.converter._dispatch("tables.after", text, options, globals);
return text;
});
showdown2.subParser("underline", function(text, options, globals) {
"use strict";
if (!options.underline) {
return text;
}
text = globals.converter._dispatch("underline.before", text, options, globals);
if (options.literalMidWordUnderscores) {
text = text.replace(/\b___(\S[\s\S]*?)___\b/g, function(wm, txt) {
return "" + txt + "";
});
text = text.replace(/\b__(\S[\s\S]*?)__\b/g, function(wm, txt) {
return "" + txt + "";
});
} else {
text = text.replace(/___(\S[\s\S]*?)___/g, function(wm, m) {
return /\S$/.test(m) ? "" + m + "" : wm;
});
text = text.replace(/__(\S[\s\S]*?)__/g, function(wm, m) {
return /\S$/.test(m) ? "" + m + "" : wm;
});
}
text = text.replace(/(_)/g, showdown2.helper.escapeCharactersCallback);
text = globals.converter._dispatch("underline.after", text, options, globals);
return text;
});
showdown2.subParser("unescapeSpecialChars", function(text, options, globals) {
"use strict";
text = globals.converter._dispatch("unescapeSpecialChars.before", text, options, globals);
text = text.replace(/¨E(\d+)E/g, function(wholeMatch, m1) {
var charCodeToReplace = parseInt(m1);
return String.fromCharCode(charCodeToReplace);
});
text = globals.converter._dispatch("unescapeSpecialChars.after", text, options, globals);
return text;
});
showdown2.subParser("makeMarkdown.blockquote", function(node, globals) {
"use strict";
var txt = "";
if (node.hasChildNodes()) {
var children = node.childNodes, childrenLength = children.length;
for (var i = 0; i < childrenLength; ++i) {
var innerTxt = showdown2.subParser("makeMarkdown.node")(children[i], globals);
if (innerTxt === "") {
continue;
}
txt += innerTxt;
}
}
txt = txt.trim();
txt = "> " + txt.split("\n").join("\n> ");
return txt;
});
showdown2.subParser("makeMarkdown.codeBlock", function(node, globals) {
"use strict";
var lang = node.getAttribute("language"), num = node.getAttribute("precodenum");
return "```" + lang + "\n" + globals.preList[num] + "\n```";
});
showdown2.subParser("makeMarkdown.codeSpan", function(node) {
"use strict";
return "`" + node.innerHTML + "`";
});
showdown2.subParser("makeMarkdown.emphasis", function(node, globals) {
"use strict";
var txt = "";
if (node.hasChildNodes()) {
txt += "*";
var children = node.childNodes, childrenLength = children.length;
for (var i = 0; i < childrenLength; ++i) {
txt += showdown2.subParser("makeMarkdown.node")(children[i], globals);
}
txt += "*";
}
return txt;
});
showdown2.subParser("makeMarkdown.header", function(node, globals, headerLevel) {
"use strict";
var headerMark = new Array(headerLevel + 1).join("#"), txt = "";
if (node.hasChildNodes()) {
txt = headerMark + " ";
var children = node.childNodes, childrenLength = children.length;
for (var i = 0; i < childrenLength; ++i) {
txt += showdown2.subParser("makeMarkdown.node")(children[i], globals);
}
}
return txt;
});
showdown2.subParser("makeMarkdown.hr", function() {
"use strict";
return "---";
});
showdown2.subParser("makeMarkdown.image", function(node) {
"use strict";
var txt = "";
if (node.hasAttribute("src")) {
txt += " + ">";
if (node.hasAttribute("width") && node.hasAttribute("height")) {
txt += " =" + node.getAttribute("width") + "x" + node.getAttribute("height");
}
if (node.hasAttribute("title")) {
txt += ' "' + node.getAttribute("title") + '"';
}
txt += ")";
}
return txt;
});
showdown2.subParser("makeMarkdown.links", function(node, globals) {
"use strict";
var txt = "";
if (node.hasChildNodes() && node.hasAttribute("href")) {
var children = node.childNodes, childrenLength = children.length;
txt = "[";
for (var i = 0; i < childrenLength; ++i) {
txt += showdown2.subParser("makeMarkdown.node")(children[i], globals);
}
txt += "](";
txt += "<" + node.getAttribute("href") + ">";
if (node.hasAttribute("title")) {
txt += ' "' + node.getAttribute("title") + '"';
}
txt += ")";
}
return txt;
});
showdown2.subParser("makeMarkdown.list", function(node, globals, type) {
"use strict";
var txt = "";
if (!node.hasChildNodes()) {
return "";
}
var listItems = node.childNodes, listItemsLenght = listItems.length, listNum = node.getAttribute("start") || 1;
for (var i = 0; i < listItemsLenght; ++i) {
if (typeof listItems[i].tagName === "undefined" || listItems[i].tagName.toLowerCase() !== "li") {
continue;
}
var bullet = "";
if (type === "ol") {
bullet = listNum.toString() + ". ";
} else {
bullet = "- ";
}
txt += bullet + showdown2.subParser("makeMarkdown.listItem")(listItems[i], globals);
++listNum;
}
txt += "\n\n";
return txt.trim();
});
showdown2.subParser("makeMarkdown.listItem", function(node, globals) {
"use strict";
var listItemTxt = "";
var children = node.childNodes, childrenLenght = children.length;
for (var i = 0; i < childrenLenght; ++i) {
listItemTxt += showdown2.subParser("makeMarkdown.node")(children[i], globals);
}
if (!/\n$/.test(listItemTxt)) {
listItemTxt += "\n";
} else {
listItemTxt = listItemTxt.split("\n").join("\n ").replace(/^ {4}$/gm, "").replace(/\n\n+/g, "\n\n");
}
return listItemTxt;
});
showdown2.subParser("makeMarkdown.node", function(node, globals, spansOnly) {
"use strict";
spansOnly = spansOnly || false;
var txt = "";
if (node.nodeType === 3) {
return showdown2.subParser("makeMarkdown.txt")(node, globals);
}
if (node.nodeType === 8) {
return "\n\n";
}
if (node.nodeType !== 1) {
return "";
}
var tagName = node.tagName.toLowerCase();
switch (tagName) {
case "h1":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.header")(node, globals, 1) + "\n\n";
}
break;
case "h2":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.header")(node, globals, 2) + "\n\n";
}
break;
case "h3":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.header")(node, globals, 3) + "\n\n";
}
break;
case "h4":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.header")(node, globals, 4) + "\n\n";
}
break;
case "h5":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.header")(node, globals, 5) + "\n\n";
}
break;
case "h6":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.header")(node, globals, 6) + "\n\n";
}
break;
case "p":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.paragraph")(node, globals) + "\n\n";
}
break;
case "blockquote":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.blockquote")(node, globals) + "\n\n";
}
break;
case "hr":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.hr")(node, globals) + "\n\n";
}
break;
case "ol":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.list")(node, globals, "ol") + "\n\n";
}
break;
case "ul":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.list")(node, globals, "ul") + "\n\n";
}
break;
case "precode":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.codeBlock")(node, globals) + "\n\n";
}
break;
case "pre":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.pre")(node, globals) + "\n\n";
}
break;
case "table":
if (!spansOnly) {
txt = showdown2.subParser("makeMarkdown.table")(node, globals) + "\n\n";
}
break;
case "code":
txt = showdown2.subParser("makeMarkdown.codeSpan")(node, globals);
break;
case "em":
case "i":
txt = showdown2.subParser("makeMarkdown.emphasis")(node, globals);
break;
case "strong":
case "b":
txt = showdown2.subParser("makeMarkdown.strong")(node, globals);
break;
case "del":
txt = showdown2.subParser("makeMarkdown.strikethrough")(node, globals);
break;
case "a":
txt = showdown2.subParser("makeMarkdown.links")(node, globals);
break;
case "img":
txt = showdown2.subParser("makeMarkdown.image")(node, globals);
break;
default:
txt = node.outerHTML + "\n\n";
}
return txt;
});
showdown2.subParser("makeMarkdown.paragraph", function(node, globals) {
"use strict";
var txt = "";
if (node.hasChildNodes()) {
var children = node.childNodes, childrenLength = children.length;
for (var i = 0; i < childrenLength; ++i) {
txt += showdown2.subParser("makeMarkdown.node")(children[i], globals);
}
}
txt = txt.trim();
return txt;
});
showdown2.subParser("makeMarkdown.pre", function(node, globals) {
"use strict";
var num = node.getAttribute("prenum");
return "" + globals.preList[num] + "
";
});
showdown2.subParser("makeMarkdown.strikethrough", function(node, globals) {
"use strict";
var txt = "";
if (node.hasChildNodes()) {
txt += "~~";
var children = node.childNodes, childrenLength = children.length;
for (var i = 0; i < childrenLength; ++i) {
txt += showdown2.subParser("makeMarkdown.node")(children[i], globals);
}
txt += "~~";
}
return txt;
});
showdown2.subParser("makeMarkdown.strong", function(node, globals) {
"use strict";
var txt = "";
if (node.hasChildNodes()) {
txt += "**";
var children = node.childNodes, childrenLength = children.length;
for (var i = 0; i < childrenLength; ++i) {
txt += showdown2.subParser("makeMarkdown.node")(children[i], globals);
}
txt += "**";
}
return txt;
});
showdown2.subParser("makeMarkdown.table", function(node, globals) {
"use strict";
var txt = "", tableArray = [[], []], headings = node.querySelectorAll("thead>tr>th"), rows = node.querySelectorAll("tbody>tr"), i, ii;
for (i = 0; i < headings.length; ++i) {
var headContent = showdown2.subParser("makeMarkdown.tableCell")(headings[i], globals), allign = "---";
if (headings[i].hasAttribute("style")) {
var style = headings[i].getAttribute("style").toLowerCase().replace(/\s/g, "");
switch (style) {
case "text-align:left;":
allign = ":---";
break;
case "text-align:right;":
allign = "---:";
break;
case "text-align:center;":
allign = ":---:";
break;
}
}
tableArray[0][i] = headContent.trim();
tableArray[1][i] = allign;
}
for (i = 0; i < rows.length; ++i) {
var r = tableArray.push([]) - 1, cols = rows[i].getElementsByTagName("td");
for (ii = 0; ii < headings.length; ++ii) {
var cellContent = " ";
if (typeof cols[ii] !== "undefined") {
cellContent = showdown2.subParser("makeMarkdown.tableCell")(cols[ii], globals);
}
tableArray[r].push(cellContent);
}
}
var cellSpacesCount = 3;
for (i = 0; i < tableArray.length; ++i) {
for (ii = 0; ii < tableArray[i].length; ++ii) {
var strLen = tableArray[i][ii].length;
if (strLen > cellSpacesCount) {
cellSpacesCount = strLen;
}
}
}
for (i = 0; i < tableArray.length; ++i) {
for (ii = 0; ii < tableArray[i].length; ++ii) {
if (i === 1) {
if (tableArray[i][ii].slice(-1) === ":") {
tableArray[i][ii] = showdown2.helper.padEnd(tableArray[i][ii].slice(-1), cellSpacesCount - 1, "-") + ":";
} else {
tableArray[i][ii] = showdown2.helper.padEnd(tableArray[i][ii], cellSpacesCount, "-");
}
} else {
tableArray[i][ii] = showdown2.helper.padEnd(tableArray[i][ii], cellSpacesCount);
}
}
txt += "| " + tableArray[i].join(" | ") + " |\n";
}
return txt.trim();
});
showdown2.subParser("makeMarkdown.tableCell", function(node, globals) {
"use strict";
var txt = "";
if (!node.hasChildNodes()) {
return "";
}
var children = node.childNodes, childrenLength = children.length;
for (var i = 0; i < childrenLength; ++i) {
txt += showdown2.subParser("makeMarkdown.node")(children[i], globals, true);
}
return txt.trim();
});
showdown2.subParser("makeMarkdown.txt", function(node) {
"use strict";
var txt = node.nodeValue;
txt = txt.replace(/ +/g, " ");
txt = txt.replace(/¨NBSP;/g, " ");
txt = showdown2.helper.unescapeHTMLEntities(txt);
txt = txt.replace(/([*_~|`])/g, "\\$1");
txt = txt.replace(/^(\s*)>/g, "\\$1>");
txt = txt.replace(/^#/gm, "\\#");
txt = txt.replace(/^(\s*)([-=]{3,})(\s*)$/, "$1\\$2$3");
txt = txt.replace(/^( {0,3}\d+)\./gm, "$1\\.");
txt = txt.replace(/^( {0,3})([+-])/gm, "$1\\$2");
txt = txt.replace(/]([\s]*)\(/g, "\\]$1\\(");
txt = txt.replace(/^ {0,3}\[([\S \t]*?)]:/gm, "\\[$1]:");
return txt;
});
var root = this;
if (typeof define === "function" && define.amd) {
define(function() {
"use strict";
return showdown2;
});
} else if (typeof module2 !== "undefined" && module2.exports) {
module2.exports = showdown2;
} else {
root.showdown = showdown2;
}
}).call(exports);
}
});
// main.ts
__export(exports, {
default: () => MarkdownToHTML
});
var import_obsidian = __toModule(require("obsidian"));
var showdown = __toModule(require_showdown());
var DEFAULT_SETTINGS = {
removeBrackets: true,
removeEmphasis: false,
removeTags: false,
removeComments: false
};
var MarkdownToHTML = class extends import_obsidian.Plugin {
onload() {
return __async(this, null, function* () {
yield this.loadSettings();
this.addCommand({
id: "copy-as-html-command",
name: "Copy as HTML command",
editorCallback: (editor) => this.markdownToHTML(editor)
});
this.addSettingTab(new MarkdownToHTMLSettingTab(this.app, this));
});
}
markdownToHTML(editor) {
const converter = new showdown.Converter();
converter.setFlavor("github");
converter.setOption("ellipsis", false);
let text = editor.getSelection();
text = text.replace(/==/g, "");
text = text.replace(/\^\w+/g, "");
if (this.settings.removeBrackets) {
text = text.replace(/\[\[(.*?)\]\]/g, "$1");
}
if (this.settings.removeEmphasis) {
text = text.replace(/[*~]+(\w+)[*~]+/g, "$1");
}
if (this.settings.removeTags) {
text = text.replace(/#\w+/g, "");
}
if (this.settings.removeComments) {
text = text.replace(/%%.+%%/g, "");
}
const html = converter.makeHtml(text).toString();
const withDivWrapper = `
${html}`;
const blob = new Blob([withDivWrapper], {
type: ["text/plain", "text/html"]
});
const data = [new ClipboardItem({
["text/plain"]: blob,
["text/html"]: blob
})];
navigator.clipboard.write(data);
}
loadSettings() {
return __async(this, null, function* () {
this.settings = Object.assign({}, DEFAULT_SETTINGS, yield this.loadData());
});
}
saveSettings() {
return __async(this, null, function* () {
yield this.saveData(this.settings);
});
}
onunload() {
}
};
var MarkdownToHTMLSettingTab = class extends import_obsidian.PluginSettingTab {
constructor(app, plugin) {
super(app, plugin);
this.plugin = plugin;
}
display() {
let { containerEl } = this;
containerEl.empty();
new import_obsidian.Setting(containerEl).setName("Remove Wikilink brackets").setDesc("If enabled, removes wikilink brackets from copied text.").addToggle((toggle) => toggle.setValue(this.plugin.settings.removeBrackets).onChange((value) => __async(this, null, function* () {
this.plugin.settings.removeBrackets = value;
yield this.plugin.saveSettings();
})));
new import_obsidian.Setting(containerEl).setName("Remove text emphasis").setDesc("If enabled, removes text styling such as bold, italics, and highlights.").addToggle((toggle) => toggle.setValue(this.plugin.settings.removeEmphasis).onChange((value) => __async(this, null, function* () {
this.plugin.settings.removeEmphasis = value;
yield this.plugin.saveSettings();
})));
new import_obsidian.Setting(containerEl).setName("Remove hashtags").setDesc("If enabled, removes text immediately after a hashtag.").addToggle((toggle) => toggle.setValue(this.plugin.settings.removeTags).onChange((value) => __async(this, null, function* () {
this.plugin.settings.removeTags = value;
yield this.plugin.saveSettings();
})));
new import_obsidian.Setting(containerEl).setName("Remove comments").setDesc("If enabled, removes commented text.").addToggle((toggle) => toggle.setValue(this.plugin.settings.removeComments).onChange((value) => __async(this, null, function* () {
this.plugin.settings.removeComments = value;
yield this.plugin.saveSettings();
})));
}
};
/*! showdown v 2.1.0 - 21-04-2022 */
/* nosourcemap */