s in one line, based on `this._rangesInLine`
+ * @returns line changed or not
+ */
+ HideToken.prototype.procLine = function (line, pre) {
+ var cm = this.cm;
+ var lineNo = typeof line === "number" ? line : line.lineNo();
+ if (typeof line === "number") line = cm.getLineHandle(line);
+ var rangesInLine = this._rangesInLine[lineNo] || [];
+ var lv = core_1.cm_internal.findViewForLine(cm, lineNo);
+ if (!lv || lv.hidden || !lv.measure) return false;
+ if (!pre) pre = lv.text;
+ if (!pre) return false;
+ var mapInfo = core_1.cm_internal.mapFromLineView(lv, line, lineNo);
+ if (!mapInfo) return;
+ var map = mapInfo.map;
+ var nodeCount = map.length / 3;
+ var changed = false;
+ // change line status
+ if (rangesInLine.length === 0) {
+ // inactiveLine
+ if (addClass(pre, lineInactiveClassName)) changed = true;
+ } else {
+ // activeLine
+ if (rmClass(pre, lineInactiveClassName)) changed = true;
+ }
+ // show or hide tokens
+ /**
+ * @returns if there are Span Nodes changed
+ */
+ function changeVisibilityForSpan(span, shallHideTokens, iNodeHint) {
+ var changed = false;
+ iNodeHint = iNodeHint || 0;
+ // iterate the map
+ for (var i = iNodeHint; i < nodeCount; i++) {
+ var begin = map[i * 3];
+ map[i * 3 + 1];
+ var domNode = map[i * 3 + 2];
+ if (begin === span.head.start) {
+ // find the leading token!
+ if (/formatting-/.test(span.head.type) && domNode.nodeType === Node.TEXT_NODE) {
+ // good. this token can be changed
+ var domParent = domNode.parentElement;
+ if (shallHideTokens ? addClass(domParent, hideClassName) : rmClass(domParent, hideClassName)) {
+ changed = true;
+ }
+ if (domParent && domParent.classList && domParent.classList.contains("cm-formatting-task")) {
+ if (!domParent.dataset.hasOwnProperty("task")) {
+ domParent.dataset.task = domNode.textContent.substring(1, 2);
+ changed = true;
+ }
+ }
+ if (
+ domParent.nextElementSibling &&
+ domParent.nextElementSibling.classList.contains("cm-internal-link-url")
+ ) {
+ if (
+ shallHideTokens
+ ? addClass(domParent.nextElementSibling, hideClassName)
+ : rmClass(domParent.nextElementSibling, hideClassName)
+ ) {
+ changed = true;
+ }
+ }
+ if (
+ domParent.nextElementSibling &&
+ domParent.nextElementSibling.nextElementSibling &&
+ domParent.nextElementSibling.nextElementSibling.classList.contains("cm-internal-link-ref")
+ ) {
+ if (
+ shallHideTokens
+ ? addClass(domParent.nextElementSibling.nextElementSibling, hideClassName)
+ : rmClass(domParent.nextElementSibling.nextElementSibling, hideClassName)
+ ) {
+ changed = true;
+ }
+ }
+ }
+ //FIXME: if leading formatting token is separated into two, the latter will not be hidden/shown!
+ // search for the tailing token
+ if (span.tail && /formatting-/.test(span.tail.type)) {
+ for (var j = i + 1; j < nodeCount; j++) {
+ var begin_1 = map[j * 3];
+ map[j * 3 + 1];
+ var domNode_1 = map[j * 3 + 2];
+ if (begin_1 == span.tail.start) {
+ // if (DEBUG) console.log("TAIL DOM CHANGED", domNode)
+ if (domNode_1.nodeType === Node.TEXT_NODE) {
+ // good. this token can be changed
+ var domParent = domNode_1.parentElement;
+ if (shallHideTokens ? addClass(domParent, hideClassName) : rmClass(domParent, hideClassName)) {
+ changed = true;
+ }
+ }
+ }
+ if (begin_1 >= span.tail.end) break;
+ }
+ }
+ }
+ // whoops, next time we can start searching since here
+ // return the hint value
+ if (begin >= span.begin) break;
+ }
+ return changed;
+ }
+ var spans = core_1.getLineSpanExtractor(cm).extract(lineNo);
+ // console.log('spans: ', spans)
+ var iNodeHint = 0;
+ for (var iSpan = 0; iSpan < spans.length; iSpan++) {
+ var span = spans[iSpan];
+
+ if (this.tokenTypes.indexOf(span.type) === -1) {
+ continue; // not-interested span type
+ }
+ /* TODO: Use AST, instead of crafted Position */
+ var spanRange = [
+ { line: lineNo, ch: span.begin },
+ { line: lineNo, ch: span.end },
+ ];
+ /* TODO: If use AST, compute `spanBeginCharInCurrentLine` in another way */
+ var spanBeginCharInCurrentLine = span.begin;
+ while (iNodeHint < nodeCount && map[iNodeHint * 3 + 1] < spanBeginCharInCurrentLine) iNodeHint++;
+ var shallHideTokens = true;
+ for (var iLineRange = 0; iLineRange < rangesInLine.length; iLineRange++) {
+ var userRange = rangesInLine[iLineRange];
+ if (core_1.rangesIntersect(spanRange, userRange)) {
+ shallHideTokens = false;
+ break;
+ }
+ }
+ // console.log('changeVis', span, shallHideTokens)
+ if (changeVisibilityForSpan(span, shallHideTokens, iNodeHint)) {
+ changed = true;
+ }
+ }
+ // finally clean the cache (if needed) and report the result
+ if (changed) {
+ // clean CodeMirror measure cache
+ delete lv.measure.heights;
+ lv.measure.cache = {};
+ }
+ return changed;
+ };
+ HideToken.prototype.updateImmediately = function () {
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
+ var _this = this;
+ this.update.stop();
+ var cm = this.cm;
+ var selections = cm.listSelections();
+ var caretAtLines = {};
+ var activedLines = {};
+ cm.state.refreshCaretLine = null;
+ var lastActivedLines = this._rangesInLine;
+ for (var _i = 0, selections_1 = selections; _i < selections_1.length; _i++) {
+ var selection = selections_1[_i];
+ var oRange = core_1.orderedRange(selection);
+ var line0 = oRange[0].line,
+ line1 = oRange[1].line;
+ caretAtLines[line0] = caretAtLines[line1] = true;
+ for (var line = line0; line <= line1; line++) {
+ if (!activedLines[line]) activedLines[line] = [oRange];
+ else activedLines[line].push(oRange);
+ }
+ }
+ this._rangesInLine = activedLines;
+ cm.operation(function () {
+ // adding "inactive" class
+ for (var line in lastActivedLines) {
+ if (activedLines[line]) {
+ continue; // line is still active. do nothing
+ }
+ _this.procLine(~~line); // or, try adding "inactive" class to the s
+ }
+ var caretLineChanged = false;
+ for (var line in activedLines) {
+ var lineChanged = _this.procLine(~~line);
+ if (!lineChanged) {
+ // always force a cursor placement refresh if the cursor changed lines
+ lastActivedLines.hasOwnProperty(line) ? (lineChanged = false) : (lineChanged = true);
+ }
+ if (lineChanged && caretAtLines[line]) caretLineChanged = true;
+ }
+ // refresh cursor position if needed
+ if (caretLineChanged) {
+ cm.getLineHandle(line);
+ core_1.updateCursorDisplay(cm, false);
+ }
+ });
+ };
+ return HideToken;
+ })();
+ exports.HideToken = HideToken;
+ //#endregion
+ /** ADDON GETTER (Singleton Pattern): a editor can have only one HideToken instance */
+ exports.getAddon = core_1.Addon.Getter("HideToken", HideToken, exports.defaultOption /** if has options */);
+});
+
+createCommonjsModule(function (module) {
+// CodeMirror, copyright (c) by laobubu
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+//
+// This is a patch to markdown mode. Supports lots of new features
+//
+var __assign =
+ (commonjsGlobal && commonjsGlobal.__assign) ||
+ function () {
+ __assign =
+ Object.assign ||
+ function (t) {
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
+ s = arguments[i];
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
+ }
+ return t;
+ };
+ return __assign.apply(this, arguments);
+ };
+
+(function (mod) {
+ //[HyperMD] UMD patched!
+ /*plain env*/ mod(null, (HyperMD.Mode = HyperMD.Mode || {}), CodeMirror);
+})(function (require, exports, CodeMirror) {
+ var _a;
+ Object.defineProperty(exports, "__esModule", { value: true });
+ /**
+ * Markdown Extension Tokens
+ *
+ * - `$` Maybe a LaTeX
+ * - `|` Maybe a Table Col Separator
+ */
+ var tokenBreakRE = /[^\\][$|]/;
+ var listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/;
+ var urlRE =
+ /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i; // from CodeMirror/mode/gfm
+ var emailRE =
+ /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+ var url2RE = /^\.{0,2}\/[^\>\s]+/;
+ var SimpleTableRE = /^\s*[^\|].*?\|.*[^|]\s*$/;
+ var SimpleTableLooseRE = /^\s*[^\|].*\|/; // unfinished | row
+ var NormalTableRE = /^\s*\|[^\|]+\|(.+\|)?\s*$/;
+ var NormalTableLooseRE = /^\s*\|/; // | unfinished row
+ var linkStyle =
+ ((_a = {}),
+ (_a[1 /* BARELINK */] = "hmd-barelink"),
+ (_a[7 /* BARELINK2 */] = "hmd-barelink2"),
+ (_a[4 /* WIKILINK */] = "hmd-internal-link"),
+ (_a[2 /* FOOTREF */] = "hmd-barelink footref"),
+ (_a[5 /* FOOTNOTE */] = "hmd-footnote line-HyperMD-footnote"),
+ (_a[8 /* FOOTREF2 */] = "hmd-footref2"),
+ (_a[9 /* FOOTREF2 */] = "hmd-embed hmd-internal-link"),
+ _a);
+ function resetTable(state) {
+ state.hmdTable = 0 /* NONE */;
+ state.hmdTableColumns = [];
+ state.hmdTableID = null;
+ state.hmdTableCol = state.hmdTableRow = 0;
+ }
+ var listInQuoteRE = /^\s+((\d+[).]|[-*+])\s+)?/;
+ var defaultTokenTypeOverrides = {
+ hr: "line-HyperMD-hr line-background-HyperMD-hr-bg hr",
+ // HyperMD needs to know the level of header/indent. using tokenTypeOverrides is not enough
+ // header: "line-HyperMD-header header",
+ // quote: "line-HyperMD-quote quote",
+ // Note: there are some list related process below
+ list1: "list-1",
+ list2: "list-2",
+ list3: "list-3",
+ code: "inline-code",
+ hashtag: "hashtag meta",
+ };
+ CodeMirror.defineMode(
+ "openmd",
+ function (cmCfg, modeCfgUser) {
+ var modeCfg = {
+ front_matter: true,
+ math: true,
+ table: true,
+ toc: true,
+ orgModeMarkup: true,
+ hashtag: true,
+ fencedCodeBlockHighlighting: true,
+ name: "markdown",
+ highlightFormatting: true,
+ taskLists: true,
+ strikethrough: true,
+ emoji: false,
+ highlight: true,
+ tokenTypeOverrides: defaultTokenTypeOverrides,
+ };
+ Object.assign(modeCfg, modeCfgUser);
+ if (modeCfg.tokenTypeOverrides !== defaultTokenTypeOverrides) {
+ modeCfg.tokenTypeOverrides = Object.assign({}, defaultTokenTypeOverrides, modeCfg.tokenTypeOverrides);
+ }
+ modeCfg["name"] = "markdown";
+ /** functions from CodeMirror Markdown mode closure. Only for status checking */
+ var rawClosure = {
+ htmlBlock: null,
+ };
+ var rawMode = CodeMirror.getMode(cmCfg, modeCfg);
+ var newMode = __assign({}, rawMode);
+ newMode.startState = function () {
+ var ans = rawMode.startState();
+ resetTable(ans);
+ ans.hmdOverride = null;
+ ans.hmdInnerExitChecker = null;
+ ans.hmdInnerMode = null;
+ ans.hmdLinkType = 0 /* NONE */;
+ ans.hmdNextMaybe = modeCfg.front_matter ? 1 /* FRONT_MATTER */ : 0 /* NONE */;
+ ans.hmdNextState = null;
+ ans.hmdNextStyle = null;
+ ans.hmdNextPos = null;
+ ans.templater = 0;
+ ans.hmdImage = 0;
+ ans.hmdHashtag = 0 /* NONE */;
+ return ans;
+ };
+ newMode.copyState = function (s) {
+ var ans = rawMode.copyState(s);
+ var keys = [
+ "hmdLinkType",
+ "hmdNextMaybe",
+ "hmdTable",
+ "hmdTableID",
+ "hmdTableCol",
+ "hmdTableRow",
+ "hmdOverride",
+ "hmdInnerMode",
+ "hmdInnerStyle",
+ "hmdInnerExitChecker",
+ "hmdNextPos",
+ "hmdNextState",
+ "hmdNextStyle",
+ "hmdHashtag",
+ "hmdImage",
+ "templater",
+ "comment",
+ ];
+ for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
+ var key = keys_1[_i];
+ ans[key] = s[key];
+ }
+ ans.hmdTableColumns = s.hmdTableColumns.slice(0);
+ if (s.hmdInnerMode) ans.hmdInnerState = CodeMirror.copyState(s.hmdInnerMode, s.hmdInnerState);
+ return ans;
+ };
+ newMode.blankLine = function (state) {
+ var ans;
+ var innerMode = state.hmdInnerMode;
+ if (innerMode) {
+ if (innerMode.blankLine) ans = innerMode.blankLine(state.hmdInnerState);
+ } else {
+ ans = rawMode.blankLine(state);
+ }
+ if (!ans) ans = "";
+ if (state.code === -1) {
+ ans += " line-HyperMD-codeblock line-background-HyperMD-codeblock-bg";
+ }
+ if (state.templater === 1) {
+ ans += " line-background-templater-command-bg line-HyperMD-codeblock line-background-HyperMD-codeblock-bg";
+ }
+ resetTable(state);
+ return ans.trim() || null;
+ };
+ newMode.indent = function (state, textAfter) {
+ var mode = state.hmdInnerMode || rawMode;
+ var f = mode.indent;
+ if (typeof f === "function") return f.apply(mode, arguments);
+ return CodeMirror.Pass;
+ };
+ newMode.innerMode = function (state) {
+ if (state.hmdInnerMode) return { mode: state.hmdInnerMode, state: state.hmdInnerState };
+ return rawMode.innerMode(state);
+ };
+ newMode.token = function (stream, state) {
+ if (state.hmdOverride) return state.hmdOverride(stream, state);
+ {
+ // Only appears once for each Doc
+ if (/^<%(.){0,1}$/.test(stream.string) && stream.peek() === "<") {
+ state.templater = 1;
+ stream.match(/^<%[^\s]*/, true);
+ return "templater-opening-tag templater-command formatting line-HyperMD-codeblock formatting-templater line-background-HyperMD-codeblock-bg line-background-HyperMD-codeblock-begin-bg line-background-templater-start line-background-templater-command-bg";
+ }
+ if (state.templater === 1) {
+ return enterMode(stream, state, "javascript", {
+ style:
+ "templater-command line-HyperMD-codeblock line-background-HyperMD-codeblock-bg line-background-templater-command-bg",
+ skipFirstToken: false,
+ fallbackMode: function () {
+ return createDummyMode("<%");
+ },
+ exitChecker: function (stream, state) {
+ if (/%>$/.test(stream.string)) {
+ // found the endline of front_matter
+ state.templater = -1 /* NONE */;
+ stream.backUp(1);
+ return { endPos: 0 };
+ } else {
+ return null;
+ }
+ },
+ });
+ }
+ if (state.templater === -1) {
+ state.templater = 0 /* NONE */;
+ stream.skipToEnd();
+ return "templater-closing-tag formatting formatting-templater templater-command line-HyperMD-codeblock line-background-HyperMD-codeblock-bg line-background-HyperMD-codeblock-end-bg line-background-templater-end line-background-templater-command-bg";
+ } else {
+ state.templater = 0 /* NONE */;
+ }
+ }
+ if (state.hmdNextMaybe === 1 /* FRONT_MATTER */) {
+ // Only appears once for each Doc
+ if (stream.string === "---") {
+ state.hmdNextMaybe = 2 /* FRONT_MATTER_END */;
+ return enterMode(stream, state, "yaml", {
+ style: "hmd-frontmatter",
+ fallbackMode: function () {
+ return createDummyMode("---");
+ },
+ exitChecker: function (stream, state) {
+ if (stream.string === "---") {
+ // found the endline of front_matter
+ state.hmdNextMaybe = 0 /* NONE */;
+ return { endPos: 3 };
+ } else {
+ return null;
+ }
+ },
+ });
+ } else {
+ state.hmdNextMaybe = 0 /* NONE */;
+ }
+ }
+ var inInternalLink;
+ var wasInHTML = state.f === rawClosure.htmlBlock;
+ var wasInCodeFence = state.code === -1;
+ var bol = stream.start === 0;
+ var wasLinkText = state.linkText;
+ var wasLinkHref = state.linkHref;
+ var inMarkdown = !(wasInCodeFence || wasInHTML);
+ var inMarkdownInline = inMarkdown && !(state.code || state.indentedCode || state.linkHref);
+ var ans = "";
+ var tmp;
+ var findComment = null;
+ var tmpPOS = -1;
+ if (inMarkdown) {
+ // now implement some extra features that require higher priority than CodeMirror's markdown
+ // add support for headers in list items
+ if (/#/.test(stream.peek())) {
+ if (state.list && /- (#+)(?: |$)/.test(stream.string)) {
+ state.list = false;
+ var level = stream.match(/(#+)(?: |$)/, true);
+ var depth = level && level.length > 0 ? level[1].length : 0;
+ state.header = depth;
+ return (ans += "formatting formatting-header formatting-header-" + depth + " header header-" + depth);
+ }
+ }
+ // add support for templater code block syntax
+ if ((tmp = stream.match(/^<%/, true))) {
+ var endTag_1 = "%>";
+ if (stream.string.slice(stream.pos).match(/%>/)) {
+ ans = enterMode(stream, state, "javascript", {
+ style: "templater-command",
+ skipFirstToken: false,
+ fallbackMode: function () {
+ return createDummyMode(endTag_1);
+ },
+ exitChecker: function (stream, state) {
+ const retInfo = {};
+ const endTag = "%>";
+ retInfo.style = "templater-closing-tag formatting formatting-templater line-templater-inline";
+ if (stream.string.substr(stream.start, endTag.length) === endTag) {
+ retInfo.endPos = stream.start + endTag.length;
+ return retInfo;
+ }
+ return null;
+ },
+ });
+ ans += " templater-opening-tag templater-command formatting formatting-templater";
+ return ans;
+ }
+ }
+ //#region Math
+ if (modeCfg.math && inMarkdownInline && (tmp = stream.match(/^\${1,2}/, false))) {
+ var endTag_1 = tmp[0];
+ var mathLevel = endTag_1.length;
+ if (mathLevel === 2 || stream.string.slice(stream.pos).match(/[^\\\s-]\$(?![0-9])/)) {
+ // $$ may span lines, $ must be paired
+ var texMode = CodeMirror.getMode(cmCfg, {
+ name: "stex",
+ });
+ var noTexMode = texMode["name"] !== "stex";
+ var block = mathLevel > 1 ? "math-block" : "";
+ ans += enterMode(stream, state, texMode, {
+ style: "math",
+ skipFirstToken: noTexMode,
+ fallbackMode: function () {
+ return createDummyMode(endTag_1);
+ },
+ exitChecker: createSimpleInnerModeExitChecker(endTag_1, {
+ style: `formatting formatting-math formatting-math-end ${block} math-` + mathLevel,
+ }),
+ });
+ if (noTexMode) stream.pos += tmp[0].length;
+ ans += ` formatting formatting-math formatting-math-begin ${block} math-` + mathLevel;
+ return ans;
+ }
+ }
+ //#endregion
+ //#region [OrgMode] markup
+ if (bol && modeCfg.orgModeMarkup && (tmp = stream.match(/^\#\+(\w+\:?)\s*/))) {
+ // Support #+TITLE: This is the title of the document
+ if (!stream.eol()) {
+ state.hmdOverride = function (stream, state) {
+ stream.skipToEnd();
+ state.hmdOverride = null;
+ return "string hmd-orgmode-markup";
+ };
+ }
+ return "meta formatting-hmd-orgmode-markup hmd-orgmode-markup line-HyperMD-orgmode-markup";
+ }
+ //#endregion
+ //#region [TOC] in a single line
+ if (bol && modeCfg.toc && stream.match(/^\[TOCM?\]\s*$/i)) {
+ return "meta line-HyperMD-toc hmd-toc";
+ }
+ //#endregion
+ //#region Extra markdown inline extenson
+ if (inMarkdownInline) {
+ // transform unformatted URL into link
+ if (!state.hmdLinkType && (stream.match(urlRE) || stream.match(emailRE))) {
+ return "url";
+ }
+ if (state.internalLink) {
+ state.hmdLinkType = 4 /* INTERNAL */;
+ state.internalLink = false;
+ } else if (state.internalEmbed) {
+ state.hmdLinkType = 9 /* EMBED */;
+ state.internalEmbed = false;
+ } else if ((inInternalLink = stream.match(/^(!?\[\[).+\]\]/, false))) {
+ "!" === inInternalLink[1].charAt(0)
+ ? ((ans += " formatting-link formatting-link-start formatting-embed"), (state.internalEmbed = true))
+ : ((ans += " formatting-link formatting-link-start"), (state.internalLink = true)),
+ (tmpPOS = stream.pos + inInternalLink[1].length);
+ } else {
+ (state.hmdLinkType !== 4 /* INTERNAL */ && state.hmdLinkType !== 9) /* EMBED */ ||
+ !stream.match(/^\]\]/, false) ||
+ ((state.hmdLinkType = 0) /* NONE */,
+ (state.linkText = false),
+ (tmpPOS = stream.pos + 2),
+ (ans += " formatting-link formatting-link-end"));
+ }
+ // block refs
+ if (stream.match(/^\^([a-zA-Z0-9\-]+)$/)) {
+ ans += " blockid";
+ }
+ // handle comments
+ let _pos = stream.pos;
+ findComment = function (e) {
+ var _match = stream.string.slice(_pos, e).match(/^(.+?)%%/);
+ return _match ? _pos + _match[1].length : e;
+ };
+ if (state.comment) {
+ ans += " comment";
+ if (stream.match(/^%%/, false)) {
+ state.comment = false;
+ tmpPOS = stream.pos + 2;
+ }
+ } else {
+ if (stream.match(/^%%/, false)) {
+ state.comment = true;
+ ans += " comment";
+ tmpPOS = stream.pos + 2;
+ }
+ }
+ }
+ //#endregion
+ }
+ // now enter markdown
+ if (state.hmdNextState) {
+ stream.pos = state.hmdNextPos;
+ ans += " " + (state.hmdNextStyle || "");
+ Object.assign(state, state.hmdNextState);
+ state.hmdNextState = null;
+ state.hmdNextStyle = null;
+ state.hmdNextPos = null;
+ } else {
+ ans += " " + (rawMode.token(stream, state) || "");
+ }
+ if (tmpPOS !== -1) {
+ stream.pos = tmpPOS;
+ }
+ if (findComment) {
+ stream.pos = findComment(stream.pos);
+ }
+ // add extra styles
+ if (state.hmdHashtag !== 0 /* NONE */) {
+ ans += " " + modeCfg.tokenTypeOverrides.hashtag;
+ }
+ /** Try to capture some internal functions from CodeMirror Markdown mode closure! */
+ if (!rawClosure.htmlBlock && state.htmlState) rawClosure.htmlBlock = state.f;
+ var inHTML = state.f === rawClosure.htmlBlock;
+ var inCodeFence = state.code === -1;
+ inMarkdown = inMarkdown && !(inHTML || inCodeFence);
+ inMarkdownInline = inMarkdownInline && inMarkdown && !(state.code || state.indentedCode || state.linkHref);
+ // If find a markdown extension token (which is not escaped),
+ // break current parsed string into two parts and the first char of next part is the markdown extension token
+ if (inMarkdownInline && (tmp = stream.current().match(tokenBreakRE))) {
+ stream.pos = stream.start + tmp.index + 1; // rewind
+ }
+ var current = stream.current();
+ if (inHTML != wasInHTML) {
+ if (inHTML) {
+ ans += " hmd-html-begin";
+ rawClosure.htmlBlock = state.f;
+ } else {
+ ans += " hmd-html-end";
+ }
+ }
+ if (wasInCodeFence || inCodeFence) {
+ if (!state.localMode || !wasInCodeFence) ans = ans.replace("inline-code", "");
+ ans += " line-HyperMD-codeblock line-background-HyperMD-codeblock-bg hmd-codeblock";
+ if (inCodeFence !== wasInCodeFence) {
+ if (!inCodeFence) ans += " line-HyperMD-codeblock-end line-background-HyperMD-codeblock-end-bg";
+ else if (!wasInCodeFence) ans += " line-HyperMD-codeblock-begin line-background-HyperMD-codeblock-begin-bg";
+ }
+ }
+ if (inMarkdown) {
+ var tableType = state.hmdTable;
+ //#region [Table] Reset
+ if (bol && tableType) {
+ var rowRE = tableType == 1 /* SIMPLE */ ? SimpleTableLooseRE : NormalTableLooseRE;
+ if (rowRE.test(stream.string)) {
+ // still in table
+ state.hmdTableCol = 0;
+ state.hmdTableRow++;
+ } else {
+ // end of a table
+ resetTable(state);
+ }
+ }
+ //#endregion
+ //#region Header, indentedCode, quote
+
+ if (bol && state.header) {
+ if (/^(?:---+|===+)\s*$/.test(stream.string) && state.prevLine && state.prevLine.header) {
+ ans += " line-HyperMD-header-line line-HyperMD-header-line-" + state.header;
+ } else {
+ ans += " line-HyperMD-header line-HyperMD-header-" + state.header;
+ }
+ }
+ if (state.indentedCode) {
+ ans += " hmd-indented-code";
+ }
+ if (state.quote) {
+ // mess up as less as possible
+ if (stream.eol()) {
+ ans += " line-HyperMD-quote line-HyperMD-quote-" + state.quote;
+ if (!/^ {0,3}\>/.test(stream.string)) ans += " line-HyperMD-quote-lazy"; // ">" is omitted
+ }
+ if (bol && (tmp = current.match(/^\s+/))) {
+ stream.pos = tmp[0].length; // rewind
+ ans += " hmd-indent-in-quote";
+ return ans.trim();
+ }
+ // make indentation (and potential list bullet) monospaced
+ if (/^>\s+$/.test(current) && stream.peek() != ">") {
+ stream.pos = stream.start + 1; // rewind!
+ current = ">";
+ state.hmdOverride = function (stream, state) {
+ stream.match(listInQuoteRE);
+ state.hmdOverride = null;
+ return "hmd-indent-in-quote line-HyperMD-quote line-HyperMD-quote-" + state.quote;
+ };
+ }
+ }
+ //#endregion
+ //#region List
+ var maxNonCodeIndentation = (state.listStack[state.listStack.length - 1] || 0) + 3;
+ var tokenIsIndent =
+ bol && /^\s+$/.test(current) && (state.list !== false || stream.indentation() <= maxNonCodeIndentation);
+ var tokenIsListBullet = state.list && /formatting-list/.test(ans);
+ if (tokenIsListBullet || (tokenIsIndent && (state.list !== false || stream.match(listRE, false)))) {
+ var listLevel = (state.listStack && state.listStack.length) || 0;
+ if (tokenIsIndent) {
+ if (stream.match(listRE, false)) {
+ // next token is 1. 2. or bullet
+ if (state.list === false) listLevel++;
+ } else {
+ while (listLevel > 0 && stream.pos < state.listStack[listLevel - 1]) {
+ listLevel--; // find the real indent level
+ }
+ if (!listLevel) {
+ // not even a list
+ return ans.trim() || null;
+ }
+ ans += " line-HyperMD-list-line-nobullet line-HyperMD-list-line line-HyperMD-list-line-" + listLevel;
+ }
+ ans += " hmd-list-indent hmd-list-indent-" + listLevel;
+ } else if (tokenIsListBullet) {
+ // no space before bullet!
+ ans += " line-HyperMD-list-line line-HyperMD-list-line-" + listLevel;
+ }
+ }
+ //#endregion
+
+ //#region Link, BareLink, Footnote, Wikilink etc
+ if (stream.current() === "[" && stream.eat("[")) {
+ current = "[[";
+ // ans += " formatting-link";
+ }
+ if (stream.current() === "]" && stream.eat("]")) {
+ current = "]]";
+ // ans += " formatting-link";
+ }
+ if (wasLinkText !== state.linkText) {
+ if (!wasLinkText) {
+ if (current === "[[" || current === "]]") {
+ // Check wiki link
+ state.hmdLinkType = 4 /* WIKILINK */;
+ } else {
+ // entering a link
+ tmp = stream.match(/^([^\]]+)\](\(| ?\[|\:)?/, false);
+ if (!tmp) {
+ // maybe met a line-break in link text?
+ state.hmdLinkType = 1 /* BARELINK */;
+ } else if (!tmp[2]) {
+ // barelink
+ if (tmp[1].charAt(0) === "^") {
+ state.hmdLinkType = 2 /* FOOTREF */;
+ } else {
+ state.hmdLinkType = 1 /* BARELINK */;
+ }
+ } else if (tmp[2] === ":") {
+ // footnote
+ state.hmdLinkType = 5 /* FOOTNOTE */;
+ } else if (
+ (tmp[2] === "[" || tmp[2] === " [") &&
+ stream.string.charAt(stream.pos + tmp[0].length) === "]"
+ ) {
+ // [barelink2][]
+ state.hmdLinkType = 7 /* BARELINK2 */;
+ } else {
+ state.hmdLinkType = 3 /* NORMAL */;
+ }
+ }
+ } else {
+ // leaving a link
+ if (state.hmdLinkType in linkStyle) {
+ if (current !== "[[" && current !== "]]") {
+ ans += " " + linkStyle[state.hmdLinkType];
+ }
+ }
+ if (state.hmdLinkType === 5 /* FOOTNOTE */) {
+ state.hmdLinkType = 6 /* MAYBE_FOOTNOTE_URL */;
+ } else {
+ state.hmdLinkType = 0 /* NONE */;
+ }
+ }
+ }
+ if (wasLinkHref !== state.linkHref) {
+ if (!wasLinkHref) {
+ // [link][doc] the [doc] part
+ if (current === "[" && stream.peek() !== "]") {
+ state.hmdLinkType = 8 /* FOOTREF2 */;
+ }
+ } else if (state.hmdLinkType) {
+ // leaving a Href
+ ans += " " + linkStyle[state.hmdLinkType];
+ state.hmdLinkType = 0 /* NONE */;
+ }
+ }
+ if (state.hmdLinkType !== 0 /* NONE */) {
+ if (state.hmdLinkType in linkStyle) {
+ if (current !== "[[" && current !== "]]") {
+ ans += " " + linkStyle[state.hmdLinkType];
+ }
+ }
+ if (
+ (state.hmdLinkType === 4 || state.hmdLinkType === 9) /* WIKILINK */ &&
+ current !== "[[" &&
+ current !== "]]"
+ ) {
+ var eaten = false;
+ // break out of link if templater syntax found
+ if (stream.match(/^<%/, false)) {
+ return;
+ }
+ while (stream.eat(/[^<|\]#]/)) {
+ eaten = true;
+ }
+ if (stream.eat("%")) {
+ stream.backUp(2);
+ return;
+ }
+ if (eaten || (stream.peek() || "").match(/[\|\]#]/)) {
+ if (stream.peek() === "#") {
+ // link has a ref
+ if (stream.match(/[^|\]]+\|[^\]]+\]\]/, false)) {
+ // link has an alias
+ ans += " " + "internal-link-url";
+ } else {
+ // no alias
+ ans += " " + "internal-link-name";
+ }
+ } else if (stream.current().startsWith("#")) {
+ stream.eat("|");
+ ans += " " + "internal-link-ref";
+ } else if (stream.peek() === "|") {
+ stream.eat("|");
+ // console.log(current);
+ if (/\.(jpe?g|png|gif|svg|bmp)/.test(stream.current())) {
+ state.hmdImage = 1;
+ ans += " " + "internal-link-name hmd-image";
+ } else {
+ ans += " " + "internal-link-url";
+ }
+ } else if (!stream.current().startsWith("#")) {
+ if (state.hmdImage === 1) {
+ state.hmdImage = 0;
+ ans += " " + "internal-link-url";
+ } else {
+ ans += " " + "internal-link-name";
+ }
+ } else ;
+ current = stream.current();
+ }
+ }
+ if (state.hmdLinkType === 6 /* MAYBE_FOOTNOTE_URL */) {
+ if (!/^(?:\]\:)?\s*$/.test(current)) {
+ // not spaces
+ if (urlRE.test(current) || url2RE.test(current)) ans += " hmd-footnote-url";
+ else ans = ans.replace("string url", "");
+ state.hmdLinkType = 0 /* NONE */; // since then, can't be url anymore
+ }
+ }
+ }
+ //#endregion
+ //#region start of an escaped char
+ if (/formatting-escape/.test(ans) && current.length > 1) {
+ // CodeMirror merge backslash and escaped char into one token, which is not good
+ // Use hmdOverride to separate them
+ var escapedLength_1 = current.length - 1;
+ var escapedCharStyle_1 = ans.replace("formatting-escape", "escape") + " hmd-escape-char";
+ state.hmdOverride = function (stream, state) {
+ // one-time token() func
+ stream.pos += escapedLength_1;
+ state.hmdOverride = null;
+ return escapedCharStyle_1.trim();
+ };
+ ans += " hmd-escape-backslash";
+ stream.pos -= escapedLength_1;
+ return ans;
+ }
+ //#endregion
+ //#region [Table] Creating Table and style Table Separators
+ if (!ans.trim() && modeCfg.table) {
+ // string is unformatted
+ var isTableSep = false;
+ if (current.charAt(0) === "|") {
+ // is "|xxxxxx", separate "|" and "xxxxxx"
+ stream.pos = stream.start + 1; // rewind to end of "|"
+ current = "|";
+ isTableSep = true;
+ }
+ if (isTableSep) {
+ // if not inside a table, try to construct one
+ if (!tableType) {
+ // check 1: current line meet the table format
+ if (SimpleTableRE.test(stream.string)) tableType = 1 /* SIMPLE */;
+ else if (NormalTableRE.test(stream.string)) tableType = 2 /* NORMAL */;
+ // check 2: check every column's alignment style
+ var rowStyles = void 0;
+ if (tableType) {
+ var nextLine = stream.lookAhead(1);
+ if (tableType === 2 /* NORMAL */) {
+ if (!NormalTableRE.test(nextLine)) {
+ tableType = 0 /* NONE */;
+ } else {
+ // remove leading / tailing pipe char
+ nextLine = nextLine.replace(/^\s*\|/, "").replace(/\|\s*$/, "");
+ }
+ } else if (tableType === 1 /* SIMPLE */) {
+ if (!SimpleTableRE.test(nextLine)) {
+ tableType = 0 /* NONE */;
+ }
+ }
+ if (tableType) {
+ rowStyles = nextLine.split("|");
+ for (var i = 0; i < rowStyles.length; i++) {
+ var row = rowStyles[i];
+ if (/^\s*--+\s*:\s*$/.test(row)) row = "right";
+ else if (/^\s*:\s*--+\s*$/.test(row)) row = "left";
+ else if (/^\s*:\s*--+\s*:\s*$/.test(row)) row = "center";
+ else if (/^\s*--+\s*$/.test(row)) row = "default";
+ else {
+ // ouch, can't be a table
+ tableType = 0 /* NONE */;
+ break;
+ }
+ rowStyles[i] = row;
+ }
+ }
+ }
+ // step 3: made it
+ if (tableType) {
+ // successfully made one
+ state.hmdTable = tableType;
+ state.hmdTableColumns = rowStyles;
+ state.hmdTableID = "T" + stream.lineOracle.line;
+ state.hmdTableRow = state.hmdTableCol = 0;
+ }
+ }
+ // then
+ if (tableType) {
+ var _dummy = false;
+ var colUbound = state.hmdTableColumns.length - 1;
+ if (
+ tableType === 2 /* NORMAL */ &&
+ ((state.hmdTableCol === 0 && /^\s*\|$/.test(stream.string.slice(0, stream.pos))) ||
+ stream.match(/^\s*$/, false))
+ ) {
+ _dummy = true;
+ ans += " hmd-table-sep hmd-table-sep-dummy";
+ }
+ if (state.hmdTableCol <= colUbound) {
+ var row = state.hmdTableRow;
+ var col = state.hmdTableCol++;
+ if (col == 0) {
+ ans +=
+ " line-HyperMD-table_" +
+ state.hmdTableID +
+ " line-HyperMD-table-" +
+ tableType +
+ " line-HyperMD-table-row line-HyperMD-table-row-" +
+ row;
+ }
+ if (!_dummy) ans += " hmd-table-sep hmd-table-sep-" + col;
+ }
+ }
+ }
+ }
+ //#endregion
+ if (tableType && state.hmdTableRow === 1) {
+ // fix a stupid problem: :------: is not emoji
+ if (/emoji/.test(ans)) ans = "";
+ }
+ //#region HTML Block
+ //
+ // See https://github.github.com/gfm/#html-blocks type3-5
+ if (inMarkdownInline && current === "<") {
+ var endTag = null;
+ if (stream.match(/^\![A-Z]+/)) endTag = ">";
+ else if (stream.match("?")) endTag = "?>";
+ else if (stream.match("![CDATA[")) endTag = "]]>";
+ if (endTag != null) {
+ return enterMode(stream, state, null, {
+ endTag: endTag,
+ style: (ans + " comment hmd-cdata-html").trim(),
+ });
+ }
+ }
+ //#endregion
+ //#region Hashtag
+ if (modeCfg.hashtag && inMarkdownInline) {
+ const hashTagRegExp = /^(?:[^\u2000-\u206F\u2E00-\u2E7F'!"#$%&()*+,.:;<=>?@^`{|}~\[\]\\\s])+/;
+ if (state.hmdHashtag === 1) {
+ var endHashTag = false;
+ if (!/formatting/.test(ans) && !/^\s*$/.test(current)) {
+ stream.eatWhile(hashTagRegExp);
+ endHashTag = true;
+ }
+ if (
+ (endHashTag || (endHashTag = stream.eol()),
+ endHashTag || (endHashTag = !hashTagRegExp.test(stream.peek())),
+ endHashTag)
+ ) {
+ ans +=
+ " hashtag-end " + (tagClass = "tag-" + (tagClass = stream.current()).replace(/[^_a-zA-Z0-9\-]/g, ""));
+ state.hmdHashtag = 0;
+ }
+ } else if (
+ "#" === current &&
+ !state.linkText &&
+ !state.image &&
+ (bol || /^\s*$/.test(stream.string.charAt(stream.start - 1)))
+ ) {
+ var escape_removed_str = stream.string.slice(stream.pos).replace(/\\./g, "");
+ tmp = hashTagRegExp.exec(escape_removed_str);
+ if (tmp && /[^0-9]/.test(tmp[0])) {
+ var tagClass = "tag-" + tmp[0].replace(/[^_a-zA-Z0-9\-]/g, "");
+ state.hmdHashtag = 1;
+ ans +=
+ " formatting formatting-hashtag hashtag-begin " + modeCfg.tokenTypeOverrides.hashtag + " " + tagClass;
+ }
+ }
+ }
+ //#endregion
+ }
+ return ans.trim() || null;
+ };
+ function modeOverride(stream, state) {
+ var exit = state.hmdInnerExitChecker(stream, state);
+ var extraStyle = state.hmdInnerStyle;
+ var ans = ((!exit || !exit.skipInnerMode) && state.hmdInnerMode.token(stream, state.hmdInnerState)) || "";
+ if (extraStyle) ans += " " + extraStyle;
+ if (exit) {
+ if (exit.style) ans += " " + exit.style;
+ if (exit.endPos) stream.pos = exit.endPos;
+ state.hmdInnerExitChecker = null;
+ state.hmdInnerMode = null;
+ state.hmdInnerState = null;
+ state.hmdOverride = null;
+ }
+ return ans.trim() || null;
+ }
+ function createDummyMode(endTag) {
+ return {
+ token: function (stream) {
+ var endTagSince = stream.string.indexOf(endTag, stream.start);
+ if (endTagSince === -1) stream.skipToEnd();
+ // endTag not in this line
+ else if (endTagSince === 0) stream.pos += endTag.length;
+ // current token is endTag
+ else {
+ stream.pos = endTagSince;
+ if (stream.string.charAt(endTagSince - 1) === "\\") stream.pos++;
+ }
+ return null;
+ },
+ };
+ }
+ function createSimpleInnerModeExitChecker(endTag, retInfo) {
+ if (!retInfo) retInfo = {};
+ return function (stream, state) {
+ if (stream.string.substr(stream.start, endTag.length) === endTag) {
+ retInfo.endPos = stream.start + endTag.length;
+ return retInfo;
+ }
+ return null;
+ };
+ }
+ /**
+ * switch to another mode
+ *
+ * After entering a mode, you can then set `hmdInnerExitStyle` and `hmdInnerState` of `state`
+ *
+ * @returns if `skipFirstToken` not set, returns `innerMode.token(stream, innerState)`, meanwhile, stream advances
+ */
+ function enterMode(stream, state, mode, opt) {
+ if (typeof mode === "string") mode = CodeMirror.getMode(cmCfg, mode);
+ if (!mode || mode["name"] === "null") {
+ if ("endTag" in opt) mode = createDummyMode(opt.endTag);
+ else mode = typeof opt.fallbackMode === "function" && opt.fallbackMode();
+ if (!mode) throw new Error("no mode");
+ }
+ state.hmdInnerExitChecker = "endTag" in opt ? createSimpleInnerModeExitChecker(opt.endTag) : opt.exitChecker;
+ state.hmdInnerStyle = opt.style;
+ state.hmdInnerMode = mode;
+ state.hmdOverride = modeOverride;
+ state.hmdInnerState = CodeMirror.startState(mode);
+ var ans = opt.style || "";
+ if (!opt.skipFirstToken) {
+ ans += " " + mode.token(stream, state.hmdInnerState);
+ }
+ return ans.trim();
+ }
+ return newMode;
+ },
+ "openmd"
+ );
+ CodeMirror.defineMIME("text/x-openmd", "openmd");
+});
+});
+
+// HyperMD, copyright (c) by laobubu
+
+var ___extends = (function () {
+ var extendStatics = function (d, b) {
+ extendStatics =
+ Object.setPrototypeOf ||
+ ({ __proto__: [] } instanceof Array &&
+ function (d, b) {
+ d.__proto__ = b;
+ }) ||
+ function (d, b) {
+ for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
+ };
+ return extendStatics(d, b);
+ };
+ return function (d, b) {
+ extendStatics(d, b);
+ function __() {
+ this.constructor = d;
+ }
+ d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
+ };
+})();
+
+(function (mod) {
+ //[HyperMD] UMD patched!
+ /*plain env*/ mod(null, (HyperMD.Fold = HyperMD.Fold || {}), CodeMirror, HyperMD, HyperMD.AttributesAddon);
+})(function (require, exports, CodeMirror, core_1, index_1) {
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.getAddon =
+ exports.Fold =
+ exports.parseAttributes =
+ exports.suggestedOption =
+ exports.defaultOption =
+ exports.breakMark =
+ exports.registerFolder =
+ exports.folderRegistry =
+ exports.RequestRangeResult =
+ void 0;
+ var FlagArray = typeof Uint8Array === "undefined" ? Array : Uint8Array;
+ var RequestRangeResult;
+ (function (RequestRangeResult) {
+ // Use string values because in TypeScript, string enum members do not get a reverse mapping generated at all.
+ // Otherwise the generated code looks ugly
+ RequestRangeResult["OK"] = "ok";
+ RequestRangeResult["CURSOR_INSIDE"] = "ci";
+ RequestRangeResult["HAS_MARKERS"] = "hm";
+ })((RequestRangeResult = exports.RequestRangeResult || (exports.RequestRangeResult = {})));
+ //#endregion
+ /********************************************************************************** */
+ //#region FolderFunc Registry
+ exports.folderRegistry = {};
+ /**
+ * Add a Folder to the System Folder Registry
+ *
+ * @param name eg. "math" "html" "image" "link"
+ * @param folder
+ * @param suggested enable this folder in suggestedEditorConfig
+ * @param force if a folder with same name is already exists, overwrite it. (dangerous)
+ */
+ function registerFolder(name, folder, suggested, force) {
+ var registry = exports.folderRegistry;
+ if (name in registry && !force) throw new Error("Folder " + name + " already registered");
+ exports.defaultOption[name] = false;
+ exports.suggestedOption[name] = !!suggested;
+ registry[name] = folder;
+ }
+ exports.registerFolder = registerFolder;
+ //#endregion
+ /********************************************************************************** */
+ //#region Utils
+ /** break a TextMarker, move cursor to where marker is */
+ function breakMark(cm, marker, chOffset) {
+ // TODO: update this to support making a selection rather than placing the cursor
+ cm.operation(function () {
+ var fromPos = marker.find().from;
+ fromPos = { line: fromPos.line, ch: fromPos.ch + ~~chOffset };
+ var toPos = marker.find().to;
+ toPos = { line: toPos.line, ch: toPos.ch + ~~chOffset };
+ // need to clear before setting the cursor since some markers don't allow the
+ // cursor to be placed next to them
+ marker.clear();
+ cm.setCursor(fromPos);
+ // cm.setSelection(fromPos, toPos);
+ cm.focus();
+ });
+ }
+ exports.breakMark = breakMark;
+ exports.defaultOption = {
+ /* will be populated by registerFolder() */
+ };
+ exports.suggestedOption = {
+ /* will be populated by registerFolder() */
+ };
+ core_1.suggestedEditorConfig.hmdFold = exports.suggestedOption;
+ core_1.normalVisualConfig.hmdFold = false;
+ CodeMirror.defineOption("hmdFold", exports.defaultOption, function (cm, newVal) {
+ ///// convert newVal's type to `Record`, if it is not.
+ var inst = exports.getAddon(cm);
+ if (!newVal || typeof newVal === "boolean") {
+ newVal = newVal ? exports.suggestedOption : exports.defaultOption;
+ }
+ if ("customFolders" in newVal) {
+ delete newVal["customFolders"];
+ }
+ ///// apply config
+ for (var type in exports.folderRegistry) {
+ inst.setStatus(cm, type, newVal[type]);
+ }
+ // then, folding task will be queued by setStatus()
+ });
+ Object.defineProperty(exports, "parseAttributes", {
+ enumerable: true,
+ get: function () {
+ return index_1.parseAttributes;
+ },
+ });
+ //#endregion
+ /********************************************************************************** */
+ //#region Addon Class
+ var Fold = /** @class */ (function (_super) {
+ ___extends(Fold, _super);
+ function Fold(cm) {
+ var _this = _super.call(this, cm) || this;
+ _this.cm = cm;
+ /**
+ * stores Folder status for current editor
+ * @private To enable/disable folders, use `setStatus()`
+ */
+ _this._enabled = {};
+ /** Folder's output goes here */
+ _this.folded = {};
+ /// END OF APIS THAT EXPOSED TO FolderFunc
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Fold everything! (This is a debounced, and `this`-binded version)
+ */
+ _this.startFold = core_1.debounce(_this.startFoldImmediately.bind(_this), 200);
+ /** stores every affected lineNo */
+ _this._quickFoldHint = [];
+ this.registerEvents = function (enable) {
+ if (enable) {
+ cm.on("changes", _this.onChange);
+ cm.on("viewportChange", _this.onViewportChange);
+ cm.on("cursorActivity", _this.onCursorActivity);
+ } else {
+ cm.off("changes", _this.onChange);
+ cm.off("viewportChange", _this.onViewportChange);
+ cm.off("cursorActivity", _this.onCursorActivity);
+ }
+ };
+ this.onViewportChange = function (cm, from, to) {
+ _this.startFold(from, to);
+ };
+ this.checkForPreview = obsidian.debounce(
+ function () {
+ document.querySelector("#math-preview")?.addClass("float-win-hidden");
+ },
+ 500,
+ true
+ );
+ this.onChange = function (cm, changes) {
+ var changedMarkers = [];
+ for (var _i = 0, changes_1 = changes; _i < changes_1.length; _i++) {
+ var change = changes_1[_i];
+ if (change.removed && change.removed.filter(text => text.includes("$")).length) {
+ _this.checkForPreview();
+ }
+ var markers = cm.findMarks(change.from, change.to);
+ for (var _a = 0, markers_1 = markers; _a < markers_1.length; _a++) {
+ var marker = markers_1[_a];
+ if (marker._hmd_fold_type) changedMarkers.push(marker);
+ }
+ }
+ for (var _b = 0, changedMarkers_1 = changedMarkers; _b < changedMarkers_1.length; _b++) {
+ var m = changedMarkers_1[_b];
+ var line = cm.getLine(changes[0].from.line);
+ if (
+ line[changes[0].from.ch - 1] === "`" &&
+ line[changes[0].from.ch] === "@" &&
+ line.slice(changes[0].from.ch).length > 1
+ ) ; else {
+ m.clear(); // TODO: add "changed" handler for FolderFunc
+ }
+ }
+ var fromLine = 0,
+ toLine = 0;
+ var _changes = changes.map(change => {
+ return { fromLine: change.from.line, toLine: change.to.line };
+ });
+ _changes.forEach(change => {
+ fromLine = change.fromLine > fromLine ? change.fromLine : fromLine;
+ toLine = change.toLine > toLine ? change.toLine : toLine;
+ });
+ _this.startFold(fromLine, toLine);
+ };
+ this.onCursorActivity = function (cm) {
+ var lineStuff = {};
+ function addPosition(pos) {
+ var lineNo = pos.line;
+ if (!(lineNo in lineStuff)) {
+ var lh = cm.getLineHandle(pos.line);
+ var ms = lh.markedSpans || [];
+ var markers = [];
+ for (var i = 0; i < ms.length; i++) {
+ var marker = ms[i].marker;
+ if ("_hmd_crange" in marker) {
+ var from = marker._hmd_crange[0].line < lineNo ? 0 : marker._hmd_crange[0].ch;
+ var to = marker._hmd_crange[1].line > lineNo ? lh.text.length : marker._hmd_crange[1].ch;
+ markers.push([marker, from, to]);
+ }
+ }
+ lineStuff[lineNo] = {
+ lineNo: lineNo,
+ ch: [pos.ch],
+ markers: markers,
+ };
+ } else {
+ lineStuff[lineNo].ch.push(pos.ch);
+ }
+ }
+ cm.listSelections().forEach(function (selection) {
+ addPosition(selection.anchor);
+ addPosition(selection.head);
+ });
+ for (var tmp_id in lineStuff) {
+ var lineData = lineStuff[tmp_id];
+ if (!lineData.markers.length) continue;
+ for (var i = 0; i < lineData.ch.length; i++) {
+ var ch = lineData.ch[i];
+ for (var j = 0; j < lineData.markers.length; j++) {
+ var _a = lineData.markers[j],
+ marker = _a[0],
+ from = _a[1],
+ to = _a[2];
+ if (from <= ch && ch <= to) {
+ marker.clear();
+ lineData.markers.splice(j, 1);
+ j--;
+ }
+ }
+ }
+ }
+ _this.startQuickFold();
+ };
+ return _this;
+ }
+ /** enable/disable one kind of folder, in current editor */
+ Fold.prototype.setStatus = function (cm, type, enabled) {
+ // this logic will disable hmdFold completely if no folders are found in the registry
+ var prevStatus;
+ for (var _type in this._enabled) {
+ if (this._enabled[_type]) {
+ prevStatus = true;
+ break;
+ } else {
+ prevStatus = false;
+ }
+ }
+ if (!(type in exports.folderRegistry)) return;
+ if (!this._enabled[type] !== !enabled) {
+ this._enabled[type] = !!enabled;
+ if (enabled) {
+ this.startFold();
+ } else this.clear(type);
+ }
+ var curStatus;
+ for (var _type in this._enabled) {
+ if (this._enabled[_type]) {
+ curStatus = true;
+ break;
+ } else {
+ curStatus = false;
+ }
+ }
+ if (prevStatus && !curStatus) {
+ this.registerEvents(false);
+ } else if (!prevStatus && curStatus) {
+ this.registerEvents(true);
+ }
+ };
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ /// BEGIN OF APIS THAT EXPOSED TO FolderFunc
+ /// @see FoldStream
+ /**
+ * Check if a range is foldable and update _quickFoldHint
+ *
+ * NOTE: this function is always called after `_quickFoldHint` reset by `startFoldImmediately`
+ */
+ Fold.prototype.requestRange = function (from, to, cfrom, cto) {
+ if (!cto) cto = to;
+ if (!cfrom) cfrom = from;
+ var cm = this.cm;
+ var markers = cm.findMarks(from, to);
+ // nil: filter out any text selection markers so that we don't bug out the entire fold logic, ugh
+ markers = markers.filter(marker => marker.className != "CodeMirror-selectedtext");
+ if (markers.length !== 0) {
+ return RequestRangeResult.HAS_MARKERS;
+ }
+ this._quickFoldHint.push(from.line);
+ // store "crange" for the coming marker
+ this._lastCRange = [cfrom, cto];
+ var selections = cm.listSelections();
+ for (var i = 0; i < selections.length; i++) {
+ var oselection = core_1.orderedRange(selections[i]);
+ // note that "crange" can be bigger or smaller than marked-text range.
+ if (core_1.rangesIntersect(this._lastCRange, oselection) || core_1.rangesIntersect([from, to], oselection)) {
+ return RequestRangeResult.CURSOR_INSIDE;
+ }
+ }
+ this._quickFoldHint.push(cfrom.line);
+ return RequestRangeResult.OK;
+ };
+ /**
+ * Fold everything!
+ *
+ * @param toLine last line to fold. Inclusive
+ */
+ Fold.prototype.startFoldImmediately = function (fromLine, toLine) {
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
+ var _this = this;
+ var cm = this.cm;
+ var viewPort = cm.getViewport();
+ // nil: if no from/to is passed, only scan the visible viewport, rather than the entire file
+ fromLine = fromLine >= 0 ? fromLine : viewPort.from; // cm.firstLine();
+ toLine = (toLine >= 0 ? toLine : viewPort.to) + 1; // cm.lastLine()) + 1;
+ this._quickFoldHint = [];
+ this.setPos(fromLine, 0, true);
+ cm.operation(function () {
+ return cm.eachLine(fromLine, toLine, function (line) {
+ var lineNo = line.lineNo();
+ if (lineNo < _this.lineNo) return;
+ // skip current line...
+ else if (lineNo > _this.lineNo) _this.setPos(lineNo, 0); // hmmm... maybe last one is empty line
+ // all the not-foldable chars are marked
+ var charMarked = new FlagArray(line.text.length);
+ {
+ // populate charMarked array.
+ // @see CodeMirror's findMarksAt
+ var lineMarkers = line.markedSpans;
+ if (lineMarkers) {
+ // nil: filter out any text selection markers so that we don't bug out the entire fold logic, ugh
+ lineMarkers = lineMarkers.filter(markedSpan => markedSpan.marker.className !== "CodeMirror-selectedtext");
+ for (var i = 0; i < lineMarkers.length; ++i) {
+ var span = lineMarkers[i];
+ var spanFrom = span.from == null ? 0 : span.from;
+ var spanTo = span.to == null ? charMarked.length : span.to;
+ for (var j = spanFrom; j < spanTo; j++) charMarked[j] = 1;
+ }
+ }
+ }
+ var tokens = _this.lineTokens;
+ while (_this.i_token < tokens.length) {
+ var token = tokens[_this.i_token];
+ var type;
+ var marker = null;
+ var tokenFoldable = true;
+ {
+ for (var i = token.start; i < token.end; i++) {
+ if (charMarked[i]) {
+ tokenFoldable = false;
+ break;
+ }
+ }
+ }
+ if (tokenFoldable) {
+ // try all enabled folders in registry
+ for (type in exports.folderRegistry) {
+ if (!_this._enabled[type]) continue;
+ if ((marker = exports.folderRegistry[type](_this, token))) break;
+ }
+ }
+ if (!marker) {
+ // this token not folded. check next
+ _this.i_token++;
+ } else {
+ var _a = marker.find(),
+ from = _a.from,
+ to = _a.to;
+ (_this.folded[type] || (_this.folded[type] = [])).push(marker);
+ marker._hmd_fold_type = type;
+ marker._hmd_crange = _this._lastCRange;
+ marker.on("clear", function (from, to) {
+ var markers = _this.folded[type];
+ var idx;
+ if (markers && (idx = markers.indexOf(marker)) !== -1) markers.splice(idx, 1);
+ _this._quickFoldHint.push(from.line);
+ });
+ // now let's update the pointer position
+ if (from.line > lineNo || from.ch > token.start) {
+ // there are some not-marked chars after current token, before the new marker
+ // first, advance the pointer
+ _this.i_token++;
+ // then mark the hidden chars as "marked"
+ var fromCh = from.line === lineNo ? from.ch : charMarked.length;
+ var toCh = to.line === lineNo ? to.ch : charMarked.length;
+ for (var i = fromCh; i < toCh; i++) charMarked[i] = 1;
+ } else {
+ // classical situation
+ // new marker starts since current token
+ if (to.line !== lineNo) {
+ _this.setPos(to.line, to.ch);
+ return; // nothing left in this line
+ } else {
+ _this.setPos(to.ch); // i_token will be updated by this.setPos()
+ }
+ }
+ }
+ }
+ });
+ });
+ };
+ /**
+ * Start a quick fold: only process recent `requestRange`-failed ranges
+ */
+ Fold.prototype.startQuickFold = function () {
+ var hint = this._quickFoldHint;
+ if (hint.length === 0) return;
+ var from = hint[0],
+ to = from;
+ for (var _i = 0, hint_1 = hint; _i < hint_1.length; _i++) {
+ var lineNo = hint_1[_i];
+ if (from > lineNo) from = lineNo;
+ if (to < lineNo) to = lineNo;
+ }
+ this.startFold.stop();
+ this.startFoldImmediately(from, to);
+ };
+ /**
+ * Clear one type of folded TextMarkers
+ *
+ * @param type builtin folder type ("image", "link" etc) or custom fold type
+ */
+ Fold.prototype.clear = function (type) {
+ this.startFold.stop();
+ var folded = this.folded[type];
+ if (!folded || !folded.length) return;
+ var marker;
+ while ((marker = folded.pop())) marker.clear();
+ };
+ /**
+ * Clear all folding result
+ */
+ Fold.prototype.clearAll = function () {
+ this.startFold.stop();
+ for (var type in this.folded) {
+ var folded = this.folded[type];
+ var marker;
+ while ((marker = folded.pop())) marker.clear();
+ }
+ };
+ return Fold;
+ })(core_1.TokenSeeker);
+ exports.Fold = Fold;
+ //#endregion
+ /** ADDON GETTER (Singleton Pattern): a editor can have only one Fold instance */
+ exports.getAddon = core_1.Addon.Getter("Fold", Fold);
+});
+
+// HyperMD, copyright (c) by laobubu
+// Distributed under an MIT license: http://laobubu.net/HyperMD/LICENSE
+//
+// DESCRIPTION: Fold URL of links `[text](url)`
+//
+
+(function (mod){ //[HyperMD] UMD patched!
+ /*plain env*/ mod(null, {}, HyperMD.Fold, HyperMD);
+})(function (require, exports, fold_1, core_1) {
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.LinkFolder = void 0;
+ var LinkFolder = function (stream, token) {
+ var cm = stream.cm;
+ // a valid beginning must be ...
+ if (!((token.string === "[" && // the leading [
+ token.state.linkText && // (double check) is link text
+ !token.state.linkTitle && // (double check) not image's title
+ !/\bimage\b/.test(token.type)) // and is not a image mark
+ ))
+ return null;
+ var spanExtractor = core_1.getLineSpanExtractor(cm);
+ // first, find the link text span
+ var linkTextSpan = spanExtractor.findSpanWithTypeAt({ line: stream.lineNo, ch: token.start }, "linkText");
+ if (!linkTextSpan)
+ return null;
+ // then find the link href span
+ var linkHrefSpan = spanExtractor.findSpanWithTypeAt({ line: stream.lineNo, ch: linkTextSpan.end + 1 }, "linkHref");
+ if (!linkHrefSpan)
+ return null;
+ // now compose the ranges
+ var hrefFrom = { line: stream.lineNo, ch: linkHrefSpan.begin };
+ var hrefTo = { line: stream.lineNo, ch: linkHrefSpan.end };
+ var linkFrom = { line: stream.lineNo, ch: linkTextSpan.begin };
+ // const linkTo: Position = { line: stream.lineNo, ch: linkTextSpan.end };
+ // and check if the range is OK
+ var rngReq = stream.requestRange(hrefFrom, hrefTo, linkFrom, hrefFrom);
+ if (rngReq !== fold_1.RequestRangeResult.OK)
+ return null;
+ // everything is OK! make the widget
+ var text = cm.getRange(hrefFrom, hrefTo);
+ var _a = splitLink(text.substr(1, text.length - 2)), url = _a.url, title = _a.title;
+ var imgElem = document.createElement("span");
+ imgElem.setAttribute("class", "hmd-link-icon");
+ imgElem.setAttribute("title", url + "\n" + title);
+ imgElem.setAttribute("data-url", url);
+ var marker = cm.markText(hrefFrom, hrefTo, {
+ collapsed: true,
+ replacedWith: imgElem,
+ });
+ imgElem.addEventListener("click", function () { return fold_1.breakMark(cm, marker); }, false);
+ return marker;
+ };
+ function splitLink(content) {
+ // remove title part (if exists)
+ content = content.trim();
+ var url = content, title = "";
+ var mat = content.match(/^(\S+)\s+("(?:[^"\\]+|\\.)+"|[^"\s].*)/);
+ if (mat) {
+ url = mat[1];
+ title = mat[2];
+ if (title.charAt(0) === '"')
+ title = title.substr(1, title.length - 2).replace(/\\"/g, '"');
+ }
+ return { url: url, title: title };
+ }
+ exports.LinkFolder = LinkFolder;
+ fold_1.registerFolder("link", exports.LinkFolder, true);
+});
+
+// HyperMD, copyright (c) by laobubu
+// Distributed under an MIT license: http://laobubu.net/HyperMD/LICENSE
+//
+// DESCRIPTION: Fold Image Markers ``
+//
+
+(function (mod) {
+ mod(null, {}, CodeMirror, HyperMD.Fold, HyperMD.ReadLink);
+})(function (require, exports, CodeMirror, fold_1) {
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.ImageFolder = void 0;
+ var ImageFolder = function (stream, token) {
+ var cm = stream.cm;
+ var imgRE = /(\bimage-marker\b)|(\bformatting-embed\b)/;
+ var extRE = /\.(jpe?g|png|gif|svg|bmp)/;
+ var urlRE = /(\bformatting-link-string\b)|(\bformatting-link\b)/; // matches the parentheses
+ if (imgRE.test(token.type) && (token.string === "!" || token.string === "![[")) {
+ var lineNo = stream.lineNo;
+ // find the begin and end of url part
+ var since = { line: lineNo, ch: token.start };
+ var url_begin = stream.findNext(urlRE, 0, since);
+ if (!url_begin) {
+ return null;
+ }
+ // var url_end = stream.findNext(urlRE, url_begin.i_token + 1);
+ var url_end = stream.findNext(urlRE, url_begin.i_token + 1);
+ var from = { line: lineNo, ch: token.start };
+ var to = { line: lineNo, ch: url_end.token.end };
+ var rngReq = stream.requestRange(from, to, from, from);
+ if (rngReq === fold_1.RequestRangeResult.OK) {
+ var url = void 0;
+ var alt = void 0;
+ var title = void 0;
+ var dimensions = void 0;
+ {
+ // extract the URL
+ var rawurl = cm.getRange(
+ // get the URL or footnote name in the parentheses
+ { line: lineNo, ch: url_begin.token.end },
+ { line: lineNo, ch: url_end.token.start }
+ );
+ if (!extRE.test(rawurl)) return null;
+ if (url_end.token.string === "]") {
+ var tmp = cm.hmdReadLink(rawurl, lineNo);
+ if (!tmp) return null; // Yup! bad URL?!
+ rawurl = tmp.content;
+ }
+ var split = splitLink(rawurl);
+ url = split.url;
+ title = split.title;
+ var _matches;
+ if ((_matches = url.match(/^([^|]+)\|(.*)$/))) {
+ url = _matches[1];
+ dimensions = _matches[2];
+ }
+ }
+ {
+ // extract the alt
+ alt = cm.getRange({ line: lineNo, ch: from.ch + 2 }, { line: lineNo, ch: url_begin.token.start - 1 });
+ }
+ var _altMatches;
+ if ((_altMatches = alt.match(/^(?:([^|]*)\|)?([0-9x]+)$/))) {
+ dimensions = _altMatches[2];
+ }
+ var img = document.createElement("img");
+ var marker = cm.markText(from, to, {
+ collapsed: true,
+ clearOnEnter: true,
+ replacedWith: img,
+ // inclusiveLeft: true,
+ // inclusiveRight: true,
+ });
+ img.addEventListener(
+ "load",
+ function () {
+ img.classList.remove("hmd-image-loading");
+ marker.changed();
+ },
+ false
+ );
+ img.addEventListener(
+ "error",
+ function () {
+ img.classList.remove("hmd-image-loading");
+ img.classList.add("hmd-image-error");
+ marker.changed();
+ },
+ false
+ );
+ img.className = "hmd-image hmd-image-loading";
+ img.addEventListener(
+ "click",
+ function () {
+ return fold_1.breakMark(cm, marker);
+ // CodeMirror.signal(cm, "imageClicked", {
+ // editor: cm,
+ // marker: marker,
+ // breakMark: fold_1.breakMark,
+ // element: img,
+ // });
+ },
+ false
+ );
+ img.alt = alt;
+ img.title = title;
+ var _url, _resolvedUrl;
+ if (/^(app|http|https):\/\//.test(url)) {
+ _url = url;
+ } else {
+ _resolvedUrl = window.app.metadataCache.getFirstLinkpathDest(decodeURIComponent(url), "");
+ if (_resolvedUrl) {
+ _url = window.app.vault.getResourcePath(_resolvedUrl);
+ } else {
+ _url = "";
+ img.alt = "⚠️";
+ }
+ }
+
+ img.setAttribute("data-src", _url);
+ if (_resolvedUrl && _resolvedUrl.path) img.setAttribute("data-path", _resolvedUrl.path);
+ img.setAttribute("src", _url);
+ if (dimensions) {
+ var _dims = dimensions.match(/^([0-9]+)x?([0-9]+)?$/);
+ var width = _dims[1] ? `width: ${_dims[1]}px;` : "";
+ var height = _dims[2] ? `height: ${_dims[2]}px;` : "";
+ img.setAttribute("style", `${width} ${height}`);
+ }
+ CodeMirror.signal(cm, "imageReadyToLoad", {
+ editor: cm,
+ marker: marker,
+ breakMark: fold_1.breakMark,
+ element: img,
+ });
+ return marker;
+ }
+ }
+ return null;
+ };
+ function splitLink(content) {
+ // support  syntax
+ // remove title part (if exists)
+ content = content.trim();
+ var url = content,
+ title = "";
+ var mat = content.match(/^([^"]+)("(?:[^"\\]+|\\.)+"|[^"\s].*)?/);
+ if (mat) {
+ url = mat[1];
+ title = mat[2] ? mat[2] : "";
+ if (title.charAt(0) === '"') title = title.substr(1, title.length - 2).replace(/\\"/g, '"');
+ }
+ return { url: url, title: title };
+ }
+ exports.ImageFolder = ImageFolder;
+ fold_1.registerFolder("image", exports.ImageFolder, true);
+});
+
+// HyperMD, copyright (c) by laobubu
+// Distributed under an MIT license: http://laobubu.net/HyperMD/LICENSE
+//
+// DESCRIPTION: Turn code blocks into flow charts / playground sandboxes etc.
+//
+
+(function (mod) {
+ mod(null, (HyperMD.FoldCode = HyperMD.FoldCode || {}), CodeMirror, HyperMD, HyperMD.Fold);
+})(function (require, exports, CodeMirror, core_1, fold_1) {
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.getAddon =
+ exports.convertNumberToString =
+ exports.FoldCode =
+ exports.suggestedOption =
+ exports.defaultOption =
+ exports.CodeFolder =
+ exports.registerRenderer =
+ exports.rendererRegistry =
+ void 0;
+ exports.rendererRegistry = {};
+ /**
+ * Add a CodeRenderer to the System CodeRenderer Registry
+ *
+ * @param lang
+ * @param folder
+ * @param suggested enable this folder in suggestedEditorConfig
+ * @param force if a folder with same name is already exists, overwrite it. (dangerous)
+ */
+ function registerRenderer(info, force) {
+ if (!info || !info.name || !info.renderer) return;
+ var name = info.name;
+ var pattern = info.pattern;
+ var registry = exports.rendererRegistry;
+ if (name in registry) {
+ if (!force) {
+ throw new Error("CodeRenderer " + name + " already exists");
+ }
+ }
+ if (typeof pattern === "string") {
+ var t_1 = pattern.toLowerCase();
+ pattern = function (lang) {
+ return lang.toLowerCase() === t_1;
+ };
+ } else if (pattern instanceof RegExp) {
+ pattern = function (lang) {
+ return info.pattern.test(lang);
+ };
+ }
+ var newInfo = {
+ name: name,
+ suggested: !!info.suggested,
+ pattern: pattern,
+ renderer: info.renderer,
+ };
+ registry[name] = newInfo;
+ exports.defaultOption[name] = false;
+ exports.suggestedOption[name] = newInfo.suggested;
+ }
+ exports.registerRenderer = registerRenderer;
+ //#endregion
+ //#region FolderFunc for Addon/Fold -----------------------------------------------------
+ /** the FolderFunc for Addon/Fold */
+ var CodeFolder = function (stream, token) {
+ if (
+ token.start !== 0 ||
+ !token.type ||
+ token.type.indexOf("HyperMD-codeblock-begin") === -1 ||
+ !/([-\w]+)(\s*|\s+\{.+\}\s*)$/.test(token.string)
+ ) {
+ return null;
+ }
+ return exports.getAddon(stream.cm).fold(stream, token);
+ };
+ exports.CodeFolder = CodeFolder;
+ fold_1.registerFolder("code", exports.CodeFolder, true);
+ exports.defaultOption = {
+ /* will be populated by registerRenderer() */
+ };
+ exports.suggestedOption = {
+ /* will be populated by registerRenderer() */
+ };
+ core_1.suggestedEditorConfig.hmdFoldCode = exports.suggestedOption;
+ CodeMirror.defineOption("hmdFoldCode", exports.defaultOption, function (cm, newVal) {
+ ///// convert newVal's type to `Record`, if it is not.
+ if (!newVal || typeof newVal === "boolean") {
+ newVal = newVal ? exports.suggestedOption : exports.defaultOption;
+ }
+ ///// apply config
+ var inst = exports.getAddon(cm);
+ for (var type in exports.rendererRegistry) {
+ inst.setStatus(type, newVal[type]);
+ }
+ // then, folding task will be queued by setStatus()
+ });
+ var FoldCode = /** @class */ (function () {
+ function FoldCode(cm) {
+ this.cm = cm;
+ /**
+ * stores renderer status for current editor
+ * @private To enable/disable renderer, use `setStatus()`
+ */
+ this._enabled = {};
+ /** renderers' output goes here */
+ this.folded = {};
+ }
+ /** enable/disable one kind of renderer, in current editor */
+ FoldCode.prototype.setStatus = function (type, enabled) {
+ if (!(type in exports.rendererRegistry)) return;
+ if (!this._enabled[type] !== !enabled) {
+ this._enabled[type] = !!enabled;
+ if (enabled) fold_1.getAddon(this.cm).startFold();
+ else this.clear(type);
+ }
+ };
+ /** Clear one type of rendered TextMarkers */
+ FoldCode.prototype.clear = function (type) {
+ var folded = this.folded[type];
+ if (!folded || !folded.length) return;
+ var info;
+ while ((info = folded.pop())) info.marker.clear();
+ };
+ FoldCode.prototype.fold = function (stream, token) {
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
+ var _this = this;
+ if (token.start !== 0 || !token.type || token.type.indexOf("HyperMD-codeblock-begin") === -1) {
+ return null;
+ }
+ var tmp = /([-\w]+)(\s*|\s+\{.+\}\s*)$/.exec(token.string);
+ var lang = tmp && tmp[1].toLowerCase();
+ var attributesStr = tmp && tmp[2] && tmp[2].trim();
+ var attributes = {};
+ if (attributesStr && attributesStr.length) {
+ attributes = fold_1.parseAttributes(attributesStr);
+ }
+ if (!lang) return null;
+ var renderer;
+ var type;
+ var cm = this.cm,
+ registry = exports.rendererRegistry,
+ _enabled = this._enabled;
+ for (var type_i in registry) {
+ var r = registry[type_i];
+ if (!_enabled[type_i]) continue;
+ if (!r.pattern(lang)) continue;
+ type = type_i;
+ renderer = r.renderer;
+ break;
+ }
+ if (!type) return null;
+ var from = { line: stream.lineNo, ch: 0 };
+ var to = null;
+ // find the end of code block
+ var lastLineCM = cm.lastLine();
+ var endLine = stream.lineNo + 1;
+ do {
+ var s = cm.getTokenAt({ line: endLine, ch: 1 });
+ if (s && s.type && s.type.indexOf("HyperMD-codeblock-end") !== -1) {
+ //FOUND END!
+ to = { line: endLine, ch: s.end };
+ break;
+ }
+ } while (++endLine < lastLineCM);
+ if (!to) return null;
+ // request the range
+ var rngReq = stream.requestRange(from, to);
+ if (rngReq !== fold_1.RequestRangeResult.OK) return null;
+ // now we can call renderer
+ var code = cm.getRange({ line: from.line + 1, ch: 0 }, { line: to.line, ch: 0 });
+ var info = {
+ editor: cm,
+ lang: lang,
+ attributes: attributes,
+ marker: null,
+ lineWidget: null,
+ el: null,
+ break: undefined_function,
+ changed: undefined_function,
+ };
+ var _a = renderer(code, info),
+ element = _a.element,
+ asyncRenderer = _a.asyncRenderer;
+ info.el = element;
+ var el = element;
+ if (!el) {
+ info.marker.clear();
+ return null;
+ }
+ //-----------------------------
+
+ var $wrapper = document.createElement("div");
+ $wrapper.className = contentClass + type;
+ $wrapper.style.minHeight = "1em";
+ $wrapper.appendChild(el);
+
+ var lineWidget = (info.lineWidget = cm.addLineWidget(to.line, $wrapper, {
+ above: false,
+ coverGutter: false,
+ handleMouseEvents: false,
+ className: "rendered-code-block rendered-widget",
+ noHScroll: false,
+ showIfHidden: false,
+ }));
+ if (asyncRenderer) {
+ asyncRenderer();
+ }
+ var wrapperLine = stream.lineNo;
+
+ cm.addLineClass(wrapperLine, "wrap", "rendered-code-block-wrapper");
+ cm.addLineClass(wrapperLine, "wrap", `rendered-${type}-wrapper`);
+ // watch for any changes to the widget wrapper or its children
+ // so that we can call widget.changed() to remeasure the element
+ // and prevent any cursor placement issues
+ // this allows our widget to shrink or grow to any size we want
+ this.widgetChanged = core_1.debounce(() => {
+ // console.log("widget change detected: " + this.lineWidget.node.className);
+ try {
+ this.lineWidget.changed();
+ } catch {
+ // console.log("widget change failed");
+ }
+ }, 250);
+ // we're using MutationObserver rather than ResizeObserver here
+ // due to ResizeObserver causing a memory leak due to holding refs
+ const observer = new MutationObserver((mutations, observer) => {
+ // mutations.forEach(el => {
+ // console.log(el.target.classList.value);
+ // });
+ this.lineWidget = lineWidget;
+ this.widgetChanged();
+ });
+ observer.observe($wrapper, { childList: true, subtree: true, attributes: true });
+ //-----------------------------
+ var $stub = document.createElement("span");
+ $stub.className = stubClass + type;
+ $stub.textContent = "";
+ var marker = (info.marker = cm.markText(from, to, {
+ replacedWith: $stub,
+ inclusiveLeft: true,
+ inclusiveRight: true,
+ }));
+ // $wrapper.addEventListener("mouseenter", highlightON, false);
+ // $wrapper.addEventListener("mouseleave", highlightOFF, false);
+ info.changed = function () {
+ lineWidget.changed();
+ };
+ info.break = function () {
+ observer.disconnect();
+ fold_1.breakMark(cm, marker);
+ };
+ $stub.addEventListener("click", info.break, false);
+ marker.on("clear", function () {
+ var markers = _this.folded[type];
+ var idx;
+ if (markers && (idx = markers.indexOf(info)) !== -1) markers.splice(idx, 1);
+ if (typeof info.onRemove === "function") info.onRemove(info);
+ cm.addLineClass(wrapperLine, "wrap", `rendered-${type}-wrapper`);
+ cm.removeLineClass(wrapperLine, "wrap", "rendered-code-block-wrapper");
+ observer.disconnect();
+ lineWidget.clear();
+ });
+ if (!(type in this.folded)) this.folded[type] = [info];
+ else this.folded[type].push(info);
+ return marker;
+ };
+ return FoldCode;
+ })();
+ exports.FoldCode = FoldCode;
+ //#endregion
+ // End
+ var contentClass = "hmd-fold-code-content hmd-fold-code-"; // + renderer_type
+ var stubClass = "hmd-fold-code-stub hmd-fold-code-"; // + renderer_type
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
+ var undefined_function = function () {};
+ /** ADDON GETTER (Singleton Pattern): a editor can have only one FoldCode instance */
+ exports.getAddon = core_1.Addon.Getter("FoldCode", FoldCode, exports.defaultOption /** if has options */);
+});
+
+// HyperMD, copyright (c) by laobubu
+// Distributed under an MIT license: http://laobubu.net/HyperMD/LICENSE
+//
+// DESCRIPTION: Fold and render embedded HTML snippets
+
+(function (mod) {
+ //[HyperMD] UMD patched!
+ /*plain env*/ mod(null, (HyperMD.FoldHTML = HyperMD.FoldHTML || {}), CodeMirror, HyperMD, HyperMD.Fold);
+})(function (require, exports, CodeMirror, core_1, fold_1) {
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.getAddon =
+ exports.FoldHTML =
+ exports.suggestedOption =
+ exports.defaultOption =
+ exports.HTMLFolder =
+ exports.defaultRenderer =
+ exports.defaultChecker =
+ void 0;
+
+ const purifySettings = {
+ ALLOW_UNKNOWN_PROTOCOLS: true,
+ IN_PLACE: true,
+ // RETURN_DOM_FRAGMENT: true,
+ // RETURN_DOM_IMPORT: true,
+ FORBID_TAGS: ["style"],
+ ADD_TAGS: ["iframe"],
+ ADD_ATTR: ["frameborder", "allowfullscreen", "allow", "aria-label-position"],
+ };
+ // export type CheckerFunc = (html: string, pos: Position, cm: cm_t) => boolean;
+ var defaultChecker = function (html) {
+ // TODO: Remove this since we're now using DOMPurify?
+ if (/^<(?:br)/i.test(html)) {
+ return false; // check first element...
+ }
+ if (/<(?:script|style|link|meta|object|embed)/i.test(html)) {
+ // TODO: dyamically add/remove iframe block
+ return false; // don't allow some tags
+ }
+ if (/\son\w+\s*=/i.test(html)) {
+ return false; // don't allow `onclick=` etc.
+ }
+ if (/(src|background|href)\s*=\s*["']?javascript:/i.test(html)) {
+ return false; // don't allow `src="javascript:` etc.
+ }
+ return true;
+ };
+ exports.defaultChecker = defaultChecker;
+ /**
+ * Create HTMLElement from HTML string and do special process with HyperMD.ReadLink
+ */
+ var defaultRenderer = function (html, pos, cm) {
+ var tagBegin = /^<(\w+)\s*/.exec(html);
+ if (!tagBegin) return null;
+ var tagName = tagBegin[1];
+ var ans = document.createElement(tagName);
+ var propRE = /([\w\:\-]+)(?:\s*=\s*((['"]).*?\3|\S+))?\s*/g;
+ var propLastIndex = (propRE.lastIndex = tagBegin[0].length);
+ var tmp;
+ while ((tmp = propRE.exec(html))) {
+ if (tmp.index > propLastIndex) break; // emmm
+ var propName = tmp[1];
+ var propValue = tmp[2]; // could be wrapped by " or '
+ if (propValue && /^['"]/.test(propValue)) propValue = propValue.slice(1, -1);
+ ans.setAttribute(propName, propValue);
+ propLastIndex = propRE.lastIndex;
+ }
+ if ("innerHTML" in ans) {
+ // node may contain innerHTML
+ var startCh = html.indexOf(">", propLastIndex) + 1;
+ var endCh = html.length;
+ if ((tmp = new RegExp("" + tagName + "\\s*>\\s*$", "i").exec(html))) {
+ endCh = tmp.index;
+ }
+ var innerHTML = html.slice(startCh, endCh);
+ if (innerHTML) {
+ ans.innerHTML = innerHTML;
+ }
+ window.DOMPurify.sanitize(ans, purifySettings);
+ // ans.replaceWith(cleanHTML);
+ // resolve relative URLs and change default behavoirs
+ core_1.visitElements([ans], function (el) {
+ var tagName = el.tagName.toLowerCase();
+ if (tagName === "a") {
+ // for links, if target not set, add target="_blank"
+ if (!el.getAttribute("target")) el.setAttribute("target", "_blank");
+ }
+ // Then, resovle relative URLs
+ var urlAttrs = {
+ a: ["href"],
+ img: ["src"],
+ iframe: ["src"],
+ }[tagName];
+ if (urlAttrs) {
+ for (var i = 0; i < urlAttrs.length; i++) {
+ var _url, _resolvedUrl;
+ var attr = urlAttrs[i];
+ var attrValue = el.getAttribute(attr);
+ _resolvedUrl = window.app.metadataCache.getFirstLinkpathDest(decodeURI(attrValue), "");
+ if (_resolvedUrl) {
+ _url = window.app.vault.getResourcePath(_resolvedUrl);
+ } else {
+ _url = "";
+ }
+ if (_url) {
+ el.setAttribute(attr, decodeURI(attrValue));
+ el.addClass("internal-link");
+ }
+ }
+ }
+ });
+ }
+ return ans;
+ };
+ exports.defaultRenderer = defaultRenderer;
+ /********************************************************************************** */
+ var stubClass = "hmd-fold-html-stub";
+ var stubClassOmittable = "hmd-fold-html-stub omittable";
+ /********************************************************************************** */
+ //#region Folder
+ /**
+ * Detect if a token is a beginning of HTML, and fold it!
+ *
+ * @see FolderFunc in ./fold.ts
+ */
+ var HTMLFolder = function (stream, token) {
+ if (!token.type || !/ hmd-html-begin/.test(token.type)) return null;
+ var endInfo = stream.findNext(/ hmd-html-\w+/, true); // find next html start/end token
+ if (!endInfo || !/ hmd-html-end/.test(endInfo.token.type) || / hmd-html-unclosed/.test(endInfo.token.type))
+ return null;
+ var cm = stream.cm;
+ var from = { line: stream.lineNo, ch: token.start };
+ var to = { line: endInfo.lineNo, ch: endInfo.token.end };
+ var inlineMode = from.ch != 0 || to.ch < cm.getLine(to.line).length;
+
+ var addon = exports.getAddon(cm);
+ var html = cm.getRange(from, to);
+
+ var reqAns = stream.requestRange(from, to);
+ if (reqAns !== fold_1.RequestRangeResult.OK) return null;
+
+ // now we are ready to fold and render!
+ var marker = addon.renderAndInsert(html, from, to, inlineMode);
+ return marker;
+ };
+ exports.HTMLFolder = HTMLFolder;
+ //#endregion
+ fold_1.registerFolder("html", exports.HTMLFolder, false);
+ exports.defaultOption = {
+ checker: exports.defaultChecker,
+ renderer: exports.defaultRenderer,
+ stubText: "",
+ isolatedTagName: /^(?:div|pre|form|mark|table|iframe|ul|ol|input|textarea|p|summary|a)$/i,
+ };
+ exports.suggestedOption = {};
+ core_1.suggestedEditorConfig.hmdFoldHTML = exports.suggestedOption;
+ CodeMirror.defineOption("hmdFoldHTML", exports.defaultOption, function (cm, newVal) {
+ ///// convert newVal's type to `Partial`, if it is not.
+ if (!newVal) {
+ newVal = {};
+ } else if (typeof newVal == "function") {
+ newVal = { checker: newVal };
+ } else if (typeof newVal != "object") {
+ console.warn("[HyperMD][FoldHTML] incorrect option value type");
+ newVal = {};
+ }
+ ///// apply config and write new values into cm
+ var inst = exports.getAddon(cm);
+ for (var k in exports.defaultOption) {
+ inst[k] = k in newVal ? newVal[k] : exports.defaultOption[k];
+ }
+ ///// Type Check
+ if (inst.isolatedTagName && !(inst.isolatedTagName instanceof RegExp)) {
+ if (window["ECHOMD_DEBUG"]) {
+ console.error("[HyperMD][FoldHTML] option isolatedTagName only accepts RegExp");
+ }
+ inst.isolatedTagName = exports.defaultOption.isolatedTagName;
+ }
+ });
+ //#endregion
+ /********************************************************************************** */
+ //#region Addon Class
+ var FoldHTML = /** @class */ (function () {
+ function FoldHTML(cm) {
+ this.cm = cm;
+ // options will be initialized to defaultOption when constructor is finished
+ }
+ /**
+ * Render HTML, insert into editor and return the marker
+ */
+ FoldHTML.prototype.renderAndInsert = function (html, from, to, inlineMode) {
+ var cm = this.cm;
+ var stub = this.makeStub();
+ var el = this.renderer(html, from, cm);
+ var breakFn = function () {
+ return fold_1.breakMark(cm, marker);
+ };
+ if (!el) return null;
+ stub.addEventListener("click", breakFn, false);
+ if (!el.tagName.match(this.isolatedTagName || /^$/)) el.addEventListener("click", breakFn, false);
+ var replacedWith;
+ var marker;
+ var isBlock = false;
+ if (inlineMode) {
+ /** put HTML inline */
+ var span = document.createElement("span");
+ span.setAttribute("class", "hmd-fold-html rendered-widget");
+ span.setAttribute("style", "display: inline-flex");
+ span.appendChild(stub);
+ span.appendChild(el);
+
+ replacedWith = span;
+ /** If element size changed, we notify CodeMirror */
+ var watcher = core_1.watchSize(el, function (w, h) {
+ var computedStyle = getComputedStyle(el);
+ var getStyle = function (name) {
+ return computedStyle.getPropertyValue(name);
+ };
+ var floating =
+ w < 10 || h < 10 || !/^relative|static$/i.test(getStyle("position")) || !/^none$/i.test(getStyle("float"));
+ if (!floating) stub.className = stubClassOmittable;
+ else stub.className = stubClass;
+ marker.changed();
+ });
+ watcher.check(); // trig the checker once
+ // Marker is not created yet. Bind events later
+ setTimeout(function () {
+ marker.on("clear", function () {
+ watcher.stop();
+ });
+ }, 0);
+ } else {
+ isBlock = true;
+ /** use lineWidget to insert element */
+ replacedWith = stub;
+ // this causes any text selection to immediately stop if the cursor is coming out of a block html element
+ // without this, the line widget will get duplicated on cursor selection. see issue #51
+ if (cm.state.selectingText) cm.state.selectingText();
+ var lineWidget_1 = cm.addLineWidget(to.line, el, {
+ above: false,
+ coverGutter: false,
+ className: "rendered-html rendered-html-block rendered-widget",
+ noHScroll: false,
+ showIfHidden: false,
+ });
+ var wrapperLine = from.line;
+ cm.addLineClass(wrapperLine, "wrap", "rendered-html-block-wrapper");
+ // var highlightON_1 = function () {
+ // return (stub.className = stubClassHighlight);
+ // };
+ // var highlightOFF_1 = function () {
+ // return (stub.className = stubClass);
+ // };
+ // el.addEventListener("mouseenter", highlightON_1, false);
+ // el.addEventListener("mouseleave", highlightOFF_1, false);
+ var watcher = core_1.watchSize(el, function () {
+ return lineWidget_1.changed();
+ });
+ watcher.check();
+ // Marker is not created yet. Bind events later
+ setTimeout(function () {
+ marker.on("clear", function () {
+ watcher.stop();
+ lineWidget_1.clear();
+ cm.removeLineClass(wrapperLine, "wrap", "rendered-html-block-wrapper");
+ // el.removeEventListener("mouseenter", highlightON_1, false);
+ // el.removeEventListener("mouseleave", highlightOFF_1, false);
+ });
+ }, 0);
+ }
+ marker = cm.markText(from, to, {
+ replacedWith: replacedWith,
+ atomic: false,
+ inclusiveLeft: isBlock,
+ inclusiveRight: isBlock,
+ });
+ return marker;
+ };
+ FoldHTML.prototype.makeStub = function () {
+ var ans = document.createElement("span");
+ ans.setAttribute("class", stubClass);
+ ans.textContent = this.stubText || "";
+ return ans;
+ };
+ return FoldHTML;
+ })();
+ exports.FoldHTML = FoldHTML;
+ //#endregion
+ /** ADDON GETTER (Singleton Pattern): a editor can have only one FoldHTML instance */
+ exports.getAddon = core_1.Addon.Getter("FoldHTML", FoldHTML, exports.defaultOption /** if has options */);
+});
+
+const debug = (
+ typeof process === 'object' &&
+ process.env &&
+ process.env.NODE_DEBUG &&
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)
+) ? (...args) => console.error('SEMVER', ...args)
+ : () => {};
+
+var debug_1 = debug;
+
+// Note: this is the semver.org version of the spec that it implements
+// Not necessarily the package version of this code.
+const SEMVER_SPEC_VERSION = '2.0.0';
+
+const MAX_LENGTH$1 = 256;
+const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
+ /* istanbul ignore next */ 9007199254740991;
+
+// Max safe segment length for coercion.
+const MAX_SAFE_COMPONENT_LENGTH = 16;
+
+var constants = {
+ SEMVER_SPEC_VERSION,
+ MAX_LENGTH: MAX_LENGTH$1,
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
+ MAX_SAFE_COMPONENT_LENGTH
+};
+
+var re_1 = createCommonjsModule(function (module, exports) {
+const { MAX_SAFE_COMPONENT_LENGTH } = constants;
+
+exports = module.exports = {};
+
+// The actual regexps go on exports.re
+const re = exports.re = [];
+const src = exports.src = [];
+const t = exports.t = {};
+let R = 0;
+
+const createToken = (name, value, isGlobal) => {
+ const index = R++;
+ debug_1(index, value);
+ t[name] = index;
+ src[index] = value;
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
+};
+
+// The following Regular Expressions can be used for tokenizing,
+// validating, and parsing SemVer version strings.
+
+// ## Numeric Identifier
+// A single `0`, or a non-zero digit followed by zero or more digits.
+
+createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
+createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
+
+// ## Non-numeric Identifier
+// Zero or more digits, followed by a letter or hyphen, and then zero or
+// more letters, digits, or hyphens.
+
+createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
+
+// ## Main Version
+// Three dot-separated numeric identifiers.
+
+createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
+ `(${src[t.NUMERICIDENTIFIER]})\\.` +
+ `(${src[t.NUMERICIDENTIFIER]})`);
+
+createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
+
+// ## Pre-release Version Identifier
+// A numeric identifier, or a non-numeric identifier.
+
+createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
+}|${src[t.NONNUMERICIDENTIFIER]})`);
+
+createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
+}|${src[t.NONNUMERICIDENTIFIER]})`);
+
+// ## Pre-release Version
+// Hyphen, followed by one or more dot-separated pre-release version
+// identifiers.
+
+createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
+}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
+
+createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
+}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
+
+// ## Build Metadata Identifier
+// Any combination of digits, letters, or hyphens.
+
+createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
+
+// ## Build Metadata
+// Plus sign, followed by one or more period-separated build metadata
+// identifiers.
+
+createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
+}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
+
+// ## Full Version String
+// A main version, followed optionally by a pre-release version and
+// build metadata.
+
+// Note that the only major, minor, patch, and pre-release sections of
+// the version string are capturing groups. The build metadata is not a
+// capturing group, because it should not ever be used in version
+// comparison.
+
+createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
+}${src[t.PRERELEASE]}?${
+ src[t.BUILD]}?`);
+
+createToken('FULL', `^${src[t.FULLPLAIN]}$`);
+
+// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
+// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
+// common in the npm registry.
+createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
+}${src[t.PRERELEASELOOSE]}?${
+ src[t.BUILD]}?`);
+
+createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
+
+createToken('GTLT', '((?:<|>)?=?)');
+
+// Something like "2.*" or "1.2.x".
+// Note that "x.x" is a valid xRange identifer, meaning "any version"
+// Only the first item is strictly required.
+createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
+createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
+
+createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
+ `(?:${src[t.PRERELEASE]})?${
+ src[t.BUILD]}?` +
+ `)?)?`);
+
+createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
+ `(?:${src[t.PRERELEASELOOSE]})?${
+ src[t.BUILD]}?` +
+ `)?)?`);
+
+createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
+createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
+
+// Coercion.
+// Extract anything that could conceivably be a part of a valid semver
+createToken('COERCE', `${'(^|[^\\d])' +
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
+ `(?:$|[^\\d])`);
+createToken('COERCERTL', src[t.COERCE], true);
+
+// Tilde ranges.
+// Meaning is "reasonably at or greater than"
+createToken('LONETILDE', '(?:~>?)');
+
+createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
+exports.tildeTrimReplace = '$1~';
+
+createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
+createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
+
+// Caret ranges.
+// Meaning is "at least and backwards compatible with"
+createToken('LONECARET', '(?:\\^)');
+
+createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
+exports.caretTrimReplace = '$1^';
+
+createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
+createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
+
+// A simple gt/lt/eq thing, or just "" to indicate "any version"
+createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
+createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
+
+// An expression to strip any whitespace between the gtlt and the thing
+// it modifies, so that `> 1.2.3` ==> `>1.2.3`
+createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
+}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
+exports.comparatorTrimReplace = '$1$2$3';
+
+// Something like `1.2.3 - 1.2.4`
+// Note that these all use the loose form, because they'll be
+// checked against either the strict or loose comparator form
+// later.
+createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
+ `\\s+-\\s+` +
+ `(${src[t.XRANGEPLAIN]})` +
+ `\\s*$`);
+
+createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
+ `\\s+-\\s+` +
+ `(${src[t.XRANGEPLAINLOOSE]})` +
+ `\\s*$`);
+
+// Star ranges basically just allow anything at all.
+createToken('STAR', '(<|>)?=?\\s*\\*');
+// >=0.0.0 is like a star
+createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
+createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
+});
+
+// parse out just the options we care about so we always get a consistent
+// obj with keys in a consistent order.
+const opts = ['includePrerelease', 'loose', 'rtl'];
+const parseOptions = options =>
+ !options ? {}
+ : typeof options !== 'object' ? { loose: true }
+ : opts.filter(k => options[k]).reduce((options, k) => {
+ options[k] = true;
+ return options
+ }, {});
+var parseOptions_1 = parseOptions;
+
+const numeric = /^[0-9]+$/;
+const compareIdentifiers$1 = (a, b) => {
+ const anum = numeric.test(a);
+ const bnum = numeric.test(b);
+
+ if (anum && bnum) {
+ a = +a;
+ b = +b;
+ }
+
+ return a === b ? 0
+ : (anum && !bnum) ? -1
+ : (bnum && !anum) ? 1
+ : a < b ? -1
+ : 1
+};
+
+const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
+
+var identifiers = {
+ compareIdentifiers: compareIdentifiers$1,
+ rcompareIdentifiers
+};
+
+const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
+const { re, t } = re_1;
+
+
+const { compareIdentifiers } = identifiers;
+class SemVer {
+ constructor (version, options) {
+ options = parseOptions_1(options);
+
+ if (version instanceof SemVer) {
+ if (version.loose === !!options.loose &&
+ version.includePrerelease === !!options.includePrerelease) {
+ return version
+ } else {
+ version = version.version;
+ }
+ } else if (typeof version !== 'string') {
+ throw new TypeError(`Invalid Version: ${version}`)
+ }
+
+ if (version.length > MAX_LENGTH) {
+ throw new TypeError(
+ `version is longer than ${MAX_LENGTH} characters`
+ )
+ }
+
+ debug_1('SemVer', version, options);
+ this.options = options;
+ this.loose = !!options.loose;
+ // this isn't actually relevant for versions, but keep it so that we
+ // don't run into trouble passing this.options around.
+ this.includePrerelease = !!options.includePrerelease;
+
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
+
+ if (!m) {
+ throw new TypeError(`Invalid Version: ${version}`)
+ }
+
+ this.raw = version;
+
+ // these are actually numbers
+ this.major = +m[1];
+ this.minor = +m[2];
+ this.patch = +m[3];
+
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
+ throw new TypeError('Invalid major version')
+ }
+
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
+ throw new TypeError('Invalid minor version')
+ }
+
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
+ throw new TypeError('Invalid patch version')
+ }
+
+ // numberify any prerelease numeric ids
+ if (!m[4]) {
+ this.prerelease = [];
+ } else {
+ this.prerelease = m[4].split('.').map((id) => {
+ if (/^[0-9]+$/.test(id)) {
+ const num = +id;
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
+ return num
+ }
+ }
+ return id
+ });
+ }
+
+ this.build = m[5] ? m[5].split('.') : [];
+ this.format();
+ }
+
+ format () {
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
+ if (this.prerelease.length) {
+ this.version += `-${this.prerelease.join('.')}`;
+ }
+ return this.version
+ }
+
+ toString () {
+ return this.version
+ }
+
+ compare (other) {
+ debug_1('SemVer.compare', this.version, this.options, other);
+ if (!(other instanceof SemVer)) {
+ if (typeof other === 'string' && other === this.version) {
+ return 0
+ }
+ other = new SemVer(other, this.options);
+ }
+
+ if (other.version === this.version) {
+ return 0
+ }
+
+ return this.compareMain(other) || this.comparePre(other)
+ }
+
+ compareMain (other) {
+ if (!(other instanceof SemVer)) {
+ other = new SemVer(other, this.options);
+ }
+
+ return (
+ compareIdentifiers(this.major, other.major) ||
+ compareIdentifiers(this.minor, other.minor) ||
+ compareIdentifiers(this.patch, other.patch)
+ )
+ }
+
+ comparePre (other) {
+ if (!(other instanceof SemVer)) {
+ other = new SemVer(other, this.options);
+ }
+
+ // NOT having a prerelease is > having one
+ if (this.prerelease.length && !other.prerelease.length) {
+ return -1
+ } else if (!this.prerelease.length && other.prerelease.length) {
+ return 1
+ } else if (!this.prerelease.length && !other.prerelease.length) {
+ return 0
+ }
+
+ let i = 0;
+ do {
+ const a = this.prerelease[i];
+ const b = other.prerelease[i];
+ debug_1('prerelease compare', i, a, b);
+ if (a === undefined && b === undefined) {
+ return 0
+ } else if (b === undefined) {
+ return 1
+ } else if (a === undefined) {
+ return -1
+ } else if (a === b) {
+ continue
+ } else {
+ return compareIdentifiers(a, b)
+ }
+ } while (++i)
+ }
+
+ compareBuild (other) {
+ if (!(other instanceof SemVer)) {
+ other = new SemVer(other, this.options);
+ }
+
+ let i = 0;
+ do {
+ const a = this.build[i];
+ const b = other.build[i];
+ debug_1('prerelease compare', i, a, b);
+ if (a === undefined && b === undefined) {
+ return 0
+ } else if (b === undefined) {
+ return 1
+ } else if (a === undefined) {
+ return -1
+ } else if (a === b) {
+ continue
+ } else {
+ return compareIdentifiers(a, b)
+ }
+ } while (++i)
+ }
+
+ // preminor will bump the version up to the next minor release, and immediately
+ // down to pre-release. premajor and prepatch work the same way.
+ inc (release, identifier) {
+ switch (release) {
+ case 'premajor':
+ this.prerelease.length = 0;
+ this.patch = 0;
+ this.minor = 0;
+ this.major++;
+ this.inc('pre', identifier);
+ break
+ case 'preminor':
+ this.prerelease.length = 0;
+ this.patch = 0;
+ this.minor++;
+ this.inc('pre', identifier);
+ break
+ case 'prepatch':
+ // If this is already a prerelease, it will bump to the next version
+ // drop any prereleases that might already exist, since they are not
+ // relevant at this point.
+ this.prerelease.length = 0;
+ this.inc('patch', identifier);
+ this.inc('pre', identifier);
+ break
+ // If the input is a non-prerelease version, this acts the same as
+ // prepatch.
+ case 'prerelease':
+ if (this.prerelease.length === 0) {
+ this.inc('patch', identifier);
+ }
+ this.inc('pre', identifier);
+ break
+
+ case 'major':
+ // If this is a pre-major version, bump up to the same major version.
+ // Otherwise increment major.
+ // 1.0.0-5 bumps to 1.0.0
+ // 1.1.0 bumps to 2.0.0
+ if (
+ this.minor !== 0 ||
+ this.patch !== 0 ||
+ this.prerelease.length === 0
+ ) {
+ this.major++;
+ }
+ this.minor = 0;
+ this.patch = 0;
+ this.prerelease = [];
+ break
+ case 'minor':
+ // If this is a pre-minor version, bump up to the same minor version.
+ // Otherwise increment minor.
+ // 1.2.0-5 bumps to 1.2.0
+ // 1.2.1 bumps to 1.3.0
+ if (this.patch !== 0 || this.prerelease.length === 0) {
+ this.minor++;
+ }
+ this.patch = 0;
+ this.prerelease = [];
+ break
+ case 'patch':
+ // If this is not a pre-release version, it will increment the patch.
+ // If it is a pre-release it will bump up to the same patch version.
+ // 1.2.0-5 patches to 1.2.0
+ // 1.2.0 patches to 1.2.1
+ if (this.prerelease.length === 0) {
+ this.patch++;
+ }
+ this.prerelease = [];
+ break
+ // This probably shouldn't be used publicly.
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
+ case 'pre':
+ if (this.prerelease.length === 0) {
+ this.prerelease = [0];
+ } else {
+ let i = this.prerelease.length;
+ while (--i >= 0) {
+ if (typeof this.prerelease[i] === 'number') {
+ this.prerelease[i]++;
+ i = -2;
+ }
+ }
+ if (i === -1) {
+ // didn't increment anything
+ this.prerelease.push(0);
+ }
+ }
+ if (identifier) {
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
+ if (this.prerelease[0] === identifier) {
+ if (isNaN(this.prerelease[1])) {
+ this.prerelease = [identifier, 0];
+ }
+ } else {
+ this.prerelease = [identifier, 0];
+ }
+ }
+ break
+
+ default:
+ throw new Error(`invalid increment argument: ${release}`)
+ }
+ this.format();
+ this.raw = this.version;
+ return this
+ }
+}
+
+var semver = SemVer;
+
+const compare = (a, b, loose) =>
+ new semver(a, loose).compare(new semver(b, loose));
+
+var compare_1 = compare;
+
+const gte = (a, b, loose) => compare_1(a, b, loose) >= 0;
+var gte_1 = gte;
+
+// HyperMD, copyright (c) by laobubu
+
+(function (mod) {
+ mod(null, {}, CodeMirror, HyperMD.Fold, HyperMD.FoldCode);
+})(function (require, exports, CodeMirror, fold_1, fold_code_1) {
+ var dependencyCheck = function () {
+ const plugin = window.app.plugins.getPlugin("obsidian-admonition");
+ return plugin?._loaded && gte_1(plugin?.manifest.version, "6.3.6") ? true : false;
+ };
+ var AdmonitionRenderer = function (code, info) {
+ const adType = info.lang.substring(3);
+ var el = document.createElement("div");
+ var asyncRenderer;
+ if (dependencyCheck()) {
+ asyncRenderer = () => {
+ try {
+ window.app.plugins
+ .getPlugin("obsidian-admonition")
+ .postprocessor(adType, code, el, info.editor.state.fileName);
+ } catch (error) {
+ el.innerText = "Failed to render Admonition: " + error;
+ }
+ };
+ } else {
+ el.innerText = "Error: Unable to find the Admonitions plugin or Admonition version not 6.3.6 or higher";
+ }
+ return {
+ element: el,
+ asyncRenderer: asyncRenderer,
+ };
+ };
+ exports.AdmonitionRenderer = AdmonitionRenderer;
+
+ CodeMirror.defineOption("admonition", null, function (cm) {
+ fold_code_1.getAddon(cm).clear("admonition");
+ fold_1.getAddon(cm).startFold();
+ });
+ fold_code_1.registerRenderer({
+ name: "admonition",
+ pattern: /^ad-(?:[a-z]+)$/i,
+ renderer: exports.AdmonitionRenderer,
+ suggested: false,
+ });
+});
+
+// HyperMD, copyright (c) by laobubu
+// Distributed under an MIT license: http://laobubu.net/HyperMD/LICENSE
+//
+// POWERPACK for "addon/fold-code"
+//
+// This module provides `ChartRenderer` for FoldCode addon
+
+(function (mod) {
+ mod(null, {}, CodeMirror, HyperMD.Fold, HyperMD.FoldCode);
+})(function (require, exports, CodeMirror, fold_1, fold_code_1) {
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.ChartRenderer = void 0;
+ var dependencyCheck = function () {
+ return window.app.plugins.getPlugin("obsidian-charts")?._loaded ? true : false;
+ };
+ var ChartRenderer = function (code, info) {
+ var el = document.createElement("div");
+ if (dependencyCheck()) {
+ window.app.plugins.getPlugin("obsidian-charts").postprocessor(code, el);
+ } else {
+ el.innerText = "Error: Unable to find the Obsidian Charts plugin";
+ }
+ return {
+ element: el,
+ asyncRenderer: null,
+ };
+ };
+ exports.ChartRenderer = ChartRenderer;
+ {
+ CodeMirror.defineOption("chart", null, function (cm) {
+ fold_code_1.getAddon(cm).clear("chart");
+ fold_1.getAddon(cm).startFold();
+ });
+ fold_code_1.registerRenderer({
+ name: "chart",
+ pattern: /^chart$/i,
+ renderer: exports.ChartRenderer,
+ suggested: true,
+ });
+ }
+});
+
+// HyperMD, copyright (c) by laobubu
+// Distributed under an MIT license: http://laobubu.net/HyperMD/LICENSE
+//
+// POWERPACK for "addon/fold-code"
+//
+// This module provides `QueryRenderer` for FoldCode addon
+
+(function (mod) {
+ mod(null, {}, CodeMirror, HyperMD.Fold, HyperMD.FoldCode);
+})(function (require, exports, CodeMirror, fold_1, fold_code_1) {
+ var dependencyCheck = function () {
+ return window.app.internalPlugins.getPluginById("global-search")?._loaded;
+ };
+ const purifySettings = {
+ ALLOW_UNKNOWN_PROTOCOLS: true,
+ IN_PLACE: true,
+ // RETURN_DOM_FRAGMENT: true,
+ // RETURN_DOM_IMPORT: true,
+ FORBID_TAGS: ["style"],
+ ADD_TAGS: ["iframe"],
+ ADD_ATTR: ["frameborder", "allowfullscreen", "allow", "aria-label-position"],
+ };
+ var QueryRenderer = function (code, info) {
+ // Welcome to the very hacky query renderer code
+ // Here we pretend to be a preview mode section and steal the rendered element
+ var queryEl = document.createElement("div");
+ if (dependencyCheck()) {
+ var promises = [];
+ const previewMode = window.app.workspace.activeLeaf.view.previewMode,
+ renderer = previewMode.renderer;
+ queryEl.innerHTML = `${code}
`;
+ // Sanitize the HTML to make sure there's no funny business
+ window.DOMPurify.sanitize(queryEl, purifySettings);
+ renderer.owner.postProcess({ el: queryEl }, promises, renderer.frontmatter);
+ // But wait... we have to clean up after ourselves so that we don't cause a memory leak
+ // We do so by removing the node we just created from the preview mode's child list
+ setTimeout(() => {
+ renderer.owner._children.forEach(child => {
+ if (child.containerEl === queryEl.firstChild) {
+ child.unload();
+ previewMode.removeChild(child);
+ }
+ });
+ // we naively wait here because search query results are async
+ // if we clean up too fast, we don't get results
+ }, 15000);
+ } else {
+ queryEl.innerText = "Error: Unable to find the Global Search plugin";
+ }
+ return {
+ element: queryEl,
+ asyncRenderer: null,
+ };
+ };
+ exports.QueryRenderer = QueryRenderer;
+
+ CodeMirror.defineOption("query", null, function (cm) {
+ fold_code_1.getAddon(cm).clear("query");
+ fold_1.getAddon(cm).startFold();
+ });
+ fold_code_1.registerRenderer({
+ name: "query",
+ pattern: /^query$/i,
+ renderer: exports.QueryRenderer,
+ suggested: false,
+ });
+});
+
+// HyperMD, copyright (c) by laobubu
+
+(function (mod) {
+ mod(null, {}, CodeMirror, HyperMD.Fold, HyperMD.FoldCode);
+})(function (require, exports, CodeMirror, fold_1, fold_code_1) {
+ var dependencyCheck = function () {
+ const plugin = window.app.plugins.getPlugin("dataview");
+ return plugin?._loaded && gte_1(plugin?.manifest.version, "0.4.17") ? true : false;
+ };
+ var DataviewRenderer = function (code, info) {
+ var el = document.createElement("div");
+ var ctx = new obsidian.Component();
+ ctx.sourcePath = info.editor.state.fileName;
+ if (dependencyCheck()) {
+ if (info.lang === "dataview") {
+ window.app.plugins.getPlugin("dataview").dataview(code, el, ctx, ctx.sourcePath);
+ } else if (info.lang === "dataviewjs") {
+ window.app.plugins.getPlugin("dataview").dataviewjs(code, el, ctx, ctx.sourcePath);
+ }
+ ctx.load();
+ el = ctx._children[0].containerEl;
+ setTimeout(() => {
+ ctx._children[0].unload();
+ ctx.unload();
+ }, 15000);
+ return {
+ element: el,
+ asyncRenderer: null,
+ };
+ } else {
+ el.innerText = "Error: Unable to find the Dataview plugin or version not 0.4.17 or greater";
+ }
+
+ return {
+ element: el,
+ asyncRenderer: null,
+ };
+ };
+ exports.DataviewRenderer = DataviewRenderer;
+ CodeMirror.defineOption("dataview", null, function (cm) {
+ fold_code_1.getAddon(cm).clear("dataview");
+ fold_1.getAddon(cm).startFold();
+ });
+ fold_code_1.registerRenderer({
+ name: "dataview",
+ pattern: /^dataview(js)?$/i,
+ renderer: exports.DataviewRenderer,
+ suggested: false,
+ });
+});
+
+// HyperMD, copyright (c) by laobubu
+
+(function (mod) {
+ mod(null, (HyperMD.FoldMath = HyperMD.FoldMath || {}), CodeMirror, HyperMD, HyperMD.Fold);
+})(function (require, exports, CodeMirror, core_1, fold_1) {
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.getAddon =
+ exports.FoldMath =
+ exports.suggestedOption =
+ exports.defaultOption =
+ // exports.DumbRenderer =
+ exports.insertMathMark =
+ exports.MathFolder =
+ void 0;
+ /********************************************************************************** */
+ //#region Exports
+ /**
+ * Detect if a token is a beginning of Math, and fold it!
+ *
+ * @see FolderFunc in ./fold.ts
+ */
+ var MathFolder = function (stream, token) {
+ var mathBeginRE = /formatting-math-begin\b/;
+ if (!mathBeginRE.test(token.type)) return null;
+ var cm = stream.cm;
+ var line = stream.lineNo;
+ var maySpanLines = /math-block\b/.test(token.type); // $$ may span lines!
+ var tokenLength = maySpanLines ? 2 : 1; // "$$" or "$"
+ // CodeMirror GFM mode split "$$" into two tokens, so do a extra check.
+ if (tokenLength == 2 && token.string.length == 1) {
+ var nextToken = stream.lineTokens[stream.i_token + 1];
+ if (!nextToken || !mathBeginRE.test(nextToken.type)) return null;
+ }
+ // Find the position of the "$" tail and compose a range
+ var end_info = stream.findNext(/formatting-math-end\b/, maySpanLines);
+ var from = { line: line, ch: token.start };
+ var to;
+ var noEndingToken = false;
+ if (end_info) {
+ to = { line: end_info.lineNo, ch: end_info.token.start + tokenLength };
+ } else if (maySpanLines) {
+ // end not found, but this is a multi-line math block.
+ // fold to the end of doc
+ var lastLineNo = cm.lastLine();
+ to = { line: lastLineNo, ch: cm.getLine(lastLineNo).length };
+ noEndingToken = true;
+ } else {
+ // Hmm... corrupted math ?
+ return null;
+ }
+ // Range is ready. request the range
+ var expr_from = { line: from.line, ch: from.ch + tokenLength };
+ var expr_to = {
+ line: to.line,
+ ch: to.ch - (noEndingToken ? 0 : tokenLength),
+ };
+ var expr = cm.getRange(expr_from, expr_to).trim();
+ var foldMathAddon = exports.getAddon(cm);
+ var reqAns = stream.requestRange(from, to);
+ if (reqAns !== fold_1.RequestRangeResult.OK) {
+ if (reqAns === fold_1.RequestRangeResult.CURSOR_INSIDE) foldMathAddon.editingExpr = expr; // try to trig preview event
+ return null;
+ }
+ // Now let's make a math widget!
+ var isDisplayMode = tokenLength > 1; // && from.ch == 0 && (noEndingToken || to.ch >= cm.getLine(to.line).length);
+ var marker = insertMathMark(cm, from, to, expr, tokenLength, isDisplayMode);
+ foldMathAddon.editingExpr = null; // try to hide preview
+ return marker;
+ };
+ exports.MathFolder = MathFolder;
+ /**
+ * Insert a TextMarker, and try to render it with configured MathRenderer.
+ */
+ function insertMathMark(cm, p1, p2, expression, tokenLength, isDisplayMode) {
+ var span = document.createElement("span");
+ span.setAttribute("class", "hmd-fold-math math-" + (isDisplayMode ? 2 : 1));
+ span.setAttribute("title", expression);
+ var mathPlaceholder = document.createElement("span");
+ mathPlaceholder.setAttribute("class", "hmd-fold-math-placeholder");
+ mathPlaceholder.textContent = expression;
+ span.appendChild(mathPlaceholder);
+ var marker = cm.markText(p1, p2, {
+ replacedWith: span,
+ });
+ span.addEventListener(
+ "click",
+ function () {
+ return fold_1.breakMark(cm, marker, tokenLength);
+ },
+ false
+ );
+ var foldMathAddon = exports.getAddon(cm);
+ var mathRenderer = foldMathAddon.createRenderer(span, isDisplayMode ? "display" : "");
+ mathRenderer.onChanged = function () {
+ // if (mathPlaceholder) {
+ // span.removeChild(mathPlaceholder);
+ // mathPlaceholder = null;
+ // }
+ marker.changed();
+ };
+ marker.on("clear", function () {
+ mathRenderer.clear();
+ });
+ marker["mathRenderer"] = mathRenderer;
+ core_1.tryToRun(
+ function () {
+ if (!mathRenderer.isReady()) return false;
+ mathRenderer.startRender(expression);
+ return true;
+ },
+ 5,
+ function () {
+ // if failed 5 times...
+ marker.clear();
+ }
+ );
+ return marker;
+ }
+ exports.insertMathMark = insertMathMark;
+ //#endregion
+ fold_1.registerFolder("math", exports.MathFolder, true);
+ /********************************************************************************** */
+ //#region Mathjax Renderer
+ var MathjaxRenderer = /** @class */ (function () {
+ function MathjaxRenderer(container, mode) {
+ this.container = container;
+ this.container.empty();
+ this.isDisplay = mode === "display";
+ var elClass = "hmd-math-mathjax";
+ if (mode) elClass += " hmd-math-mathjax-" + mode;
+ var errorEl = (this.errorEl = document.createElement("span"));
+ errorEl.setAttribute("style", "white-space: pre-wrap; font-size: 90%; border: 1px solid #900; color: #C00");
+ var el = (this.el = document.createElement("span"));
+ el.className = elClass;
+ container.appendChild(el);
+ }
+ MathjaxRenderer.prototype.dependencyCheck = function () {
+ return gte_1(electron.ipcRenderer.sendSync("version"), "0.12.16") ? true : false;
+ };
+ MathjaxRenderer.prototype.startRender = function (expr) {
+ var el = this.el,
+ errorEl = this.errorEl;
+ try {
+ if (!this.dependencyCheck()) {
+ el.innerHTML = 'Obsidian v0.12.16+ is needed to render Mathjax';
+ } else {
+ el.innerHTML = obsidian.renderMath(expr, { display: true }).outerHTML;
+ // this.container.appendChild(this.el);
+ obsidian.finishRenderMath();
+ }
+ } catch (err) {
+ // failed to render!
+ errorEl.textContent = err && err.message;
+ if (errorEl.parentElement !== el) {
+ el.textContent = "";
+ el.appendChild(errorEl);
+ el.className += " hmd-math-mathjax-error";
+ }
+ }
+ var onChanged = this.onChanged;
+ if (onChanged) setTimeout(onChanged.bind(this, expr), 0);
+ };
+ MathjaxRenderer.prototype.clear = function () {
+ this.container.removeChild(this.el);
+ };
+ /** indicate that if the Renderer is ready to execute */
+ MathjaxRenderer.prototype.isReady = function () {
+ return true; // I'm always ready!
+ };
+ return MathjaxRenderer;
+ })();
+ // exports.DumbRenderer = DumbRenderer;
+ exports.defaultOption = {
+ renderer: MathjaxRenderer,
+ onPreview: null,
+ onPreviewEnd: null,
+ };
+ exports.suggestedOption = {};
+ core_1.suggestedEditorConfig.hmdFoldMath = exports.suggestedOption;
+ CodeMirror.defineOption("hmdFoldMath", exports.defaultOption, function (cm, newVal) {
+ ///// convert newVal's type to `Partial`, if it is not.
+ if (!newVal) {
+ newVal = {};
+ } else if (newVal === true) {
+ newVal = { renderer: MathjaxRenderer, onPreview: null, onPreviewEnd: null };
+ } else if (typeof newVal === "function") {
+ newVal = { renderer: newVal };
+ }
+ ///// apply config and write new values into cm
+ var inst = exports.getAddon(cm);
+ for (var k in exports.defaultOption) {
+ inst[k] = k in newVal ? newVal[k] : exports.defaultOption[k];
+ }
+ });
+ //#endregion
+ /********************************************************************************** */
+ //#region Addon Class
+ var FoldMath = /** @class */ (function () {
+ function FoldMath(cm) {
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
+ var _this = this;
+ this.cm = cm;
+ new core_1.FlipFlop(
+ /** CHANGED */ function (expr) {
+ _this.onPreview && _this.onPreview(expr);
+ },
+ /** HIDE */ function () {
+ _this.onPreviewEnd && _this.onPreviewEnd();
+ },
+ null
+ ).bind(this, "editingExpr");
+ }
+ FoldMath.prototype.createRenderer = function (container, mode) {
+ var RendererClass = this.renderer || MathjaxRenderer;
+ return new RendererClass(container, mode);
+ };
+ return FoldMath;
+ })();
+ exports.FoldMath = FoldMath;
+ //#endregion
+ /** ADDON GETTER (Singleton Pattern): a editor can have only one FoldMath instance */
+ exports.getAddon = core_1.Addon.Getter("FoldMath", FoldMath, exports.defaultOption /** if has options */);
+});
+
+// HyperMD, copyright (c) by laobubu
+// Distributed under an MIT license: http://laobubu.net/HyperMD/LICENSE
+//
+// DESCRIPTION: Align Table Columns
+//
+
+
+(function (mod) {
+ mod(null, (HyperMD.TableAlign = HyperMD.TableAlign || {}), CodeMirror, HyperMD);
+})(function (require, exports, CodeMirror, core_1) {
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.getAddon = exports.TableAlign = exports.suggestedOption = exports.defaultOption = void 0;
+ // CodeMirror = __importStar(CodeMirror);
+ exports.defaultOption = {
+ enabled: false,
+ };
+ exports.suggestedOption = {
+ enabled: true,
+ };
+ core_1.suggestedEditorConfig.hmdTableAlign = exports.suggestedOption;
+ core_1.normalVisualConfig.hmdTableAlign = false;
+ CodeMirror.defineOption("hmdTableAlign", exports.defaultOption, function (cm, newVal) {
+ var enabled = !!newVal;
+ ///// convert newVal's type to `Partial`, if it is not.
+ if (!enabled || typeof newVal === "boolean") {
+ newVal = { enabled: enabled };
+ }
+ ///// apply config and write new values into cm
+ var inst = exports.getAddon(cm);
+ for (var k in exports.defaultOption) {
+ inst[k] = k in newVal ? newVal[k] : exports.defaultOption[k];
+ }
+ });
+ //#endregion
+ /********************************************************************************** */
+ //#region Addon Class
+ var TableAlign = /** @class */ (function () {
+ function TableAlign(cm) {
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
+ var _this = this;
+ this.cm = cm;
+ this.styleEl = document.createElement("style");
+ /**
+ * Remeasure visible columns, update CSS style to make columns aligned
+ *
+ * (This is a debounced function)
+ */
+ this.updateStyle = core_1.debounce(function () {
+ if (!_this.enabled) return;
+ var cm = _this.cm;
+ var measures = _this.measure();
+ var css = _this.makeCSS(measures);
+ if (css === _this._lastCSS) return;
+ _this.styleEl.textContent = _this._lastCSS = css;
+ core_1.updateCursorDisplay(cm, false);
+ // cm.refresh();
+ }, 100);
+ /** CodeMirror renderLine event handler */
+ this._procLine = function (cm, line, el) {
+ if (!el.querySelector(".cm-hmd-table-sep")) return;
+ var lineSpan = el.firstElementChild;
+ var lineSpanChildren = Array.prototype.slice.call(lineSpan.childNodes, 0);
+ var eolState = cm.getStateAfter(line.lineNo());
+ var columnStyles = eolState.hmdTableColumns;
+ if (!columnStyles.length) return;
+ var tableID = eolState.hmdTableID;
+ var columnIdx = eolState.hmdTable === 2 /* NORMAL */ ? -1 : 0;
+ var columnSpan = _this.makeColumn(columnIdx, columnStyles[columnIdx] || "dummy", tableID);
+ var columnContentSpan = columnSpan.firstElementChild;
+ for (var _i = 0, lineSpanChildren_1 = lineSpanChildren; _i < lineSpanChildren_1.length; _i++) {
+ var el_1 = lineSpanChildren_1[_i];
+ var elClass = (el_1.nodeType === Node.ELEMENT_NODE && el_1.className) || "";
+ if (/cm-hmd-table-sep/.test(elClass)) {
+ // found a "|", and a column is finished
+ columnIdx++;
+ columnSpan.appendChild(columnContentSpan);
+ lineSpan.appendChild(columnSpan);
+ lineSpan.appendChild(el_1);
+ columnSpan = _this.makeColumn(columnIdx, columnStyles[columnIdx] || "dummy", tableID);
+ columnContentSpan = columnSpan.firstElementChild;
+ } else {
+ columnContentSpan.appendChild(el_1);
+ }
+ }
+ columnSpan.appendChild(columnContentSpan);
+ lineSpan.appendChild(columnSpan);
+ };
+ new core_1.FlipFlop(
+ /* ON */ function () {
+ cm.on("renderLine", _this._procLine);
+ cm.on("update", _this.updateStyle);
+ cm.refresh();
+ document.head.appendChild(_this.styleEl);
+ },
+ /* OFF */ function () {
+ cm.off("renderLine", _this._procLine);
+ cm.off("update", _this.updateStyle);
+ document.head.removeChild(_this.styleEl);
+ cm.refresh();
+ }
+ ).bind(this, "enabled", true);
+ }
+ /**
+ * create a container as column,
+ * note that put content into column.firstElementChild
+ */
+ TableAlign.prototype.makeColumn = function (index, style, tableID) {
+ var span = document.createElement("span");
+ span.className = "hmd-table-column hmd-table-column-" + index + " hmd-table-column-" + style;
+ span.setAttribute("data-column", "" + index);
+ span.setAttribute("data-table-id", tableID);
+ var span2 = document.createElement("span");
+ span2.className = "hmd-table-column-content";
+ span2.setAttribute("data-column", "" + index);
+ span.appendChild(span2);
+ return span;
+ };
+ /** Measure all visible tables and columns */
+ TableAlign.prototype.measure = function () {
+ var cm = this.cm;
+ var lineDiv = cm.display.lineDiv; // contains every line
+ var contentSpans = lineDiv.querySelectorAll(".hmd-table-column-content");
+ /** every table's every column's width in px */
+ var ans = {};
+ for (var i = 0; i < contentSpans.length; i++) {
+ var contentSpan = contentSpans[i];
+ var column = contentSpan.parentElement;
+ var tableID = column.getAttribute("data-table-id");
+ var columnIdx = ~~column.getAttribute("data-column");
+ var width = contentSpan.offsetWidth + 1; // +1 because browsers turn 311.3 into 312
+ if (!(tableID in ans)) ans[tableID] = [];
+ var columnWidths = ans[tableID];
+ while (columnWidths.length <= columnIdx) columnWidths.push(0);
+ if (columnWidths[columnIdx] < width) columnWidths[columnIdx] = width;
+ }
+ return ans;
+ };
+ /** Generate CSS */
+ TableAlign.prototype.makeCSS = function (measures) {
+ var rules = [];
+ for (var tableID in measures) {
+ var columnWidths = measures[tableID];
+ var rulePrefix = "pre.HyperMD-table-row.HyperMD-table_" + tableID + " .hmd-table-column-";
+ for (var columnIdx = 0; columnIdx < columnWidths.length; columnIdx++) {
+ var width = columnWidths[columnIdx];
+ rules.push("" + rulePrefix + columnIdx + " { min-width: " + (width + 0.5) + "px }");
+ }
+ }
+ return rules.join("\n");
+ };
+ return TableAlign;
+ })();
+ exports.TableAlign = TableAlign;
+ //#endregion
+ /** ADDON GETTER (Singleton Pattern): a editor can have only one TableAlign instance */
+ exports.getAddon = core_1.Addon.Getter("TableAlign", TableAlign, exports.defaultOption);
+});
+
+function isNothing(subject) {
+ return (typeof subject === 'undefined') || (subject === null);
+}
+
+
+function isObject(subject) {
+ return (typeof subject === 'object') && (subject !== null);
+}
+
+
+function toArray(sequence) {
+ if (Array.isArray(sequence)) return sequence;
+ else if (isNothing(sequence)) return [];
+
+ return [ sequence ];
+}
+
+
+function extend(target, source) {
+ var index, length, key, sourceKeys;
+
+ if (source) {
+ sourceKeys = Object.keys(source);
+
+ for (index = 0, length = sourceKeys.length; index < length; index += 1) {
+ key = sourceKeys[index];
+ target[key] = source[key];
+ }
+ }
+
+ return target;
+}
+
+
+function repeat(string, count) {
+ var result = '', cycle;
+
+ for (cycle = 0; cycle < count; cycle += 1) {
+ result += string;
+ }
+
+ return result;
+}
+
+
+function isNegativeZero(number) {
+ return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
+}
+
+
+var isNothing_1 = isNothing;
+var isObject_1 = isObject;
+var toArray_1 = toArray;
+var repeat_1 = repeat;
+var isNegativeZero_1 = isNegativeZero;
+var extend_1 = extend;
+
+var common = {
+ isNothing: isNothing_1,
+ isObject: isObject_1,
+ toArray: toArray_1,
+ repeat: repeat_1,
+ isNegativeZero: isNegativeZero_1,
+ extend: extend_1
+};
+
+// YAML error class. http://stackoverflow.com/questions/8458984
+
+
+function formatError(exception, compact) {
+ var where = '', message = exception.reason || '(unknown reason)';
+
+ if (!exception.mark) return message;
+
+ if (exception.mark.name) {
+ where += 'in "' + exception.mark.name + '" ';
+ }
+
+ where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')';
+
+ if (!compact && exception.mark.snippet) {
+ where += '\n\n' + exception.mark.snippet;
+ }
+
+ return message + ' ' + where;
+}
+
+
+function YAMLException$1(reason, mark) {
+ // Super constructor
+ Error.call(this);
+
+ this.name = 'YAMLException';
+ this.reason = reason;
+ this.mark = mark;
+ this.message = formatError(this, false);
+
+ // Include stack trace in error object
+ if (Error.captureStackTrace) {
+ // Chrome and NodeJS
+ Error.captureStackTrace(this, this.constructor);
+ } else {
+ // FF, IE 10+ and Safari 6+. Fallback for others
+ this.stack = (new Error()).stack || '';
+ }
+}
+
+
+// Inherit from Error
+YAMLException$1.prototype = Object.create(Error.prototype);
+YAMLException$1.prototype.constructor = YAMLException$1;
+
+
+YAMLException$1.prototype.toString = function toString(compact) {
+ return this.name + ': ' + formatError(this, compact);
+};
+
+
+var exception = YAMLException$1;
+
+// get snippet for a single line, respecting maxLength
+function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
+ var head = '';
+ var tail = '';
+ var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
+
+ if (position - lineStart > maxHalfLength) {
+ head = ' ... ';
+ lineStart = position - maxHalfLength + head.length;
+ }
+
+ if (lineEnd - position > maxHalfLength) {
+ tail = ' ...';
+ lineEnd = position + maxHalfLength - tail.length;
+ }
+
+ return {
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail,
+ pos: position - lineStart + head.length // relative position
+ };
+}
+
+
+function padStart(string, max) {
+ return common.repeat(' ', max - string.length) + string;
+}
+
+
+function makeSnippet(mark, options) {
+ options = Object.create(options || null);
+
+ if (!mark.buffer) return null;
+
+ if (!options.maxLength) options.maxLength = 79;
+ if (typeof options.indent !== 'number') options.indent = 1;
+ if (typeof options.linesBefore !== 'number') options.linesBefore = 3;
+ if (typeof options.linesAfter !== 'number') options.linesAfter = 2;
+
+ var re = /\r?\n|\r|\0/g;
+ var lineStarts = [ 0 ];
+ var lineEnds = [];
+ var match;
+ var foundLineNo = -1;
+
+ while ((match = re.exec(mark.buffer))) {
+ lineEnds.push(match.index);
+ lineStarts.push(match.index + match[0].length);
+
+ if (mark.position <= match.index && foundLineNo < 0) {
+ foundLineNo = lineStarts.length - 2;
+ }
+ }
+
+ if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
+
+ var result = '', i, line;
+ var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
+ var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
+
+ for (i = 1; i <= options.linesBefore; i++) {
+ if (foundLineNo - i < 0) break;
+ line = getLine(
+ mark.buffer,
+ lineStarts[foundLineNo - i],
+ lineEnds[foundLineNo - i],
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
+ maxLineLength
+ );
+ result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) +
+ ' | ' + line.str + '\n' + result;
+ }
+
+ line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
+ result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) +
+ ' | ' + line.str + '\n';
+ result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n';
+
+ for (i = 1; i <= options.linesAfter; i++) {
+ if (foundLineNo + i >= lineEnds.length) break;
+ line = getLine(
+ mark.buffer,
+ lineStarts[foundLineNo + i],
+ lineEnds[foundLineNo + i],
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
+ maxLineLength
+ );
+ result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) +
+ ' | ' + line.str + '\n';
+ }
+
+ return result.replace(/\n$/, '');
+}
+
+
+var snippet = makeSnippet;
+
+var TYPE_CONSTRUCTOR_OPTIONS = [
+ 'kind',
+ 'multi',
+ 'resolve',
+ 'construct',
+ 'instanceOf',
+ 'predicate',
+ 'represent',
+ 'representName',
+ 'defaultStyle',
+ 'styleAliases'
+];
+
+var YAML_NODE_KINDS = [
+ 'scalar',
+ 'sequence',
+ 'mapping'
+];
+
+function compileStyleAliases(map) {
+ var result = {};
+
+ if (map !== null) {
+ Object.keys(map).forEach(function (style) {
+ map[style].forEach(function (alias) {
+ result[String(alias)] = style;
+ });
+ });
+ }
+
+ return result;
+}
+
+function Type$1(tag, options) {
+ options = options || {};
+
+ Object.keys(options).forEach(function (name) {
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
+ throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
+ }
+ });
+
+ // TODO: Add tag format check.
+ this.options = options; // keep original options in case user wants to extend this type later
+ this.tag = tag;
+ this.kind = options['kind'] || null;
+ this.resolve = options['resolve'] || function () { return true; };
+ this.construct = options['construct'] || function (data) { return data; };
+ this.instanceOf = options['instanceOf'] || null;
+ this.predicate = options['predicate'] || null;
+ this.represent = options['represent'] || null;
+ this.representName = options['representName'] || null;
+ this.defaultStyle = options['defaultStyle'] || null;
+ this.multi = options['multi'] || false;
+ this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
+
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
+ throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
+ }
+}
+
+var type = Type$1;
+
+/*eslint-disable max-len*/
+
+
+
+
+
+function compileList(schema, name) {
+ var result = [];
+
+ schema[name].forEach(function (currentType) {
+ var newIndex = result.length;
+
+ result.forEach(function (previousType, previousIndex) {
+ if (previousType.tag === currentType.tag &&
+ previousType.kind === currentType.kind &&
+ previousType.multi === currentType.multi) {
+
+ newIndex = previousIndex;
+ }
+ });
+
+ result[newIndex] = currentType;
+ });
+
+ return result;
+}
+
+
+function compileMap(/* lists... */) {
+ var result = {
+ scalar: {},
+ sequence: {},
+ mapping: {},
+ fallback: {},
+ multi: {
+ scalar: [],
+ sequence: [],
+ mapping: [],
+ fallback: []
+ }
+ }, index, length;
+
+ function collectType(type) {
+ if (type.multi) {
+ result.multi[type.kind].push(type);
+ result.multi['fallback'].push(type);
+ } else {
+ result[type.kind][type.tag] = result['fallback'][type.tag] = type;
+ }
+ }
+
+ for (index = 0, length = arguments.length; index < length; index += 1) {
+ arguments[index].forEach(collectType);
+ }
+ return result;
+}
+
+
+function Schema$1(definition) {
+ return this.extend(definition);
+}
+
+
+Schema$1.prototype.extend = function extend(definition) {
+ var implicit = [];
+ var explicit = [];
+
+ if (definition instanceof type) {
+ // Schema.extend(type)
+ explicit.push(definition);
+
+ } else if (Array.isArray(definition)) {
+ // Schema.extend([ type1, type2, ... ])
+ explicit = explicit.concat(definition);
+
+ } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
+ // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] })
+ if (definition.implicit) implicit = implicit.concat(definition.implicit);
+ if (definition.explicit) explicit = explicit.concat(definition.explicit);
+
+ } else {
+ throw new exception('Schema.extend argument should be a Type, [ Type ], ' +
+ 'or a schema definition ({ implicit: [...], explicit: [...] })');
+ }
+
+ implicit.forEach(function (type$1) {
+ if (!(type$1 instanceof type)) {
+ throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.');
+ }
+
+ if (type$1.loadKind && type$1.loadKind !== 'scalar') {
+ throw new exception('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
+ }
+
+ if (type$1.multi) {
+ throw new exception('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.');
+ }
+ });
+
+ explicit.forEach(function (type$1) {
+ if (!(type$1 instanceof type)) {
+ throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.');
+ }
+ });
+
+ var result = Object.create(Schema$1.prototype);
+
+ result.implicit = (this.implicit || []).concat(implicit);
+ result.explicit = (this.explicit || []).concat(explicit);
+
+ result.compiledImplicit = compileList(result, 'implicit');
+ result.compiledExplicit = compileList(result, 'explicit');
+ result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
+
+ return result;
+};
+
+
+var schema = Schema$1;
+
+var str = new type('tag:yaml.org,2002:str', {
+ kind: 'scalar',
+ construct: function (data) { return data !== null ? data : ''; }
+});
+
+var seq = new type('tag:yaml.org,2002:seq', {
+ kind: 'sequence',
+ construct: function (data) { return data !== null ? data : []; }
+});
+
+var map = new type('tag:yaml.org,2002:map', {
+ kind: 'mapping',
+ construct: function (data) { return data !== null ? data : {}; }
+});
+
+var failsafe = new schema({
+ explicit: [
+ str,
+ seq,
+ map
+ ]
+});
+
+function resolveYamlNull(data) {
+ if (data === null) return true;
+
+ var max = data.length;
+
+ return (max === 1 && data === '~') ||
+ (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
+}
+
+function constructYamlNull() {
+ return null;
+}
+
+function isNull(object) {
+ return object === null;
+}
+
+var _null = new type('tag:yaml.org,2002:null', {
+ kind: 'scalar',
+ resolve: resolveYamlNull,
+ construct: constructYamlNull,
+ predicate: isNull,
+ represent: {
+ canonical: function () { return '~'; },
+ lowercase: function () { return 'null'; },
+ uppercase: function () { return 'NULL'; },
+ camelcase: function () { return 'Null'; },
+ empty: function () { return ''; }
+ },
+ defaultStyle: 'lowercase'
+});
+
+function resolveYamlBoolean(data) {
+ if (data === null) return false;
+
+ var max = data.length;
+
+ return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
+ (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
+}
+
+function constructYamlBoolean(data) {
+ return data === 'true' ||
+ data === 'True' ||
+ data === 'TRUE';
+}
+
+function isBoolean(object) {
+ return Object.prototype.toString.call(object) === '[object Boolean]';
+}
+
+var bool = new type('tag:yaml.org,2002:bool', {
+ kind: 'scalar',
+ resolve: resolveYamlBoolean,
+ construct: constructYamlBoolean,
+ predicate: isBoolean,
+ represent: {
+ lowercase: function (object) { return object ? 'true' : 'false'; },
+ uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
+ camelcase: function (object) { return object ? 'True' : 'False'; }
+ },
+ defaultStyle: 'lowercase'
+});
+
+function isHexCode(c) {
+ return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
+ ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
+ ((0x61/* a */ <= c) && (c <= 0x66/* f */));
+}
+
+function isOctCode(c) {
+ return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
+}
+
+function isDecCode(c) {
+ return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
+}
+
+function resolveYamlInteger(data) {
+ if (data === null) return false;
+
+ var max = data.length,
+ index = 0,
+ hasDigits = false,
+ ch;
+
+ if (!max) return false;
+
+ ch = data[index];
+
+ // sign
+ if (ch === '-' || ch === '+') {
+ ch = data[++index];
+ }
+
+ if (ch === '0') {
+ // 0
+ if (index + 1 === max) return true;
+ ch = data[++index];
+
+ // base 2, base 8, base 16
+
+ if (ch === 'b') {
+ // base 2
+ index++;
+
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (ch !== '0' && ch !== '1') return false;
+ hasDigits = true;
+ }
+ return hasDigits && ch !== '_';
+ }
+
+
+ if (ch === 'x') {
+ // base 16
+ index++;
+
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (!isHexCode(data.charCodeAt(index))) return false;
+ hasDigits = true;
+ }
+ return hasDigits && ch !== '_';
+ }
+
+
+ if (ch === 'o') {
+ // base 8
+ index++;
+
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (!isOctCode(data.charCodeAt(index))) return false;
+ hasDigits = true;
+ }
+ return hasDigits && ch !== '_';
+ }
+ }
+
+ // base 10 (except 0)
+
+ // value should not start with `_`;
+ if (ch === '_') return false;
+
+ for (; index < max; index++) {
+ ch = data[index];
+ if (ch === '_') continue;
+ if (!isDecCode(data.charCodeAt(index))) {
+ return false;
+ }
+ hasDigits = true;
+ }
+
+ // Should have digits and should not end with `_`
+ if (!hasDigits || ch === '_') return false;
+
+ return true;
+}
+
+function constructYamlInteger(data) {
+ var value = data, sign = 1, ch;
+
+ if (value.indexOf('_') !== -1) {
+ value = value.replace(/_/g, '');
+ }
+
+ ch = value[0];
+
+ if (ch === '-' || ch === '+') {
+ if (ch === '-') sign = -1;
+ value = value.slice(1);
+ ch = value[0];
+ }
+
+ if (value === '0') return 0;
+
+ if (ch === '0') {
+ if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
+ if (value[1] === 'x') return sign * parseInt(value.slice(2), 16);
+ if (value[1] === 'o') return sign * parseInt(value.slice(2), 8);
+ }
+
+ return sign * parseInt(value, 10);
+}
+
+function isInteger(object) {
+ return (Object.prototype.toString.call(object)) === '[object Number]' &&
+ (object % 1 === 0 && !common.isNegativeZero(object));
+}
+
+var int_1 = new type('tag:yaml.org,2002:int', {
+ kind: 'scalar',
+ resolve: resolveYamlInteger,
+ construct: constructYamlInteger,
+ predicate: isInteger,
+ represent: {
+ binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
+ octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); },
+ decimal: function (obj) { return obj.toString(10); },
+ /* eslint-disable max-len */
+ hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); }
+ },
+ defaultStyle: 'decimal',
+ styleAliases: {
+ binary: [ 2, 'bin' ],
+ octal: [ 8, 'oct' ],
+ decimal: [ 10, 'dec' ],
+ hexadecimal: [ 16, 'hex' ]
+ }
+});
+
+var YAML_FLOAT_PATTERN = new RegExp(
+ // 2.5e4, 2.5 and integers
+ '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
+ // .2e4, .2
+ // special case, seems not from spec
+ '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
+ // .inf
+ '|[-+]?\\.(?:inf|Inf|INF)' +
+ // .nan
+ '|\\.(?:nan|NaN|NAN))$');
+
+function resolveYamlFloat(data) {
+ if (data === null) return false;
+
+ if (!YAML_FLOAT_PATTERN.test(data) ||
+ // Quick hack to not allow integers end with `_`
+ // Probably should update regexp & check speed
+ data[data.length - 1] === '_') {
+ return false;
+ }
+
+ return true;
+}
+
+function constructYamlFloat(data) {
+ var value, sign;
+
+ value = data.replace(/_/g, '').toLowerCase();
+ sign = value[0] === '-' ? -1 : 1;
+
+ if ('+-'.indexOf(value[0]) >= 0) {
+ value = value.slice(1);
+ }
+
+ if (value === '.inf') {
+ return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
+
+ } else if (value === '.nan') {
+ return NaN;
+ }
+ return sign * parseFloat(value, 10);
+}
+
+
+var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
+
+function representYamlFloat(object, style) {
+ var res;
+
+ if (isNaN(object)) {
+ switch (style) {
+ case 'lowercase': return '.nan';
+ case 'uppercase': return '.NAN';
+ case 'camelcase': return '.NaN';
+ }
+ } else if (Number.POSITIVE_INFINITY === object) {
+ switch (style) {
+ case 'lowercase': return '.inf';
+ case 'uppercase': return '.INF';
+ case 'camelcase': return '.Inf';
+ }
+ } else if (Number.NEGATIVE_INFINITY === object) {
+ switch (style) {
+ case 'lowercase': return '-.inf';
+ case 'uppercase': return '-.INF';
+ case 'camelcase': return '-.Inf';
+ }
+ } else if (common.isNegativeZero(object)) {
+ return '-0.0';
+ }
+
+ res = object.toString(10);
+
+ // JS stringifier can build scientific format without dots: 5e-100,
+ // while YAML requres dot: 5.e-100. Fix it with simple hack
+
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
+}
+
+function isFloat(object) {
+ return (Object.prototype.toString.call(object) === '[object Number]') &&
+ (object % 1 !== 0 || common.isNegativeZero(object));
+}
+
+var float_1 = new type('tag:yaml.org,2002:float', {
+ kind: 'scalar',
+ resolve: resolveYamlFloat,
+ construct: constructYamlFloat,
+ predicate: isFloat,
+ represent: representYamlFloat,
+ defaultStyle: 'lowercase'
+});
+
+var json = failsafe.extend({
+ implicit: [
+ _null,
+ bool,
+ int_1,
+ float_1
+ ]
+});
+
+var core = json;
+
+var YAML_DATE_REGEXP = new RegExp(
+ '^([0-9][0-9][0-9][0-9])' + // [1] year
+ '-([0-9][0-9])' + // [2] month
+ '-([0-9][0-9])$'); // [3] day
+
+var YAML_TIMESTAMP_REGEXP = new RegExp(
+ '^([0-9][0-9][0-9][0-9])' + // [1] year
+ '-([0-9][0-9]?)' + // [2] month
+ '-([0-9][0-9]?)' + // [3] day
+ '(?:[Tt]|[ \\t]+)' + // ...
+ '([0-9][0-9]?)' + // [4] hour
+ ':([0-9][0-9])' + // [5] minute
+ ':([0-9][0-9])' + // [6] second
+ '(?:\\.([0-9]*))?' + // [7] fraction
+ '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
+ '(?::([0-9][0-9]))?))?$'); // [11] tz_minute
+
+function resolveYamlTimestamp(data) {
+ if (data === null) return false;
+ if (YAML_DATE_REGEXP.exec(data) !== null) return true;
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
+ return false;
+}
+
+function constructYamlTimestamp(data) {
+ var match, year, month, day, hour, minute, second, fraction = 0,
+ delta = null, tz_hour, tz_minute, date;
+
+ match = YAML_DATE_REGEXP.exec(data);
+ if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
+
+ if (match === null) throw new Error('Date resolve error');
+
+ // match: [1] year [2] month [3] day
+
+ year = +(match[1]);
+ month = +(match[2]) - 1; // JS month starts with 0
+ day = +(match[3]);
+
+ if (!match[4]) { // no hour
+ return new Date(Date.UTC(year, month, day));
+ }
+
+ // match: [4] hour [5] minute [6] second [7] fraction
+
+ hour = +(match[4]);
+ minute = +(match[5]);
+ second = +(match[6]);
+
+ if (match[7]) {
+ fraction = match[7].slice(0, 3);
+ while (fraction.length < 3) { // milli-seconds
+ fraction += '0';
+ }
+ fraction = +fraction;
+ }
+
+ // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
+
+ if (match[9]) {
+ tz_hour = +(match[10]);
+ tz_minute = +(match[11] || 0);
+ delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
+ if (match[9] === '-') delta = -delta;
+ }
+
+ date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
+
+ if (delta) date.setTime(date.getTime() - delta);
+
+ return date;
+}
+
+function representYamlTimestamp(object /*, style*/) {
+ return object.toISOString();
+}
+
+var timestamp = new type('tag:yaml.org,2002:timestamp', {
+ kind: 'scalar',
+ resolve: resolveYamlTimestamp,
+ construct: constructYamlTimestamp,
+ instanceOf: Date,
+ represent: representYamlTimestamp
+});
+
+function resolveYamlMerge(data) {
+ return data === '<<' || data === null;
+}
+
+var merge = new type('tag:yaml.org,2002:merge', {
+ kind: 'scalar',
+ resolve: resolveYamlMerge
+});
+
+/*eslint-disable no-bitwise*/
+
+
+
+
+
+// [ 64, 65, 66 ] -> [ padding, CR, LF ]
+var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
+
+
+function resolveYamlBinary(data) {
+ if (data === null) return false;
+
+ var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
+
+ // Convert one by one.
+ for (idx = 0; idx < max; idx++) {
+ code = map.indexOf(data.charAt(idx));
+
+ // Skip CR/LF
+ if (code > 64) continue;
+
+ // Fail on illegal characters
+ if (code < 0) return false;
+
+ bitlen += 6;
+ }
+
+ // If there are any bits left, source was corrupted
+ return (bitlen % 8) === 0;
+}
+
+function constructYamlBinary(data) {
+ var idx, tailbits,
+ input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
+ max = input.length,
+ map = BASE64_MAP,
+ bits = 0,
+ result = [];
+
+ // Collect by 6*4 bits (3 bytes)
+
+ for (idx = 0; idx < max; idx++) {
+ if ((idx % 4 === 0) && idx) {
+ result.push((bits >> 16) & 0xFF);
+ result.push((bits >> 8) & 0xFF);
+ result.push(bits & 0xFF);
+ }
+
+ bits = (bits << 6) | map.indexOf(input.charAt(idx));
+ }
+
+ // Dump tail
+
+ tailbits = (max % 4) * 6;
+
+ if (tailbits === 0) {
+ result.push((bits >> 16) & 0xFF);
+ result.push((bits >> 8) & 0xFF);
+ result.push(bits & 0xFF);
+ } else if (tailbits === 18) {
+ result.push((bits >> 10) & 0xFF);
+ result.push((bits >> 2) & 0xFF);
+ } else if (tailbits === 12) {
+ result.push((bits >> 4) & 0xFF);
+ }
+
+ return new Uint8Array(result);
+}
+
+function representYamlBinary(object /*, style*/) {
+ var result = '', bits = 0, idx, tail,
+ max = object.length,
+ map = BASE64_MAP;
+
+ // Convert every three bytes to 4 ASCII characters.
+
+ for (idx = 0; idx < max; idx++) {
+ if ((idx % 3 === 0) && idx) {
+ result += map[(bits >> 18) & 0x3F];
+ result += map[(bits >> 12) & 0x3F];
+ result += map[(bits >> 6) & 0x3F];
+ result += map[bits & 0x3F];
+ }
+
+ bits = (bits << 8) + object[idx];
+ }
+
+ // Dump tail
+
+ tail = max % 3;
+
+ if (tail === 0) {
+ result += map[(bits >> 18) & 0x3F];
+ result += map[(bits >> 12) & 0x3F];
+ result += map[(bits >> 6) & 0x3F];
+ result += map[bits & 0x3F];
+ } else if (tail === 2) {
+ result += map[(bits >> 10) & 0x3F];
+ result += map[(bits >> 4) & 0x3F];
+ result += map[(bits << 2) & 0x3F];
+ result += map[64];
+ } else if (tail === 1) {
+ result += map[(bits >> 2) & 0x3F];
+ result += map[(bits << 4) & 0x3F];
+ result += map[64];
+ result += map[64];
+ }
+
+ return result;
+}
+
+function isBinary(obj) {
+ return Object.prototype.toString.call(obj) === '[object Uint8Array]';
+}
+
+var binary = new type('tag:yaml.org,2002:binary', {
+ kind: 'scalar',
+ resolve: resolveYamlBinary,
+ construct: constructYamlBinary,
+ predicate: isBinary,
+ represent: representYamlBinary
+});
+
+var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
+var _toString$2 = Object.prototype.toString;
+
+function resolveYamlOmap(data) {
+ if (data === null) return true;
+
+ var objectKeys = [], index, length, pair, pairKey, pairHasKey,
+ object = data;
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ pair = object[index];
+ pairHasKey = false;
+
+ if (_toString$2.call(pair) !== '[object Object]') return false;
+
+ for (pairKey in pair) {
+ if (_hasOwnProperty$3.call(pair, pairKey)) {
+ if (!pairHasKey) pairHasKey = true;
+ else return false;
+ }
+ }
+
+ if (!pairHasKey) return false;
+
+ if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
+ else return false;
+ }
+
+ return true;
+}
+
+function constructYamlOmap(data) {
+ return data !== null ? data : [];
+}
+
+var omap = new type('tag:yaml.org,2002:omap', {
+ kind: 'sequence',
+ resolve: resolveYamlOmap,
+ construct: constructYamlOmap
+});
+
+var _toString$1 = Object.prototype.toString;
+
+function resolveYamlPairs(data) {
+ if (data === null) return true;
+
+ var index, length, pair, keys, result,
+ object = data;
+
+ result = new Array(object.length);
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ pair = object[index];
+
+ if (_toString$1.call(pair) !== '[object Object]') return false;
+
+ keys = Object.keys(pair);
+
+ if (keys.length !== 1) return false;
+
+ result[index] = [ keys[0], pair[keys[0]] ];
+ }
+
+ return true;
+}
+
+function constructYamlPairs(data) {
+ if (data === null) return [];
+
+ var index, length, pair, keys, result,
+ object = data;
+
+ result = new Array(object.length);
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ pair = object[index];
+
+ keys = Object.keys(pair);
+
+ result[index] = [ keys[0], pair[keys[0]] ];
+ }
+
+ return result;
+}
+
+var pairs = new type('tag:yaml.org,2002:pairs', {
+ kind: 'sequence',
+ resolve: resolveYamlPairs,
+ construct: constructYamlPairs
+});
+
+var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
+
+function resolveYamlSet(data) {
+ if (data === null) return true;
+
+ var key, object = data;
+
+ for (key in object) {
+ if (_hasOwnProperty$2.call(object, key)) {
+ if (object[key] !== null) return false;
+ }
+ }
+
+ return true;
+}
+
+function constructYamlSet(data) {
+ return data !== null ? data : {};
+}
+
+var set = new type('tag:yaml.org,2002:set', {
+ kind: 'mapping',
+ resolve: resolveYamlSet,
+ construct: constructYamlSet
+});
+
+var _default = core.extend({
+ implicit: [
+ timestamp,
+ merge
+ ],
+ explicit: [
+ binary,
+ omap,
+ pairs,
+ set
+ ]
+});
+
+/*eslint-disable max-len,no-use-before-define*/
+
+
+
+
+
+
+
+var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
+
+
+var CONTEXT_FLOW_IN = 1;
+var CONTEXT_FLOW_OUT = 2;
+var CONTEXT_BLOCK_IN = 3;
+var CONTEXT_BLOCK_OUT = 4;
+
+
+var CHOMPING_CLIP = 1;
+var CHOMPING_STRIP = 2;
+var CHOMPING_KEEP = 3;
+
+
+var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
+var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
+var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
+var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
+var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
+
+
+function _class(obj) { return Object.prototype.toString.call(obj); }
+
+function is_EOL(c) {
+ return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
+}
+
+function is_WHITE_SPACE(c) {
+ return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
+}
+
+function is_WS_OR_EOL(c) {
+ return (c === 0x09/* Tab */) ||
+ (c === 0x20/* Space */) ||
+ (c === 0x0A/* LF */) ||
+ (c === 0x0D/* CR */);
+}
+
+function is_FLOW_INDICATOR(c) {
+ return c === 0x2C/* , */ ||
+ c === 0x5B/* [ */ ||
+ c === 0x5D/* ] */ ||
+ c === 0x7B/* { */ ||
+ c === 0x7D/* } */;
+}
+
+function fromHexCode(c) {
+ var lc;
+
+ if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
+ return c - 0x30;
+ }
+
+ /*eslint-disable no-bitwise*/
+ lc = c | 0x20;
+
+ if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
+ return lc - 0x61 + 10;
+ }
+
+ return -1;
+}
+
+function escapedHexLen(c) {
+ if (c === 0x78/* x */) { return 2; }
+ if (c === 0x75/* u */) { return 4; }
+ if (c === 0x55/* U */) { return 8; }
+ return 0;
+}
+
+function fromDecimalCode(c) {
+ if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
+ return c - 0x30;
+ }
+
+ return -1;
+}
+
+function simpleEscapeSequence(c) {
+ /* eslint-disable indent */
+ return (c === 0x30/* 0 */) ? '\x00' :
+ (c === 0x61/* a */) ? '\x07' :
+ (c === 0x62/* b */) ? '\x08' :
+ (c === 0x74/* t */) ? '\x09' :
+ (c === 0x09/* Tab */) ? '\x09' :
+ (c === 0x6E/* n */) ? '\x0A' :
+ (c === 0x76/* v */) ? '\x0B' :
+ (c === 0x66/* f */) ? '\x0C' :
+ (c === 0x72/* r */) ? '\x0D' :
+ (c === 0x65/* e */) ? '\x1B' :
+ (c === 0x20/* Space */) ? ' ' :
+ (c === 0x22/* " */) ? '\x22' :
+ (c === 0x2F/* / */) ? '/' :
+ (c === 0x5C/* \ */) ? '\x5C' :
+ (c === 0x4E/* N */) ? '\x85' :
+ (c === 0x5F/* _ */) ? '\xA0' :
+ (c === 0x4C/* L */) ? '\u2028' :
+ (c === 0x50/* P */) ? '\u2029' : '';
+}
+
+function charFromCodepoint(c) {
+ if (c <= 0xFFFF) {
+ return String.fromCharCode(c);
+ }
+ // Encode UTF-16 surrogate pair
+ // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
+ return String.fromCharCode(
+ ((c - 0x010000) >> 10) + 0xD800,
+ ((c - 0x010000) & 0x03FF) + 0xDC00
+ );
+}
+
+var simpleEscapeCheck = new Array(256); // integer, for fast access
+var simpleEscapeMap = new Array(256);
+for (var i = 0; i < 256; i++) {
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
+}
+
+
+function State$1(input, options) {
+ this.input = input;
+
+ this.filename = options['filename'] || null;
+ this.schema = options['schema'] || _default;
+ this.onWarning = options['onWarning'] || null;
+ // (Hidden) Remove? makes the loader to expect YAML 1.1 documents
+ // if such documents have no explicit %YAML directive
+ this.legacy = options['legacy'] || false;
+
+ this.json = options['json'] || false;
+ this.listener = options['listener'] || null;
+
+ this.implicitTypes = this.schema.compiledImplicit;
+ this.typeMap = this.schema.compiledTypeMap;
+
+ this.length = input.length;
+ this.position = 0;
+ this.line = 0;
+ this.lineStart = 0;
+ this.lineIndent = 0;
+
+ // position of first leading tab in the current line,
+ // used to make sure there are no tabs in the indentation
+ this.firstTabInLine = -1;
+
+ this.documents = [];
+
+ /*
+ this.version;
+ this.checkLineBreaks;
+ this.tagMap;
+ this.anchorMap;
+ this.tag;
+ this.anchor;
+ this.kind;
+ this.result;*/
+
+}
+
+
+function generateError(state, message) {
+ var mark = {
+ name: state.filename,
+ buffer: state.input.slice(0, -1), // omit trailing \0
+ position: state.position,
+ line: state.line,
+ column: state.position - state.lineStart
+ };
+
+ mark.snippet = snippet(mark);
+
+ return new exception(message, mark);
+}
+
+function throwError(state, message) {
+ throw generateError(state, message);
+}
+
+function throwWarning(state, message) {
+ if (state.onWarning) {
+ state.onWarning.call(null, generateError(state, message));
+ }
+}
+
+
+var directiveHandlers = {
+
+ YAML: function handleYamlDirective(state, name, args) {
+
+ var match, major, minor;
+
+ if (state.version !== null) {
+ throwError(state, 'duplication of %YAML directive');
+ }
+
+ if (args.length !== 1) {
+ throwError(state, 'YAML directive accepts exactly one argument');
+ }
+
+ match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
+
+ if (match === null) {
+ throwError(state, 'ill-formed argument of the YAML directive');
+ }
+
+ major = parseInt(match[1], 10);
+ minor = parseInt(match[2], 10);
+
+ if (major !== 1) {
+ throwError(state, 'unacceptable YAML version of the document');
+ }
+
+ state.version = args[0];
+ state.checkLineBreaks = (minor < 2);
+
+ if (minor !== 1 && minor !== 2) {
+ throwWarning(state, 'unsupported YAML version of the document');
+ }
+ },
+
+ TAG: function handleTagDirective(state, name, args) {
+
+ var handle, prefix;
+
+ if (args.length !== 2) {
+ throwError(state, 'TAG directive accepts exactly two arguments');
+ }
+
+ handle = args[0];
+ prefix = args[1];
+
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
+ throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
+ }
+
+ if (_hasOwnProperty$1.call(state.tagMap, handle)) {
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
+ }
+
+ if (!PATTERN_TAG_URI.test(prefix)) {
+ throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
+ }
+
+ try {
+ prefix = decodeURIComponent(prefix);
+ } catch (err) {
+ throwError(state, 'tag prefix is malformed: ' + prefix);
+ }
+
+ state.tagMap[handle] = prefix;
+ }
+};
+
+
+function captureSegment(state, start, end, checkJson) {
+ var _position, _length, _character, _result;
+
+ if (start < end) {
+ _result = state.input.slice(start, end);
+
+ if (checkJson) {
+ for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
+ _character = _result.charCodeAt(_position);
+ if (!(_character === 0x09 ||
+ (0x20 <= _character && _character <= 0x10FFFF))) {
+ throwError(state, 'expected valid JSON character');
+ }
+ }
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
+ throwError(state, 'the stream contains non-printable characters');
+ }
+
+ state.result += _result;
+ }
+}
+
+function mergeMappings(state, destination, source, overridableKeys) {
+ var sourceKeys, key, index, quantity;
+
+ if (!common.isObject(source)) {
+ throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
+ }
+
+ sourceKeys = Object.keys(source);
+
+ for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
+ key = sourceKeys[index];
+
+ if (!_hasOwnProperty$1.call(destination, key)) {
+ destination[key] = source[key];
+ overridableKeys[key] = true;
+ }
+ }
+}
+
+function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode,
+ startLine, startLineStart, startPos) {
+
+ var index, quantity;
+
+ // The output is a plain object here, so keys can only be strings.
+ // We need to convert keyNode to a string, but doing so can hang the process
+ // (deeply nested arrays that explode exponentially using aliases).
+ if (Array.isArray(keyNode)) {
+ keyNode = Array.prototype.slice.call(keyNode);
+
+ for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
+ if (Array.isArray(keyNode[index])) {
+ throwError(state, 'nested arrays are not supported inside keys');
+ }
+
+ if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
+ keyNode[index] = '[object Object]';
+ }
+ }
+ }
+
+ // Avoid code execution in load() via toString property
+ // (still use its own toString for arrays, timestamps,
+ // and whatever user schema extensions happen to have @@toStringTag)
+ if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
+ keyNode = '[object Object]';
+ }
+
+
+ keyNode = String(keyNode);
+
+ if (_result === null) {
+ _result = {};
+ }
+
+ if (keyTag === 'tag:yaml.org,2002:merge') {
+ if (Array.isArray(valueNode)) {
+ for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
+ }
+ } else {
+ mergeMappings(state, _result, valueNode, overridableKeys);
+ }
+ } else {
+ if (!state.json &&
+ !_hasOwnProperty$1.call(overridableKeys, keyNode) &&
+ _hasOwnProperty$1.call(_result, keyNode)) {
+ state.line = startLine || state.line;
+ state.lineStart = startLineStart || state.lineStart;
+ state.position = startPos || state.position;
+ throwError(state, 'duplicated mapping key');
+ }
+
+ // used for this specific key only because Object.defineProperty is slow
+ if (keyNode === '__proto__') {
+ Object.defineProperty(_result, keyNode, {
+ configurable: true,
+ enumerable: true,
+ writable: true,
+ value: valueNode
+ });
+ } else {
+ _result[keyNode] = valueNode;
+ }
+ delete overridableKeys[keyNode];
+ }
+
+ return _result;
+}
+
+function readLineBreak(state) {
+ var ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x0A/* LF */) {
+ state.position++;
+ } else if (ch === 0x0D/* CR */) {
+ state.position++;
+ if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
+ state.position++;
+ }
+ } else {
+ throwError(state, 'a line break is expected');
+ }
+
+ state.line += 1;
+ state.lineStart = state.position;
+ state.firstTabInLine = -1;
+}
+
+function skipSeparationSpace(state, allowComments, checkIndent) {
+ var lineBreaks = 0,
+ ch = state.input.charCodeAt(state.position);
+
+ while (ch !== 0) {
+ while (is_WHITE_SPACE(ch)) {
+ if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) {
+ state.firstTabInLine = state.position;
+ }
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (allowComments && ch === 0x23/* # */) {
+ do {
+ ch = state.input.charCodeAt(++state.position);
+ } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
+ }
+
+ if (is_EOL(ch)) {
+ readLineBreak(state);
+
+ ch = state.input.charCodeAt(state.position);
+ lineBreaks++;
+ state.lineIndent = 0;
+
+ while (ch === 0x20/* Space */) {
+ state.lineIndent++;
+ ch = state.input.charCodeAt(++state.position);
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
+ throwWarning(state, 'deficient indentation');
+ }
+
+ return lineBreaks;
+}
+
+function testDocumentSeparator(state) {
+ var _position = state.position,
+ ch;
+
+ ch = state.input.charCodeAt(_position);
+
+ // Condition state.position === state.lineStart is tested
+ // in parent on each call, for efficiency. No needs to test here again.
+ if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
+ ch === state.input.charCodeAt(_position + 1) &&
+ ch === state.input.charCodeAt(_position + 2)) {
+
+ _position += 3;
+
+ ch = state.input.charCodeAt(_position);
+
+ if (ch === 0 || is_WS_OR_EOL(ch)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+function writeFoldedLines(state, count) {
+ if (count === 1) {
+ state.result += ' ';
+ } else if (count > 1) {
+ state.result += common.repeat('\n', count - 1);
+ }
+}
+
+
+function readPlainScalar(state, nodeIndent, withinFlowCollection) {
+ var preceding,
+ following,
+ captureStart,
+ captureEnd,
+ hasPendingContent,
+ _line,
+ _lineStart,
+ _lineIndent,
+ _kind = state.kind,
+ _result = state.result,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (is_WS_OR_EOL(ch) ||
+ is_FLOW_INDICATOR(ch) ||
+ ch === 0x23/* # */ ||
+ ch === 0x26/* & */ ||
+ ch === 0x2A/* * */ ||
+ ch === 0x21/* ! */ ||
+ ch === 0x7C/* | */ ||
+ ch === 0x3E/* > */ ||
+ ch === 0x27/* ' */ ||
+ ch === 0x22/* " */ ||
+ ch === 0x25/* % */ ||
+ ch === 0x40/* @ */ ||
+ ch === 0x60/* ` */) {
+ return false;
+ }
+
+ if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (is_WS_OR_EOL(following) ||
+ withinFlowCollection && is_FLOW_INDICATOR(following)) {
+ return false;
+ }
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+ captureStart = captureEnd = state.position;
+ hasPendingContent = false;
+
+ while (ch !== 0) {
+ if (ch === 0x3A/* : */) {
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (is_WS_OR_EOL(following) ||
+ withinFlowCollection && is_FLOW_INDICATOR(following)) {
+ break;
+ }
+
+ } else if (ch === 0x23/* # */) {
+ preceding = state.input.charCodeAt(state.position - 1);
+
+ if (is_WS_OR_EOL(preceding)) {
+ break;
+ }
+
+ } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
+ withinFlowCollection && is_FLOW_INDICATOR(ch)) {
+ break;
+
+ } else if (is_EOL(ch)) {
+ _line = state.line;
+ _lineStart = state.lineStart;
+ _lineIndent = state.lineIndent;
+ skipSeparationSpace(state, false, -1);
+
+ if (state.lineIndent >= nodeIndent) {
+ hasPendingContent = true;
+ ch = state.input.charCodeAt(state.position);
+ continue;
+ } else {
+ state.position = captureEnd;
+ state.line = _line;
+ state.lineStart = _lineStart;
+ state.lineIndent = _lineIndent;
+ break;
+ }
+ }
+
+ if (hasPendingContent) {
+ captureSegment(state, captureStart, captureEnd, false);
+ writeFoldedLines(state, state.line - _line);
+ captureStart = captureEnd = state.position;
+ hasPendingContent = false;
+ }
+
+ if (!is_WHITE_SPACE(ch)) {
+ captureEnd = state.position + 1;
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ captureSegment(state, captureStart, captureEnd, false);
+
+ if (state.result) {
+ return true;
+ }
+
+ state.kind = _kind;
+ state.result = _result;
+ return false;
+}
+
+function readSingleQuotedScalar(state, nodeIndent) {
+ var ch,
+ captureStart, captureEnd;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x27/* ' */) {
+ return false;
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+ state.position++;
+ captureStart = captureEnd = state.position;
+
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
+ if (ch === 0x27/* ' */) {
+ captureSegment(state, captureStart, state.position, true);
+ ch = state.input.charCodeAt(++state.position);
+
+ if (ch === 0x27/* ' */) {
+ captureStart = state.position;
+ state.position++;
+ captureEnd = state.position;
+ } else {
+ return true;
+ }
+
+ } else if (is_EOL(ch)) {
+ captureSegment(state, captureStart, captureEnd, true);
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
+ captureStart = captureEnd = state.position;
+
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
+ throwError(state, 'unexpected end of the document within a single quoted scalar');
+
+ } else {
+ state.position++;
+ captureEnd = state.position;
+ }
+ }
+
+ throwError(state, 'unexpected end of the stream within a single quoted scalar');
+}
+
+function readDoubleQuotedScalar(state, nodeIndent) {
+ var captureStart,
+ captureEnd,
+ hexLength,
+ hexResult,
+ tmp,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x22/* " */) {
+ return false;
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+ state.position++;
+ captureStart = captureEnd = state.position;
+
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
+ if (ch === 0x22/* " */) {
+ captureSegment(state, captureStart, state.position, true);
+ state.position++;
+ return true;
+
+ } else if (ch === 0x5C/* \ */) {
+ captureSegment(state, captureStart, state.position, true);
+ ch = state.input.charCodeAt(++state.position);
+
+ if (is_EOL(ch)) {
+ skipSeparationSpace(state, false, nodeIndent);
+
+ // TODO: rework to inline fn with no type cast?
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
+ state.result += simpleEscapeMap[ch];
+ state.position++;
+
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
+ hexLength = tmp;
+ hexResult = 0;
+
+ for (; hexLength > 0; hexLength--) {
+ ch = state.input.charCodeAt(++state.position);
+
+ if ((tmp = fromHexCode(ch)) >= 0) {
+ hexResult = (hexResult << 4) + tmp;
+
+ } else {
+ throwError(state, 'expected hexadecimal character');
+ }
+ }
+
+ state.result += charFromCodepoint(hexResult);
+
+ state.position++;
+
+ } else {
+ throwError(state, 'unknown escape sequence');
+ }
+
+ captureStart = captureEnd = state.position;
+
+ } else if (is_EOL(ch)) {
+ captureSegment(state, captureStart, captureEnd, true);
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
+ captureStart = captureEnd = state.position;
+
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
+ throwError(state, 'unexpected end of the document within a double quoted scalar');
+
+ } else {
+ state.position++;
+ captureEnd = state.position;
+ }
+ }
+
+ throwError(state, 'unexpected end of the stream within a double quoted scalar');
+}
+
+function readFlowCollection(state, nodeIndent) {
+ var readNext = true,
+ _line,
+ _lineStart,
+ _pos,
+ _tag = state.tag,
+ _result,
+ _anchor = state.anchor,
+ following,
+ terminator,
+ isPair,
+ isExplicitPair,
+ isMapping,
+ overridableKeys = Object.create(null),
+ keyNode,
+ keyTag,
+ valueNode,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x5B/* [ */) {
+ terminator = 0x5D;/* ] */
+ isMapping = false;
+ _result = [];
+ } else if (ch === 0x7B/* { */) {
+ terminator = 0x7D;/* } */
+ isMapping = true;
+ _result = {};
+ } else {
+ return false;
+ }
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = _result;
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+
+ while (ch !== 0) {
+ skipSeparationSpace(state, true, nodeIndent);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === terminator) {
+ state.position++;
+ state.tag = _tag;
+ state.anchor = _anchor;
+ state.kind = isMapping ? 'mapping' : 'sequence';
+ state.result = _result;
+ return true;
+ } else if (!readNext) {
+ throwError(state, 'missed comma between flow collection entries');
+ } else if (ch === 0x2C/* , */) {
+ // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4
+ throwError(state, "expected the node content, but found ','");
+ }
+
+ keyTag = keyNode = valueNode = null;
+ isPair = isExplicitPair = false;
+
+ if (ch === 0x3F/* ? */) {
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (is_WS_OR_EOL(following)) {
+ isPair = isExplicitPair = true;
+ state.position++;
+ skipSeparationSpace(state, true, nodeIndent);
+ }
+ }
+
+ _line = state.line; // Save the current line.
+ _lineStart = state.lineStart;
+ _pos = state.position;
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
+ keyTag = state.tag;
+ keyNode = state.result;
+ skipSeparationSpace(state, true, nodeIndent);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
+ isPair = true;
+ ch = state.input.charCodeAt(++state.position);
+ skipSeparationSpace(state, true, nodeIndent);
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
+ valueNode = state.result;
+ }
+
+ if (isMapping) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
+ } else if (isPair) {
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
+ } else {
+ _result.push(keyNode);
+ }
+
+ skipSeparationSpace(state, true, nodeIndent);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x2C/* , */) {
+ readNext = true;
+ ch = state.input.charCodeAt(++state.position);
+ } else {
+ readNext = false;
+ }
+ }
+
+ throwError(state, 'unexpected end of the stream within a flow collection');
+}
+
+function readBlockScalar(state, nodeIndent) {
+ var captureStart,
+ folding,
+ chomping = CHOMPING_CLIP,
+ didReadContent = false,
+ detectedIndent = false,
+ textIndent = nodeIndent,
+ emptyLines = 0,
+ atMoreIndented = false,
+ tmp,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch === 0x7C/* | */) {
+ folding = false;
+ } else if (ch === 0x3E/* > */) {
+ folding = true;
+ } else {
+ return false;
+ }
+
+ state.kind = 'scalar';
+ state.result = '';
+
+ while (ch !== 0) {
+ ch = state.input.charCodeAt(++state.position);
+
+ if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
+ if (CHOMPING_CLIP === chomping) {
+ chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
+ } else {
+ throwError(state, 'repeat of a chomping mode identifier');
+ }
+
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
+ if (tmp === 0) {
+ throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
+ } else if (!detectedIndent) {
+ textIndent = nodeIndent + tmp - 1;
+ detectedIndent = true;
+ } else {
+ throwError(state, 'repeat of an indentation width identifier');
+ }
+
+ } else {
+ break;
+ }
+ }
+
+ if (is_WHITE_SPACE(ch)) {
+ do { ch = state.input.charCodeAt(++state.position); }
+ while (is_WHITE_SPACE(ch));
+
+ if (ch === 0x23/* # */) {
+ do { ch = state.input.charCodeAt(++state.position); }
+ while (!is_EOL(ch) && (ch !== 0));
+ }
+ }
+
+ while (ch !== 0) {
+ readLineBreak(state);
+ state.lineIndent = 0;
+
+ ch = state.input.charCodeAt(state.position);
+
+ while ((!detectedIndent || state.lineIndent < textIndent) &&
+ (ch === 0x20/* Space */)) {
+ state.lineIndent++;
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (!detectedIndent && state.lineIndent > textIndent) {
+ textIndent = state.lineIndent;
+ }
+
+ if (is_EOL(ch)) {
+ emptyLines++;
+ continue;
+ }
+
+ // End of the scalar.
+ if (state.lineIndent < textIndent) {
+
+ // Perform the chomping.
+ if (chomping === CHOMPING_KEEP) {
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
+ } else if (chomping === CHOMPING_CLIP) {
+ if (didReadContent) { // i.e. only if the scalar is not empty.
+ state.result += '\n';
+ }
+ }
+
+ // Break this `while` cycle and go to the funciton's epilogue.
+ break;
+ }
+
+ // Folded style: use fancy rules to handle line breaks.
+ if (folding) {
+
+ // Lines starting with white space characters (more-indented lines) are not folded.
+ if (is_WHITE_SPACE(ch)) {
+ atMoreIndented = true;
+ // except for the first content line (cf. Example 8.1)
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
+
+ // End of more-indented block.
+ } else if (atMoreIndented) {
+ atMoreIndented = false;
+ state.result += common.repeat('\n', emptyLines + 1);
+
+ // Just one line break - perceive as the same line.
+ } else if (emptyLines === 0) {
+ if (didReadContent) { // i.e. only if we have already read some scalar content.
+ state.result += ' ';
+ }
+
+ // Several line breaks - perceive as different lines.
+ } else {
+ state.result += common.repeat('\n', emptyLines);
+ }
+
+ // Literal style: just add exact number of line breaks between content lines.
+ } else {
+ // Keep all line breaks except the header line break.
+ state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
+ }
+
+ didReadContent = true;
+ detectedIndent = true;
+ emptyLines = 0;
+ captureStart = state.position;
+
+ while (!is_EOL(ch) && (ch !== 0)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ captureSegment(state, captureStart, state.position, false);
+ }
+
+ return true;
+}
+
+function readBlockSequence(state, nodeIndent) {
+ var _line,
+ _tag = state.tag,
+ _anchor = state.anchor,
+ _result = [],
+ following,
+ detected = false,
+ ch;
+
+ // there is a leading tab before this token, so it can't be a block sequence/mapping;
+ // it can still be flow sequence/mapping or a scalar
+ if (state.firstTabInLine !== -1) return false;
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = _result;
+ }
+
+ ch = state.input.charCodeAt(state.position);
+
+ while (ch !== 0) {
+ if (state.firstTabInLine !== -1) {
+ state.position = state.firstTabInLine;
+ throwError(state, 'tab characters must not be used in indentation');
+ }
+
+ if (ch !== 0x2D/* - */) {
+ break;
+ }
+
+ following = state.input.charCodeAt(state.position + 1);
+
+ if (!is_WS_OR_EOL(following)) {
+ break;
+ }
+
+ detected = true;
+ state.position++;
+
+ if (skipSeparationSpace(state, true, -1)) {
+ if (state.lineIndent <= nodeIndent) {
+ _result.push(null);
+ ch = state.input.charCodeAt(state.position);
+ continue;
+ }
+ }
+
+ _line = state.line;
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
+ _result.push(state.result);
+ skipSeparationSpace(state, true, -1);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
+ throwError(state, 'bad indentation of a sequence entry');
+ } else if (state.lineIndent < nodeIndent) {
+ break;
+ }
+ }
+
+ if (detected) {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ state.kind = 'sequence';
+ state.result = _result;
+ return true;
+ }
+ return false;
+}
+
+function readBlockMapping(state, nodeIndent, flowIndent) {
+ var following,
+ allowCompact,
+ _line,
+ _keyLine,
+ _keyLineStart,
+ _keyPos,
+ _tag = state.tag,
+ _anchor = state.anchor,
+ _result = {},
+ overridableKeys = Object.create(null),
+ keyTag = null,
+ keyNode = null,
+ valueNode = null,
+ atExplicitKey = false,
+ detected = false,
+ ch;
+
+ // there is a leading tab before this token, so it can't be a block sequence/mapping;
+ // it can still be flow sequence/mapping or a scalar
+ if (state.firstTabInLine !== -1) return false;
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = _result;
+ }
+
+ ch = state.input.charCodeAt(state.position);
+
+ while (ch !== 0) {
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
+ state.position = state.firstTabInLine;
+ throwError(state, 'tab characters must not be used in indentation');
+ }
+
+ following = state.input.charCodeAt(state.position + 1);
+ _line = state.line; // Save the current line.
+
+ //
+ // Explicit notation case. There are two separate blocks:
+ // first for the key (denoted by "?") and second for the value (denoted by ":")
+ //
+ if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
+
+ if (ch === 0x3F/* ? */) {
+ if (atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
+ keyTag = keyNode = valueNode = null;
+ }
+
+ detected = true;
+ atExplicitKey = true;
+ allowCompact = true;
+
+ } else if (atExplicitKey) {
+ // i.e. 0x3A/* : */ === character after the explicit key.
+ atExplicitKey = false;
+ allowCompact = true;
+
+ } else {
+ throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
+ }
+
+ state.position += 1;
+ ch = following;
+
+ //
+ // Implicit notation case. Flow-style node as the key first, then ":", and the value.
+ //
+ } else {
+ _keyLine = state.line;
+ _keyLineStart = state.lineStart;
+ _keyPos = state.position;
+
+ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
+ // Neither implicit nor explicit notation.
+ // Reading is done. Go to the epilogue.
+ break;
+ }
+
+ if (state.line === _line) {
+ ch = state.input.charCodeAt(state.position);
+
+ while (is_WHITE_SPACE(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (ch === 0x3A/* : */) {
+ ch = state.input.charCodeAt(++state.position);
+
+ if (!is_WS_OR_EOL(ch)) {
+ throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
+ }
+
+ if (atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
+ keyTag = keyNode = valueNode = null;
+ }
+
+ detected = true;
+ atExplicitKey = false;
+ allowCompact = false;
+ keyTag = state.tag;
+ keyNode = state.result;
+
+ } else if (detected) {
+ throwError(state, 'can not read an implicit mapping pair; a colon is missed');
+
+ } else {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ return true; // Keep the result of `composeNode`.
+ }
+
+ } else if (detected) {
+ throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
+
+ } else {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ return true; // Keep the result of `composeNode`.
+ }
+ }
+
+ //
+ // Common reading code for both explicit and implicit notations.
+ //
+ if (state.line === _line || state.lineIndent > nodeIndent) {
+ if (atExplicitKey) {
+ _keyLine = state.line;
+ _keyLineStart = state.lineStart;
+ _keyPos = state.position;
+ }
+
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
+ if (atExplicitKey) {
+ keyNode = state.result;
+ } else {
+ valueNode = state.result;
+ }
+ }
+
+ if (!atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
+ keyTag = keyNode = valueNode = null;
+ }
+
+ skipSeparationSpace(state, true, -1);
+ ch = state.input.charCodeAt(state.position);
+ }
+
+ if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
+ throwError(state, 'bad indentation of a mapping entry');
+ } else if (state.lineIndent < nodeIndent) {
+ break;
+ }
+ }
+
+ //
+ // Epilogue.
+ //
+
+ // Special case: last mapping's node contains only the key in explicit notation.
+ if (atExplicitKey) {
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
+ }
+
+ // Expose the resulting mapping.
+ if (detected) {
+ state.tag = _tag;
+ state.anchor = _anchor;
+ state.kind = 'mapping';
+ state.result = _result;
+ }
+
+ return detected;
+}
+
+function readTagProperty(state) {
+ var _position,
+ isVerbatim = false,
+ isNamed = false,
+ tagHandle,
+ tagName,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x21/* ! */) return false;
+
+ if (state.tag !== null) {
+ throwError(state, 'duplication of a tag property');
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+
+ if (ch === 0x3C/* < */) {
+ isVerbatim = true;
+ ch = state.input.charCodeAt(++state.position);
+
+ } else if (ch === 0x21/* ! */) {
+ isNamed = true;
+ tagHandle = '!!';
+ ch = state.input.charCodeAt(++state.position);
+
+ } else {
+ tagHandle = '!';
+ }
+
+ _position = state.position;
+
+ if (isVerbatim) {
+ do { ch = state.input.charCodeAt(++state.position); }
+ while (ch !== 0 && ch !== 0x3E/* > */);
+
+ if (state.position < state.length) {
+ tagName = state.input.slice(_position, state.position);
+ ch = state.input.charCodeAt(++state.position);
+ } else {
+ throwError(state, 'unexpected end of the stream within a verbatim tag');
+ }
+ } else {
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
+
+ if (ch === 0x21/* ! */) {
+ if (!isNamed) {
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
+
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
+ throwError(state, 'named tag handle cannot contain such characters');
+ }
+
+ isNamed = true;
+ _position = state.position + 1;
+ } else {
+ throwError(state, 'tag suffix cannot contain exclamation marks');
+ }
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ tagName = state.input.slice(_position, state.position);
+
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
+ throwError(state, 'tag suffix cannot contain flow indicator characters');
+ }
+ }
+
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
+ throwError(state, 'tag name cannot contain such characters: ' + tagName);
+ }
+
+ try {
+ tagName = decodeURIComponent(tagName);
+ } catch (err) {
+ throwError(state, 'tag name is malformed: ' + tagName);
+ }
+
+ if (isVerbatim) {
+ state.tag = tagName;
+
+ } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
+ state.tag = state.tagMap[tagHandle] + tagName;
+
+ } else if (tagHandle === '!') {
+ state.tag = '!' + tagName;
+
+ } else if (tagHandle === '!!') {
+ state.tag = 'tag:yaml.org,2002:' + tagName;
+
+ } else {
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
+ }
+
+ return true;
+}
+
+function readAnchorProperty(state) {
+ var _position,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x26/* & */) return false;
+
+ if (state.anchor !== null) {
+ throwError(state, 'duplication of an anchor property');
+ }
+
+ ch = state.input.charCodeAt(++state.position);
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (state.position === _position) {
+ throwError(state, 'name of an anchor node must contain at least one character');
+ }
+
+ state.anchor = state.input.slice(_position, state.position);
+ return true;
+}
+
+function readAlias(state) {
+ var _position, alias,
+ ch;
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (ch !== 0x2A/* * */) return false;
+
+ ch = state.input.charCodeAt(++state.position);
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (state.position === _position) {
+ throwError(state, 'name of an alias node must contain at least one character');
+ }
+
+ alias = state.input.slice(_position, state.position);
+
+ if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
+ throwError(state, 'unidentified alias "' + alias + '"');
+ }
+
+ state.result = state.anchorMap[alias];
+ skipSeparationSpace(state, true, -1);
+ return true;
+}
+
+function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
+ var allowBlockStyles,
+ allowBlockScalars,
+ allowBlockCollections,
+ indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) {
+ indentStatus = 1;
+ } else if (state.lineIndent === parentIndent) {
+ indentStatus = 0;
+ } else if (state.lineIndent < parentIndent) {
+ indentStatus = -1;
+ }
+ }
+ }
+
+ if (indentStatus === 1) {
+ while (readTagProperty(state) || readAnchorProperty(state)) {
+ if (skipSeparationSpace(state, true, -1)) {
+ atNewLine = true;
+ allowBlockCollections = allowBlockStyles;
+
+ if (state.lineIndent > parentIndent) {
+ indentStatus = 1;
+ } else if (state.lineIndent === parentIndent) {
+ indentStatus = 0;
+ } else if (state.lineIndent < parentIndent) {
+ indentStatus = -1;
+ }
+ } else {
+ allowBlockCollections = false;
+ }
+ }
+ }
+
+ if (allowBlockCollections) {
+ allowBlockCollections = atNewLine || allowCompact;
+ }
+
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
+ flowIndent = parentIndent;
+ } else {
+ flowIndent = parentIndent + 1;
+ }
+
+ blockIndent = state.position - state.lineStart;
+
+ if (indentStatus === 1) {
+ if (allowBlockCollections &&
+ (readBlockSequence(state, blockIndent) ||
+ readBlockMapping(state, blockIndent, flowIndent)) ||
+ readFlowCollection(state, flowIndent)) {
+ hasContent = true;
+ } else {
+ if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
+ readSingleQuotedScalar(state, flowIndent) ||
+ readDoubleQuotedScalar(state, flowIndent)) {
+ hasContent = true;
+
+ } else if (readAlias(state)) {
+ hasContent = true;
+
+ if (state.tag !== null || state.anchor !== null) {
+ throwError(state, 'alias node should not have any properties');
+ }
+
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
+ hasContent = true;
+
+ if (state.tag === null) {
+ state.tag = '?';
+ }
+ }
+
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = state.result;
+ }
+ }
+ } else if (indentStatus === 0) {
+ // Special case: block sequences are allowed to have same indentation level as the parent.
+ // http://www.yaml.org/spec/1.2/spec.html#id2799784
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
+ }
+ }
+
+ if (state.tag === null) {
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = state.result;
+ }
+
+ } else if (state.tag === '?') {
+ // Implicit resolving is not allowed for non-scalar types, and '?'
+ // non-specific tag is only automatically assigned to plain scalars.
+ //
+ // We only need to check kind conformity in case user explicitly assigns '?'
+ // tag, for example like this: "!> [0]"
+ //
+ if (state.result !== null && state.kind !== 'scalar') {
+ throwError(state, 'unacceptable node kind for !> tag; it should be "scalar", not "' + state.kind + '"');
+ }
+
+ for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
+ type = state.implicitTypes[typeIndex];
+
+ if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
+ state.result = type.construct(state.result);
+ state.tag = type.tag;
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = state.result;
+ }
+ break;
+ }
+ }
+ } else if (state.tag !== '!') {
+ if (_hasOwnProperty$1.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
+ type = state.typeMap[state.kind || 'fallback'][state.tag];
+ } else {
+ // looking for multi type
+ type = null;
+ typeList = state.typeMap.multi[state.kind || 'fallback'];
+
+ for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
+ if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
+ type = typeList[typeIndex];
+ break;
+ }
+ }
+ }
+
+ if (!type) {
+ throwError(state, 'unknown tag !<' + state.tag + '>');
+ }
+
+ if (state.result !== null && type.kind !== state.kind) {
+ throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
+ }
+
+ if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched
+ throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
+ } else {
+ state.result = type.construct(state.result, state.tag);
+ if (state.anchor !== null) {
+ state.anchorMap[state.anchor] = state.result;
+ }
+ }
+ }
+
+ if (state.listener !== null) {
+ state.listener('close', state);
+ }
+ return state.tag !== null || state.anchor !== null || hasContent;
+}
+
+function readDocument(state) {
+ var documentStart = state.position,
+ _position,
+ directiveName,
+ directiveArgs,
+ hasDirectives = false,
+ ch;
+
+ state.version = null;
+ state.checkLineBreaks = state.legacy;
+ state.tagMap = Object.create(null);
+ state.anchorMap = Object.create(null);
+
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
+ skipSeparationSpace(state, true, -1);
+
+ ch = state.input.charCodeAt(state.position);
+
+ if (state.lineIndent > 0 || ch !== 0x25/* % */) {
+ break;
+ }
+
+ hasDirectives = true;
+ ch = state.input.charCodeAt(++state.position);
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ directiveName = state.input.slice(_position, state.position);
+ directiveArgs = [];
+
+ if (directiveName.length < 1) {
+ throwError(state, 'directive name must not be less than one character in length');
+ }
+
+ while (ch !== 0) {
+ while (is_WHITE_SPACE(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ if (ch === 0x23/* # */) {
+ do { ch = state.input.charCodeAt(++state.position); }
+ while (ch !== 0 && !is_EOL(ch));
+ break;
+ }
+
+ if (is_EOL(ch)) break;
+
+ _position = state.position;
+
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
+ ch = state.input.charCodeAt(++state.position);
+ }
+
+ directiveArgs.push(state.input.slice(_position, state.position));
+ }
+
+ if (ch !== 0) readLineBreak(state);
+
+ if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
+ } else {
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
+ }
+ }
+
+ skipSeparationSpace(state, true, -1);
+
+ if (state.lineIndent === 0 &&
+ state.input.charCodeAt(state.position) === 0x2D/* - */ &&
+ state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
+ state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
+ state.position += 3;
+ skipSeparationSpace(state, true, -1);
+
+ } else if (hasDirectives) {
+ throwError(state, 'directives end mark is expected');
+ }
+
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
+ skipSeparationSpace(state, true, -1);
+
+ if (state.checkLineBreaks &&
+ PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
+ throwWarning(state, 'non-ASCII line breaks are interpreted as content');
+ }
+
+ state.documents.push(state.result);
+
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
+
+ if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
+ state.position += 3;
+ skipSeparationSpace(state, true, -1);
+ }
+ return;
+ }
+
+ if (state.position < (state.length - 1)) {
+ throwError(state, 'end of the stream or a document separator is expected');
+ } else {
+ return;
+ }
+}
+
+
+function loadDocuments(input, options) {
+ input = String(input);
+ options = options || {};
+
+ if (input.length !== 0) {
+
+ // Add tailing `\n` if not exists
+ if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
+ input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
+ input += '\n';
+ }
+
+ // Strip BOM
+ if (input.charCodeAt(0) === 0xFEFF) {
+ input = input.slice(1);
+ }
+ }
+
+ var state = new State$1(input, options);
+
+ var nullpos = input.indexOf('\0');
+
+ if (nullpos !== -1) {
+ state.position = nullpos;
+ throwError(state, 'null byte is not allowed in input');
+ }
+
+ // Use 0 as string terminator. That significantly simplifies bounds check.
+ state.input += '\0';
+
+ while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
+ state.lineIndent += 1;
+ state.position += 1;
+ }
+
+ while (state.position < (state.length - 1)) {
+ readDocument(state);
+ }
+
+ return state.documents;
+}
+
+
+function loadAll$1(input, iterator, options) {
+ if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') {
+ options = iterator;
+ iterator = null;
+ }
+
+ var documents = loadDocuments(input, options);
+
+ if (typeof iterator !== 'function') {
+ return documents;
+ }
+
+ for (var index = 0, length = documents.length; index < length; index += 1) {
+ iterator(documents[index]);
+ }
+}
+
+
+function load$1(input, options) {
+ var documents = loadDocuments(input, options);
+
+ if (documents.length === 0) {
+ /*eslint-disable no-undefined*/
+ return undefined;
+ } else if (documents.length === 1) {
+ return documents[0];
+ }
+ throw new exception('expected a single document in the stream, but found more');
+}
+
+
+var loadAll_1 = loadAll$1;
+var load_1 = load$1;
+
+var loader = {
+ loadAll: loadAll_1,
+ load: load_1
+};
+
+/*eslint-disable no-use-before-define*/
+
+
+
+
+
+var _toString = Object.prototype.toString;
+var _hasOwnProperty = Object.prototype.hasOwnProperty;
+
+var CHAR_BOM = 0xFEFF;
+var CHAR_TAB = 0x09; /* Tab */
+var CHAR_LINE_FEED = 0x0A; /* LF */
+var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
+var CHAR_SPACE = 0x20; /* Space */
+var CHAR_EXCLAMATION = 0x21; /* ! */
+var CHAR_DOUBLE_QUOTE = 0x22; /* " */
+var CHAR_SHARP = 0x23; /* # */
+var CHAR_PERCENT = 0x25; /* % */
+var CHAR_AMPERSAND = 0x26; /* & */
+var CHAR_SINGLE_QUOTE = 0x27; /* ' */
+var CHAR_ASTERISK = 0x2A; /* * */
+var CHAR_COMMA = 0x2C; /* , */
+var CHAR_MINUS = 0x2D; /* - */
+var CHAR_COLON = 0x3A; /* : */
+var CHAR_EQUALS = 0x3D; /* = */
+var CHAR_GREATER_THAN = 0x3E; /* > */
+var CHAR_QUESTION = 0x3F; /* ? */
+var CHAR_COMMERCIAL_AT = 0x40; /* @ */
+var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
+var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
+var CHAR_GRAVE_ACCENT = 0x60; /* ` */
+var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
+var CHAR_VERTICAL_LINE = 0x7C; /* | */
+var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
+
+var ESCAPE_SEQUENCES = {};
+
+ESCAPE_SEQUENCES[0x00] = '\\0';
+ESCAPE_SEQUENCES[0x07] = '\\a';
+ESCAPE_SEQUENCES[0x08] = '\\b';
+ESCAPE_SEQUENCES[0x09] = '\\t';
+ESCAPE_SEQUENCES[0x0A] = '\\n';
+ESCAPE_SEQUENCES[0x0B] = '\\v';
+ESCAPE_SEQUENCES[0x0C] = '\\f';
+ESCAPE_SEQUENCES[0x0D] = '\\r';
+ESCAPE_SEQUENCES[0x1B] = '\\e';
+ESCAPE_SEQUENCES[0x22] = '\\"';
+ESCAPE_SEQUENCES[0x5C] = '\\\\';
+ESCAPE_SEQUENCES[0x85] = '\\N';
+ESCAPE_SEQUENCES[0xA0] = '\\_';
+ESCAPE_SEQUENCES[0x2028] = '\\L';
+ESCAPE_SEQUENCES[0x2029] = '\\P';
+
+var DEPRECATED_BOOLEANS_SYNTAX = [
+ 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
+ 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
+];
+
+var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
+
+function compileStyleMap(schema, map) {
+ var result, keys, index, length, tag, style, type;
+
+ if (map === null) return {};
+
+ result = {};
+ keys = Object.keys(map);
+
+ for (index = 0, length = keys.length; index < length; index += 1) {
+ tag = keys[index];
+ style = String(map[tag]);
+
+ if (tag.slice(0, 2) === '!!') {
+ tag = 'tag:yaml.org,2002:' + tag.slice(2);
+ }
+ type = schema.compiledTypeMap['fallback'][tag];
+
+ if (type && _hasOwnProperty.call(type.styleAliases, style)) {
+ style = type.styleAliases[style];
+ }
+
+ result[tag] = style;
+ }
+
+ return result;
+}
+
+function encodeHex(character) {
+ var string, handle, length;
+
+ string = character.toString(16).toUpperCase();
+
+ if (character <= 0xFF) {
+ handle = 'x';
+ length = 2;
+ } else if (character <= 0xFFFF) {
+ handle = 'u';
+ length = 4;
+ } else if (character <= 0xFFFFFFFF) {
+ handle = 'U';
+ length = 8;
+ } else {
+ throw new exception('code point within a string may not be greater than 0xFFFFFFFF');
+ }
+
+ return '\\' + handle + common.repeat('0', length - string.length) + string;
+}
+
+
+var QUOTING_TYPE_SINGLE = 1,
+ QUOTING_TYPE_DOUBLE = 2;
+
+function State(options) {
+ this.schema = options['schema'] || _default;
+ this.indent = Math.max(1, (options['indent'] || 2));
+ this.noArrayIndent = options['noArrayIndent'] || false;
+ this.skipInvalid = options['skipInvalid'] || false;
+ this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
+ this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
+ this.sortKeys = options['sortKeys'] || false;
+ this.lineWidth = options['lineWidth'] || 80;
+ this.noRefs = options['noRefs'] || false;
+ this.noCompatMode = options['noCompatMode'] || false;
+ this.condenseFlow = options['condenseFlow'] || false;
+ this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
+ this.forceQuotes = options['forceQuotes'] || false;
+ this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null;
+
+ this.implicitTypes = this.schema.compiledImplicit;
+ this.explicitTypes = this.schema.compiledExplicit;
+
+ this.tag = null;
+ this.result = '';
+
+ this.duplicates = [];
+ this.usedDuplicates = null;
+}
+
+// Indents every line in a string. Empty lines (\n only) are not indented.
+function indentString(string, spaces) {
+ var ind = common.repeat(' ', spaces),
+ position = 0,
+ next = -1,
+ result = '',
+ line,
+ length = string.length;
+
+ while (position < length) {
+ next = string.indexOf('\n', position);
+ if (next === -1) {
+ line = string.slice(position);
+ position = length;
+ } else {
+ line = string.slice(position, next + 1);
+ position = next + 1;
+ }
+
+ if (line.length && line !== '\n') result += ind;
+
+ result += line;
+ }
+
+ return result;
+}
+
+function generateNextLine(state, level) {
+ return '\n' + common.repeat(' ', state.indent * level);
+}
+
+function testImplicitResolving(state, str) {
+ var index, length, type;
+
+ for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
+ type = state.implicitTypes[index];
+
+ if (type.resolve(str)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+// [33] s-white ::= s-space | s-tab
+function isWhitespace(c) {
+ return c === CHAR_SPACE || c === CHAR_TAB;
+}
+
+// Returns true if the character can be printed without escaping.
+// From YAML 1.2: "any allowed characters known to be non-printable
+// should also be escaped. [However,] This isn’t mandatory"
+// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
+function isPrintable(c) {
+ return (0x00020 <= c && c <= 0x00007E)
+ || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
+ || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM)
+ || (0x10000 <= c && c <= 0x10FFFF);
+}
+
+// [34] ns-char ::= nb-char - s-white
+// [27] nb-char ::= c-printable - b-char - c-byte-order-mark
+// [26] b-char ::= b-line-feed | b-carriage-return
+// Including s-white (for some reason, examples doesn't match specs in this aspect)
+// ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark
+function isNsCharOrWhitespace(c) {
+ return isPrintable(c)
+ && c !== CHAR_BOM
+ // - b-char
+ && c !== CHAR_CARRIAGE_RETURN
+ && c !== CHAR_LINE_FEED;
+}
+
+// [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out
+// c = flow-in ⇒ ns-plain-safe-in
+// c = block-key ⇒ ns-plain-safe-out
+// c = flow-key ⇒ ns-plain-safe-in
+// [128] ns-plain-safe-out ::= ns-char
+// [129] ns-plain-safe-in ::= ns-char - c-flow-indicator
+// [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” )
+// | ( /* An ns-char preceding */ “#” )
+// | ( “:” /* Followed by an ns-plain-safe(c) */ )
+function isPlainSafe(c, prev, inblock) {
+ var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
+ var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
+ return (
+ // ns-plain-safe
+ inblock ? // c = flow-in
+ cIsNsCharOrWhitespace
+ : cIsNsCharOrWhitespace
+ // - c-flow-indicator
+ && c !== CHAR_COMMA
+ && c !== CHAR_LEFT_SQUARE_BRACKET
+ && c !== CHAR_RIGHT_SQUARE_BRACKET
+ && c !== CHAR_LEFT_CURLY_BRACKET
+ && c !== CHAR_RIGHT_CURLY_BRACKET
+ )
+ // ns-plain-char
+ && c !== CHAR_SHARP // false on '#'
+ && !(prev === CHAR_COLON && !cIsNsChar) // false on ': '
+ || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#'
+ || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]'
+}
+
+// Simplified test for values allowed as the first character in plain style.
+function isPlainSafeFirst(c) {
+ // Uses a subset of ns-char - c-indicator
+ // where ns-char = nb-char - s-white.
+ // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part
+ return isPrintable(c) && c !== CHAR_BOM
+ && !isWhitespace(c) // - s-white
+ // - (c-indicator ::=
+ // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
+ && c !== CHAR_MINUS
+ && c !== CHAR_QUESTION
+ && c !== CHAR_COLON
+ && c !== CHAR_COMMA
+ && c !== CHAR_LEFT_SQUARE_BRACKET
+ && c !== CHAR_RIGHT_SQUARE_BRACKET
+ && c !== CHAR_LEFT_CURLY_BRACKET
+ && c !== CHAR_RIGHT_CURLY_BRACKET
+ // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
+ && c !== CHAR_SHARP
+ && c !== CHAR_AMPERSAND
+ && c !== CHAR_ASTERISK
+ && c !== CHAR_EXCLAMATION
+ && c !== CHAR_VERTICAL_LINE
+ && c !== CHAR_EQUALS
+ && c !== CHAR_GREATER_THAN
+ && c !== CHAR_SINGLE_QUOTE
+ && c !== CHAR_DOUBLE_QUOTE
+ // | “%” | “@” | “`”)
+ && c !== CHAR_PERCENT
+ && c !== CHAR_COMMERCIAL_AT
+ && c !== CHAR_GRAVE_ACCENT;
+}
+
+// Simplified test for values allowed as the last character in plain style.
+function isPlainSafeLast(c) {
+ // just not whitespace or colon, it will be checked to be plain character later
+ return !isWhitespace(c) && c !== CHAR_COLON;
+}
+
+// Same as 'string'.codePointAt(pos), but works in older browsers.
+function codePointAt(string, pos) {
+ var first = string.charCodeAt(pos), second;
+ if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) {
+ second = string.charCodeAt(pos + 1);
+ if (second >= 0xDC00 && second <= 0xDFFF) {
+ // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
+ }
+ }
+ return first;
+}
+
+// Determines whether block indentation indicator is required.
+function needIndentIndicator(string) {
+ var leadingSpaceRe = /^\n* /;
+ return leadingSpaceRe.test(string);
+}
+
+var STYLE_PLAIN = 1,
+ STYLE_SINGLE = 2,
+ STYLE_LITERAL = 3,
+ STYLE_FOLDED = 4,
+ STYLE_DOUBLE = 5;
+
+// Determines which scalar styles are possible and returns the preferred style.
+// lineWidth = -1 => no limit.
+// Pre-conditions: str.length > 0.
+// Post-conditions:
+// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
+// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
+// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
+function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth,
+ testAmbiguousType, quotingType, forceQuotes, inblock) {
+
+ var i;
+ var char = 0;
+ var prevChar = null;
+ var hasLineBreak = false;
+ var hasFoldableLine = false; // only checked if shouldTrackWidth
+ var shouldTrackWidth = lineWidth !== -1;
+ var previousLineBreak = -1; // count the first line correctly
+ var plain = isPlainSafeFirst(codePointAt(string, 0))
+ && isPlainSafeLast(codePointAt(string, string.length - 1));
+
+ if (singleLineOnly || forceQuotes) {
+ // Case: no block styles.
+ // Check for disallowed characters to rule out plain and single.
+ for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) {
+ char = codePointAt(string, i);
+ if (!isPrintable(char)) {
+ return STYLE_DOUBLE;
+ }
+ plain = plain && isPlainSafe(char, prevChar, inblock);
+ prevChar = char;
+ }
+ } else {
+ // Case: block styles permitted.
+ for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) {
+ char = codePointAt(string, i);
+ if (char === CHAR_LINE_FEED) {
+ hasLineBreak = true;
+ // Check if any line can be folded.
+ if (shouldTrackWidth) {
+ hasFoldableLine = hasFoldableLine ||
+ // Foldable line = too long, and not more-indented.
+ (i - previousLineBreak - 1 > lineWidth &&
+ string[previousLineBreak + 1] !== ' ');
+ previousLineBreak = i;
+ }
+ } else if (!isPrintable(char)) {
+ return STYLE_DOUBLE;
+ }
+ plain = plain && isPlainSafe(char, prevChar, inblock);
+ prevChar = char;
+ }
+ // in case the end is missing a \n
+ hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
+ (i - previousLineBreak - 1 > lineWidth &&
+ string[previousLineBreak + 1] !== ' '));
+ }
+ // Although every style can represent \n without escaping, prefer block styles
+ // for multiline, since they're more readable and they don't add empty lines.
+ // Also prefer folding a super-long line.
+ if (!hasLineBreak && !hasFoldableLine) {
+ // Strings interpretable as another type have to be quoted;
+ // e.g. the string 'true' vs. the boolean true.
+ if (plain && !forceQuotes && !testAmbiguousType(string)) {
+ return STYLE_PLAIN;
+ }
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
+ }
+ // Edge case: block indentation indicator can only have one digit.
+ if (indentPerLevel > 9 && needIndentIndicator(string)) {
+ return STYLE_DOUBLE;
+ }
+ // At this point we know block styles are valid.
+ // Prefer literal style unless we want to fold.
+ if (!forceQuotes) {
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
+ }
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
+}
+
+// Note: line breaking/folding is implemented for only the folded style.
+// NB. We drop the last trailing newline (if any) of a returned block scalar
+// since the dumper adds its own newline. This always works:
+// • No ending newline => unaffected; already using strip "-" chomping.
+// • Ending newline => removed then restored.
+// Importantly, this keeps the "+" chomp indicator from gaining an extra line.
+function writeScalar(state, string, level, iskey, inblock) {
+ state.dump = (function () {
+ if (string.length === 0) {
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
+ }
+ if (!state.noCompatMode) {
+ if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'");
+ }
+ }
+
+ var indent = state.indent * Math.max(1, level); // no 0-indent scalars
+ // As indentation gets deeper, let the width decrease monotonically
+ // to the lower bound min(state.lineWidth, 40).
+ // Note that this implies
+ // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
+ // state.lineWidth > 40 + state.indent: width decreases until the lower bound.
+ // This behaves better than a constant minimum width which disallows narrower options,
+ // or an indent threshold which causes the width to suddenly increase.
+ var lineWidth = state.lineWidth === -1
+ ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
+
+ // Without knowing if keys are implicit/explicit, assume implicit for safety.
+ var singleLineOnly = iskey
+ // No block styles in flow mode.
+ || (state.flowLevel > -1 && level >= state.flowLevel);
+ function testAmbiguity(string) {
+ return testImplicitResolving(state, string);
+ }
+
+ switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth,
+ testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
+
+ case STYLE_PLAIN:
+ return string;
+ case STYLE_SINGLE:
+ return "'" + string.replace(/'/g, "''") + "'";
+ case STYLE_LITERAL:
+ return '|' + blockHeader(string, state.indent)
+ + dropEndingNewline(indentString(string, indent));
+ case STYLE_FOLDED:
+ return '>' + blockHeader(string, state.indent)
+ + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
+ case STYLE_DOUBLE:
+ return '"' + escapeString(string) + '"';
+ default:
+ throw new exception('impossible error: invalid scalar style');
+ }
+ }());
+}
+
+// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
+function blockHeader(string, indentPerLevel) {
+ var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
+
+ // note the special case: the string '\n' counts as a "trailing" empty line.
+ var clip = string[string.length - 1] === '\n';
+ var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
+ var chomp = keep ? '+' : (clip ? '' : '-');
+
+ return indentIndicator + chomp + '\n';
+}
+
+// (See the note for writeScalar.)
+function dropEndingNewline(string) {
+ return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
+}
+
+// Note: a long line without a suitable break point will exceed the width limit.
+// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
+function foldString(string, width) {
+ // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
+ // unless they're before or after a more-indented line, or at the very
+ // beginning or end, in which case $k$ maps to $k$.
+ // Therefore, parse each chunk as newline(s) followed by a content line.
+ var lineRe = /(\n+)([^\n]*)/g;
+
+ // first line (possibly an empty line)
+ var result = (function () {
+ var nextLF = string.indexOf('\n');
+ nextLF = nextLF !== -1 ? nextLF : string.length;
+ lineRe.lastIndex = nextLF;
+ return foldLine(string.slice(0, nextLF), width);
+ }());
+ // If we haven't reached the first content line yet, don't add an extra \n.
+ var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
+ var moreIndented;
+
+ // rest of the lines
+ var match;
+ while ((match = lineRe.exec(string))) {
+ var prefix = match[1], line = match[2];
+ moreIndented = (line[0] === ' ');
+ result += prefix
+ + (!prevMoreIndented && !moreIndented && line !== ''
+ ? '\n' : '')
+ + foldLine(line, width);
+ prevMoreIndented = moreIndented;
+ }
+
+ return result;
+}
+
+// Greedy line breaking.
+// Picks the longest line under the limit each time,
+// otherwise settles for the shortest line over the limit.
+// NB. More-indented lines *cannot* be folded, as that would add an extra \n.
+function foldLine(line, width) {
+ if (line === '' || line[0] === ' ') return line;
+
+ // Since a more-indented line adds a \n, breaks can't be followed by a space.
+ var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
+ var match;
+ // start is an inclusive index. end, curr, and next are exclusive.
+ var start = 0, end, curr = 0, next = 0;
+ var result = '';
+
+ // Invariants: 0 <= start <= length-1.
+ // 0 <= curr <= next <= max(0, length-2). curr - start <= width.
+ // Inside the loop:
+ // A match implies length >= 2, so curr and next are <= length-2.
+ while ((match = breakRe.exec(line))) {
+ next = match.index;
+ // maintain invariant: curr - start <= width
+ if (next - start > width) {
+ end = (curr > start) ? curr : next; // derive end <= length-2
+ result += '\n' + line.slice(start, end);
+ // skip the space that was output as \n
+ start = end + 1; // derive start <= length-1
+ }
+ curr = next;
+ }
+
+ // By the invariants, start <= length-1, so there is something left over.
+ // It is either the whole string or a part starting from non-whitespace.
+ result += '\n';
+ // Insert a break if the remainder is too long and there is a break available.
+ if (line.length - start > width && curr > start) {
+ result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
+ } else {
+ result += line.slice(start);
+ }
+
+ return result.slice(1); // drop extra \n joiner
+}
+
+// Escapes a double-quoted string.
+function escapeString(string) {
+ var result = '';
+ var char = 0;
+ var escapeSeq;
+
+ for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) {
+ char = codePointAt(string, i);
+ escapeSeq = ESCAPE_SEQUENCES[char];
+
+ if (!escapeSeq && isPrintable(char)) {
+ result += string[i];
+ if (char >= 0x10000) result += string[i + 1];
+ } else {
+ result += escapeSeq || encodeHex(char);
+ }
+ }
+
+ return result;
+}
+
+function writeFlowSequence(state, level, object) {
+ var _result = '',
+ _tag = state.tag,
+ index,
+ length,
+ value;
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ value = object[index];
+
+ if (state.replacer) {
+ value = state.replacer.call(object, String(index), value);
+ }
+
+ // Write only valid elements, put null instead of invalid elements.
+ if (writeNode(state, level, value, false, false) ||
+ (typeof value === 'undefined' &&
+ writeNode(state, level, null, false, false))) {
+
+ if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : '');
+ _result += state.dump;
+ }
+ }
+
+ state.tag = _tag;
+ state.dump = '[' + _result + ']';
+}
+
+function writeBlockSequence(state, level, object, compact) {
+ var _result = '',
+ _tag = state.tag,
+ index,
+ length,
+ value;
+
+ for (index = 0, length = object.length; index < length; index += 1) {
+ value = object[index];
+
+ if (state.replacer) {
+ value = state.replacer.call(object, String(index), value);
+ }
+
+ // Write only valid elements, put null instead of invalid elements.
+ if (writeNode(state, level + 1, value, true, true, false, true) ||
+ (typeof value === 'undefined' &&
+ writeNode(state, level + 1, null, true, true, false, true))) {
+
+ if (!compact || _result !== '') {
+ _result += generateNextLine(state, level);
+ }
+
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
+ _result += '-';
+ } else {
+ _result += '- ';
+ }
+
+ _result += state.dump;
+ }
+ }
+
+ state.tag = _tag;
+ state.dump = _result || '[]'; // Empty sequence if no valid values.
+}
+
+function writeFlowMapping(state, level, object) {
+ var _result = '',
+ _tag = state.tag,
+ objectKeyList = Object.keys(object),
+ index,
+ length,
+ objectKey,
+ objectValue,
+ pairBuffer;
+
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
+
+ pairBuffer = '';
+ if (_result !== '') pairBuffer += ', ';
+
+ if (state.condenseFlow) pairBuffer += '"';
+
+ objectKey = objectKeyList[index];
+ objectValue = object[objectKey];
+
+ if (state.replacer) {
+ objectValue = state.replacer.call(object, objectKey, objectValue);
+ }
+
+ if (!writeNode(state, level, objectKey, false, false)) {
+ continue; // Skip this pair because of invalid key;
+ }
+
+ if (state.dump.length > 1024) pairBuffer += '? ';
+
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
+
+ if (!writeNode(state, level, objectValue, false, false)) {
+ continue; // Skip this pair because of invalid value.
+ }
+
+ pairBuffer += state.dump;
+
+ // Both key and value are valid.
+ _result += pairBuffer;
+ }
+
+ state.tag = _tag;
+ state.dump = '{' + _result + '}';
+}
+
+function writeBlockMapping(state, level, object, compact) {
+ var _result = '',
+ _tag = state.tag,
+ objectKeyList = Object.keys(object),
+ index,
+ length,
+ objectKey,
+ objectValue,
+ explicitPair,
+ pairBuffer;
+
+ // Allow sorting keys so that the output file is deterministic
+ if (state.sortKeys === true) {
+ // Default sorting
+ objectKeyList.sort();
+ } else if (typeof state.sortKeys === 'function') {
+ // Custom sort function
+ objectKeyList.sort(state.sortKeys);
+ } else if (state.sortKeys) {
+ // Something is wrong
+ throw new exception('sortKeys must be a boolean or a function');
+ }
+
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
+ pairBuffer = '';
+
+ if (!compact || _result !== '') {
+ pairBuffer += generateNextLine(state, level);
+ }
+
+ objectKey = objectKeyList[index];
+ objectValue = object[objectKey];
+
+ if (state.replacer) {
+ objectValue = state.replacer.call(object, objectKey, objectValue);
+ }
+
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
+ continue; // Skip this pair because of invalid key.
+ }
+
+ explicitPair = (state.tag !== null && state.tag !== '?') ||
+ (state.dump && state.dump.length > 1024);
+
+ if (explicitPair) {
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
+ pairBuffer += '?';
+ } else {
+ pairBuffer += '? ';
+ }
+ }
+
+ pairBuffer += state.dump;
+
+ if (explicitPair) {
+ pairBuffer += generateNextLine(state, level);
+ }
+
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
+ continue; // Skip this pair because of invalid value.
+ }
+
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
+ pairBuffer += ':';
+ } else {
+ pairBuffer += ': ';
+ }
+
+ pairBuffer += state.dump;
+
+ // Both key and value are valid.
+ _result += pairBuffer;
+ }
+
+ state.tag = _tag;
+ state.dump = _result || '{}'; // Empty mapping if no valid pairs.
+}
+
+function detectType(state, object, explicit) {
+ var _result, typeList, index, length, type, style;
+
+ typeList = explicit ? state.explicitTypes : state.implicitTypes;
+
+ for (index = 0, length = typeList.length; index < length; index += 1) {
+ type = typeList[index];
+
+ if ((type.instanceOf || type.predicate) &&
+ (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
+ (!type.predicate || type.predicate(object))) {
+
+ if (explicit) {
+ if (type.multi && type.representName) {
+ state.tag = type.representName(object);
+ } else {
+ state.tag = type.tag;
+ }
+ } else {
+ state.tag = '?';
+ }
+
+ if (type.represent) {
+ style = state.styleMap[type.tag] || type.defaultStyle;
+
+ if (_toString.call(type.represent) === '[object Function]') {
+ _result = type.represent(object, style);
+ } else if (_hasOwnProperty.call(type.represent, style)) {
+ _result = type.represent[style](object, style);
+ } else {
+ throw new exception('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
+ }
+
+ state.dump = _result;
+ }
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+// Serializes `object` and writes it to global `result`.
+// Returns true on success, or false on invalid object.
+//
+function writeNode(state, level, object, block, compact, iskey, isblockseq) {
+ state.tag = null;
+ state.dump = object;
+
+ if (!detectType(state, object, false)) {
+ detectType(state, object, true);
+ }
+
+ var type = _toString.call(state.dump);
+ var inblock = block;
+ var tagStr;
+
+ if (block) {
+ block = (state.flowLevel < 0 || state.flowLevel > level);
+ }
+
+ var objectOrArray = type === '[object Object]' || type === '[object Array]',
+ duplicateIndex,
+ duplicate;
+
+ if (objectOrArray) {
+ duplicateIndex = state.duplicates.indexOf(object);
+ duplicate = duplicateIndex !== -1;
+ }
+
+ if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
+ compact = false;
+ }
+
+ if (duplicate && state.usedDuplicates[duplicateIndex]) {
+ state.dump = '*ref_' + duplicateIndex;
+ } else {
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
+ state.usedDuplicates[duplicateIndex] = true;
+ }
+ if (type === '[object Object]') {
+ if (block && (Object.keys(state.dump).length !== 0)) {
+ writeBlockMapping(state, level, state.dump, compact);
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + state.dump;
+ }
+ } else {
+ writeFlowMapping(state, level, state.dump);
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
+ }
+ }
+ } else if (type === '[object Array]') {
+ if (block && (state.dump.length !== 0)) {
+ if (state.noArrayIndent && !isblockseq && level > 0) {
+ writeBlockSequence(state, level - 1, state.dump, compact);
+ } else {
+ writeBlockSequence(state, level, state.dump, compact);
+ }
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + state.dump;
+ }
+ } else {
+ writeFlowSequence(state, level, state.dump);
+ if (duplicate) {
+ state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
+ }
+ }
+ } else if (type === '[object String]') {
+ if (state.tag !== '?') {
+ writeScalar(state, state.dump, level, iskey, inblock);
+ }
+ } else if (type === '[object Undefined]') {
+ return false;
+ } else {
+ if (state.skipInvalid) return false;
+ throw new exception('unacceptable kind of an object to dump ' + type);
+ }
+
+ if (state.tag !== null && state.tag !== '?') {
+ // Need to encode all characters except those allowed by the spec:
+ //
+ // [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */
+ // [36] ns-hex-digit ::= ns-dec-digit
+ // | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */
+ // [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */
+ // [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-”
+ // [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#”
+ // | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,”
+ // | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]”
+ //
+ // Also need to encode '!' because it has special meaning (end of tag prefix).
+ //
+ tagStr = encodeURI(
+ state.tag[0] === '!' ? state.tag.slice(1) : state.tag
+ ).replace(/!/g, '%21');
+
+ if (state.tag[0] === '!') {
+ tagStr = '!' + tagStr;
+ } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') {
+ tagStr = '!!' + tagStr.slice(18);
+ } else {
+ tagStr = '!<' + tagStr + '>';
+ }
+
+ state.dump = tagStr + ' ' + state.dump;
+ }
+ }
+
+ return true;
+}
+
+function getDuplicateReferences(object, state) {
+ var objects = [],
+ duplicatesIndexes = [],
+ index,
+ length;
+
+ inspectNode(object, objects, duplicatesIndexes);
+
+ for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
+ }
+ state.usedDuplicates = new Array(length);
+}
+
+function inspectNode(object, objects, duplicatesIndexes) {
+ var objectKeyList,
+ index,
+ length;
+
+ if (object !== null && typeof object === 'object') {
+ index = objects.indexOf(object);
+ if (index !== -1) {
+ if (duplicatesIndexes.indexOf(index) === -1) {
+ duplicatesIndexes.push(index);
+ }
+ } else {
+ objects.push(object);
+
+ if (Array.isArray(object)) {
+ for (index = 0, length = object.length; index < length; index += 1) {
+ inspectNode(object[index], objects, duplicatesIndexes);
+ }
+ } else {
+ objectKeyList = Object.keys(object);
+
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
+ inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
+ }
+ }
+ }
+ }
+}
+
+function dump$1(input, options) {
+ options = options || {};
+
+ var state = new State(options);
+
+ if (!state.noRefs) getDuplicateReferences(input, state);
+
+ var value = input;
+
+ if (state.replacer) {
+ value = state.replacer.call({ '': value }, '', value);
+ }
+
+ if (writeNode(state, 0, value, true, true)) return state.dump + '\n';
+
+ return '';
+}
+
+var dump_1 = dump$1;
+
+var dumper = {
+ dump: dump_1
+};
+
+function renamed(from, to) {
+ return function () {
+ throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' +
+ 'Use yaml.' + to + ' instead, which is now safe by default.');
+ };
+}
+
+
+var Type = type;
+var Schema = schema;
+var FAILSAFE_SCHEMA = failsafe;
+var JSON_SCHEMA = json;
+var CORE_SCHEMA = core;
+var DEFAULT_SCHEMA = _default;
+var load = loader.load;
+var loadAll = loader.loadAll;
+var dump = dumper.dump;
+var YAMLException = exception;
+
+// Re-export all types in case user wants to create custom schema
+var types = {
+ binary: binary,
+ float: float_1,
+ map: map,
+ null: _null,
+ pairs: pairs,
+ set: set,
+ timestamp: timestamp,
+ bool: bool,
+ int: int_1,
+ merge: merge,
+ omap: omap,
+ seq: seq,
+ str: str
+};
+
+// Removed functions from JS-YAML 3.0.x
+var safeLoad = renamed('safeLoad', 'load');
+var safeLoadAll = renamed('safeLoadAll', 'loadAll');
+var safeDump = renamed('safeDump', 'dump');
+
+var jsYaml = {
+ Type: Type,
+ Schema: Schema,
+ FAILSAFE_SCHEMA: FAILSAFE_SCHEMA,
+ JSON_SCHEMA: JSON_SCHEMA,
+ CORE_SCHEMA: CORE_SCHEMA,
+ DEFAULT_SCHEMA: DEFAULT_SCHEMA,
+ load: load,
+ loadAll: loadAll,
+ dump: dump,
+ YAMLException: YAMLException,
+ types: types,
+ safeLoad: safeLoad,
+ safeLoadAll: safeLoadAll,
+ safeDump: safeDump
+};
+
+function onRenderLine(cm, line, el) {
+ var _this = this;
+ var parentElement = el.parentElement;
+ if (!parentElement)
+ el.addEventListener("DOMNodeInserted", function (event) { return procLine(cm, line, el, event.relatedNode, _this); }, { once: true });
+}
+function procLine(cm, line, el, parentEl, plugin) {
+ var _a, _b, _c, _d, _e, _f;
+ // for some reason, codemirror or hmd skips putting elements in a wrapping div
+ // unsure what causes this to happen but try and account for it by falling back
+ // if the parent is the root codemirror-code element
+ if (parentEl.className === "CodeMirror-code")
+ parentEl = el;
+ // clear existing data keys
+ clearDataKeys(parentEl.dataset);
+ // split child classes
+ var childClasses = (_b = (_a = line.styleClasses) === null || _a === void 0 ? void 0 : _a.textClass) === null || _b === void 0 ? void 0 : _b.split(" ");
+ // line.styles is an array of multi-class strings
+ // we combine all of the styles into a single string and then dedupe it
+ var childElementClasses = (_c = line.styles) === null || _c === void 0 ? void 0 : _c.filter(function (style) { return typeof style === "string"; }).join(" ").split(" ").filter(function (v, i, a) { return a.indexOf(v) === i; });
+ // raise yaml frontmatter attributes up as CSS vars and attrs
+ if (childElementClasses.contains("hmd-frontmatter") && line.text !== "---") {
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ //@ts-ignore
+ var display = cm.display;
+ var viewEl_1 = (_e = (_d = display === null || display === void 0 ? void 0 : display.wrapper) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.parentElement;
+ (_f = display === null || display === void 0 ? void 0 : display.scrollbars) === null || _f === void 0 ? void 0 : _f.vert;
+ var approvedAttrs_1 = plugin.settings.allowedYamlKeys.split(",").map(function (item) { return item.trim(); });
+ if (plugin.settings.renderBanner) {
+ approvedAttrs_1.push("banner_x", "banner_y", "banner", "banner-height", "banner-style");
+ }
+ // try and parse the frontmatter into yaml key/value pairs
+ var kv = void 0;
+ try {
+ var parsedYaml = jsYaml.load(line.text);
+ kv = Object.entries(parsedYaml).map(function (_a) {
+ var key = _a[0], value = _a[1];
+ return ({ key: key, value: value });
+ });
+ }
+ catch (_g) {
+ kv = [];
+ }
+ kv.forEach(function (item) {
+ // if the key is not registered, skip
+ if (!approvedAttrs_1.includes(item.key))
+ return;
+ // if the value looks like a file, try and resolve the full path
+ if (/\.(jpg|jpeg|md|png|gif)$/.test(item.value)) {
+ var file = void 0, filePath = void 0;
+ try {
+ (file = plugin.app.metadataCache.getFirstLinkpathDest(decodeURIComponent(item.value), "")) &&
+ (filePath = plugin.app.vault.getResourcePath(file));
+ }
+ catch (_a) { }
+ if (file && filePath) {
+ viewEl_1.style.setProperty("--" + item.key, "url(" + filePath + ")");
+ }
+ else {
+ viewEl_1.style.setProperty("--" + item.key, "" + item.value);
+ }
+ }
+ else {
+ // special handling for the banner plugin to turn decimals into percents
+ if (/^banner_[xy]$/.test(item.key)) {
+ item.value = item.value * 100 + "%";
+ }
+ viewEl_1.style.setProperty("--" + item.key, "" + item.value);
+ }
+ try {
+ viewEl_1.setAttribute("data-" + item.key, item.value);
+ }
+ catch (_b) { }
+ });
+ }
+ // look for anything labeled as a header
+ // extract its full text value (minus the initial hash)
+ if (childClasses === null || childClasses === void 0 ? void 0 : childClasses.includes("HyperMD-header")) {
+ var _match = line.text.match(/^[#]+[\s]+(.+)/);
+ parentEl.dataset["heading"] = (_match === null || _match === void 0 ? void 0 : _match.length) > 0 ? line.text.match(/^[#]+[\s]+(.+)/)[1].trim() : "";
+ }
+ // check line for any hashtags and add them to a new data key
+ var tokens = cm.getLineTokens(line.lineNo());
+ var parsedTokens = parseLineTokens(tokens);
+ if (parsedTokens)
+ parentEl.dataset["hashtags"] = parseLineTokens(tokens);
+ // infer html tag type based on style classes
+ var htmlTag = childElementClasses ? lookupTag(childElementClasses) : null;
+ if (htmlTag) {
+ parentEl.dataset["tagName"] = htmlTag;
+ }
+}
+function clearDataKeys(keys) {
+ if (keys) {
+ Object.keys(keys).forEach(function (dataKey) {
+ delete keys[dataKey];
+ });
+ }
+}
+function parseLineTokens(tokens) {
+ tokens = tokens.filter(function (token) { var _a; return (_a = token.type) === null || _a === void 0 ? void 0 : _a.includes("hashtag-end"); });
+ if (tokens.length) {
+ var hashtags = tokens.map(function (token) { return token.string; }).join(" ");
+ if (hashtags.length) {
+ return tokens.map(function (token) { return token.string; }).join(" ");
+ }
+ }
+}
+function lookupTag(classes) {
+ var htmlTag;
+ for (var _i = 0, classes_1 = classes; _i < classes_1.length; _i++) {
+ var className = classes_1[_i];
+ switch (className) {
+ case "formatting-list-ol":
+ htmlTag = "ol";
+ break;
+ case "formatting-list-ul":
+ htmlTag = "ul";
+ break;
+ case "header-1":
+ htmlTag = "h1";
+ break;
+ case "header-2":
+ htmlTag = "h2";
+ break;
+ case "header-3":
+ htmlTag = "h3";
+ break;
+ case "header-4":
+ htmlTag = "h4";
+ break;
+ case "header-5":
+ htmlTag = "h5";
+ break;
+ case "header-6":
+ htmlTag = "h6";
+ break;
+ case "hmd-codeblock":
+ htmlTag = "code";
+ break;
+ case "hr":
+ htmlTag = "hr";
+ break;
+ case "hmd-frontmatter":
+ htmlTag = "frontmatter";
+ break;
+ }
+ }
+ return htmlTag;
+}
+
+function around(obj, factories) {
+ const removers = Object.keys(factories).map(key => around1(obj, key, factories[key]));
+ return removers.length === 1 ? removers[0] : function () { removers.forEach(r => r()); };
+}
+function around1(obj, method, createWrapper) {
+ const original = obj[method], hadOwn = obj.hasOwnProperty(method);
+ let current = createWrapper(original);
+ // Let our wrapper inherit static props from the wrapping method,
+ // and the wrapping method, props from the original method
+ if (original)
+ Object.setPrototypeOf(current, original);
+ Object.setPrototypeOf(wrapper, current);
+ obj[method] = wrapper;
+ // Return a callback to allow safe removal
+ return remove;
+ function wrapper(...args) {
+ // If we have been deactivated and are no longer wrapped, remove ourselves
+ if (current === original && obj[method] === wrapper)
+ remove();
+ return current.apply(this, args);
+ }
+ function remove() {
+ // If no other patches, just do a direct removal
+ if (obj[method] === wrapper) {
+ if (hadOwn)
+ obj[method] = original;
+ else
+ delete obj[method];
+ }
+ if (current === original)
+ return;
+ // Else pass future calls through, and remove wrapper from the prototype chain
+ current = original;
+ Object.setPrototypeOf(wrapper, original || Function);
+ }
+}
+
+var ObsidianCodeMirrorOptionsPlugin = /** @class */ (function (_super) {
+ __extends(ObsidianCodeMirrorOptionsPlugin, _super);
+ function ObsidianCodeMirrorOptionsPlugin() {
+ var _this_1 = _super !== null && _super.apply(this, arguments) || this;
+ _this_1.onImageContextMenu = function (event, target) {
+ // the "editor-menu" event does not include the MouseEvent or the target HTMLElement
+ // so instead, we create this stanadard context menu event handler and hook it into
+ // the "editor-menu" event temporarily
+ var boundFunc = _this_1.onEditorMenu.bind(_this_1, target);
+ _this_1.app.workspace.on("editor-menu", boundFunc);
+ setTimeout(function () {
+ _this_1.app.workspace.off("editor-menu", boundFunc);
+ }, 100);
+ };
+ _this_1.onEditorMenu = function (target, menu) {
+ var file;
+ if (target.dataset.path) {
+ file = _this_1.app.vault.getAbstractFileByPath(target.dataset.path);
+ if (!(file instanceof obsidian.TFile))
+ return;
+ }
+ else if (/^http/i.test(target.getAttribute("src"))) {
+ file = target.getAttribute("src");
+ }
+ if (file)
+ _this_1.addContextMenuItem(menu, file);
+ };
+ _this_1.addContextMenuItem = function (menu, imageFile) {
+ menu.addItem(function (menuItem) {
+ menuItem.setTitle("Copy Image to Clipboard");
+ menuItem.setIcon("image-file");
+ menuItem.onClick(function () { return __awaiter(_this_1, void 0, void 0, function () {
+ var blob, buffer, arr, item;
+ return __generator(this, function (_a) {
+ switch (_a.label) {
+ case 0:
+ if (!(imageFile instanceof obsidian.TFile)) return [3 /*break*/, 2];
+ return [4 /*yield*/, this.app.vault.adapter.readBinary(imageFile.path)];
+ case 1:
+ buffer = _a.sent();
+ arr = new Uint8Array(buffer);
+ blob = new Blob([arr], { type: "image/png" });
+ return [3 /*break*/, 5];
+ case 2: return [4 /*yield*/, fetch(imageFile)];
+ case 3: return [4 /*yield*/, (_a.sent()).blob()];
+ case 4:
+ blob = _a.sent();
+ _a.label = 5;
+ case 5:
+ item = new ClipboardItem({ "image/png": blob });
+ //@ts-ignore
+ window.navigator.clipboard.write([item]);
+ return [2 /*return*/];
+ }
+ });
+ }); });
+ });
+ };
+ _this_1.mdProcessor = function (el) { return __awaiter(_this_1, void 0, void 0, function () {
+ var _this_1 = this;
+ return __generator(this, function (_a) {
+ setTimeout(function () {
+ _this_1.injectCM(el);
+ }, 100);
+ return [2 /*return*/];
+ });
+ }); };
+ _this_1.onRenderLineBound = onRenderLine.bind(_this_1);
+ _this_1.onImageClick = function (args) {
+ args.breakMark(args.editor, args.marker);
+ };
+ _this_1.updateCodeMirrorOption = obsidian.debounce(function (optionKey, optionValue, refresh) {
+ if (refresh === void 0) { refresh = false; }
+ _this_1.app.workspace.iterateCodeMirrors(function (cm) {
+ if (cm && cm.getOption(optionKey) != optionValue) {
+ cm.setOption(optionKey, optionValue);
+ if (refresh)
+ cm.refresh();
+ }
+ });
+ }, 400, true);
+ _this_1.updateCodeMirrorHandlers = obsidian.debounce(function (eventType, callback, enable, refresh) {
+ if (enable === void 0) { enable = true; }
+ if (refresh === void 0) { refresh = false; }
+ _this_1.app.workspace.iterateCodeMirrors(function (cm) {
+ if (enable)
+ cm.on(eventType, callback);
+ else
+ cm.off(eventType, callback);
+ if (refresh)
+ cm.refresh();
+ });
+ }, 0, true);
+ return _this_1;
+ }
+ ObsidianCodeMirrorOptionsPlugin.prototype.onload = function () {
+ return __awaiter(this, void 0, void 0, function () {
+ var _this_1 = this;
+ return __generator(this, function (_a) {
+ switch (_a.label) {
+ case 0:
+ // patch the default Obsidian methods, ASAP
+ this.applyMonkeyPatches();
+ // load settings
+ return [4 /*yield*/, this.loadSettings()];
+ case 1:
+ // load settings
+ _a.sent();
+ // add the settings tab
+ this.addSettingTab(new ObsidianCodeMirrorOptionsSettingsTab(this.app, this));
+ this.app.workspace.onLayoutReady(function () {
+ _this_1.registerCodeMirrorSettings();
+ _this_1.applyBodyClasses();
+ _this_1.registerCommands();
+ setTimeout(function () {
+ // workaround to ensure our plugin registers properly with Style Settings
+ _this_1.app.workspace.trigger("css-change");
+ }, 1000);
+ });
+ document.on("contextmenu", "img.hmd-image", this.onImageContextMenu, false);
+ document.on("contextmenu", ".rendered-widget img:not(.hmd-image)", this.onImageContextMenu, false);
+ return [2 /*return*/];
+ }
+ });
+ });
+ };
+ ObsidianCodeMirrorOptionsPlugin.prototype.loadSettings = function () {
+ return __awaiter(this, void 0, void 0, function () {
+ var _a, _b, _c, _d;
+ return __generator(this, function (_e) {
+ switch (_e.label) {
+ case 0:
+ _a = this;
+ _c = (_b = Object).assign;
+ _d = [{}, DEFAULT_SETTINGS];
+ return [4 /*yield*/, this.loadData()];
+ case 1:
+ _a.settings = _c.apply(_b, _d.concat([_e.sent()]));
+ return [2 /*return*/];
+ }
+ });
+ });
+ };
+ ObsidianCodeMirrorOptionsPlugin.prototype.applyMonkeyPatches = function () {
+ // patching onLoadFile to clear CM specific state in order to avoid fold related memory leaks
+ // we also add the current file name to the CM state so that CM native actions have a reference
+ var patchOnLoadFile = around(obsidian.MarkdownView.prototype, {
+ onLoadFile: function (old) {
+ // old is the original onLoadFile function
+ return function (file) {
+ var _a, _b, _c, _d;
+ // TODO: emit a trigger and create event handlers instead of performing direct actions here
+ try {
+ var previewEl = document.querySelector("#math-preview");
+ if (previewEl && !previewEl.hasClass("float-win-hidden")) {
+ previewEl.addClass("float-win-hidden");
+ }
+ var cm = (_a = this.sourceMode) === null || _a === void 0 ? void 0 : _a.editor.cm;
+ if (cm) {
+ var viewEl_1 = (_d = (_c = (_b = cm.display) === null || _b === void 0 ? void 0 : _b.wrapper) === null || _c === void 0 ? void 0 : _c.parentElement) === null || _d === void 0 ? void 0 : _d.parentElement;
+ if (viewEl_1) {
+ Object.keys(viewEl_1.dataset).forEach(function (el) { return viewEl_1.removeAttribute("data-" + el); });
+ viewEl_1.style = null;
+ }
+ cm.state.fileName = file.path;
+ cm.hmd.Fold.folded = {}; // these objects can hold references to detached elements
+ cm.hmd.FoldCode.folded = {}; // these objects can hold references to detached elements
+ }
+ }
+ catch (_e) { }
+ return old.call(this, file); // call the orignal function and bind the current scope to it
+ };
+ },
+ // @ts-ignore
+ onClose: function (old) {
+ return function () {
+ var _a, _b, _c, _d;
+ // TODO: emit a trigger and create event handlers instead of performing direct actions here
+ try {
+ var cm = (_a = this.sourceMode) === null || _a === void 0 ? void 0 : _a.editor.cm;
+ if (cm) {
+ var viewEl_2 = (_d = (_c = (_b = cm.display) === null || _b === void 0 ? void 0 : _b.wrapper) === null || _c === void 0 ? void 0 : _c.parentElement) === null || _d === void 0 ? void 0 : _d.parentElement;
+ if (viewEl_2) {
+ Object.keys(viewEl_2.dataset).forEach(function (el) { return viewEl_2.removeAttribute("data-" + el); });
+ viewEl_2.style = null;
+ }
+ cm.hmd.Fold.folded = {}; // these objects can hold references to detached elements
+ cm.hmd.FoldCode.folded = {}; // these objects can hold references to detached elements
+ }
+ var previewEl = document.querySelector("#math-preview");
+ if (previewEl && !previewEl.hasClass("float-win-hidden")) {
+ previewEl.addClass("float-win-hidden");
+ }
+ }
+ catch (_e) { }
+ return old.call(this);
+ };
+ },
+ });
+ this.register(patchOnLoadFile);
+ // patch the preview mode click handlers so that we get preview context menus on edit mode rendered widgets
+ var patchSourceView = around(obsidian.MarkdownSourceView.prototype, {
+ attachDomEvents: function (old) {
+ return function () {
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
+ var _this = this, editorEl = this.editorEl;
+ editorEl.addEventListener("mousedown", this.onCodeMirrorMousedown.bind(this)),
+ editorEl.addEventListener("contextmenu", function (event) {
+ if (event &&
+ event.path.length &&
+ event.path.filter(function (el) { return el.hasClass && el.hasClass("rendered-widget"); }).length &&
+ event.path[0].tagName !== "IMG") {
+ return;
+ }
+ return _this.clipboardManager.onContextMenu(event);
+ }, { capture: true }),
+ editorEl.on("mouseover", ".cm-hmd-internal-link", this.onInternalLinkMouseover.bind(this));
+ };
+ },
+ });
+ this.register(patchSourceView);
+ var patchRenderer = around(obsidian.MarkdownPreviewRenderer.prototype, {
+ onInternalLinkContextMenu: function (old) {
+ return function (event, el) {
+ var href = this.getInternalLinkHref(el);
+ href && this.owner.onInternalLinkRightClick(event, el, href);
+ };
+ },
+ onResize: function (old) {
+ return function () {
+ var _this_1 = this;
+ setTimeout(function () {
+ var _a;
+ var editor = (_a = _this_1.owner.app.workspace.activeLeaf) === null || _a === void 0 ? void 0 : _a.view.sourceMode.editorEl;
+ if (editor && !_this_1.widgetHandlersRegistered && _this_1.owner.type === "preview") {
+ _this_1.widgetHandlersRegistered = true;
+ editor.on("click", ".rendered-widget a.internal-link", _this_1.onInternalLinkClick.bind(_this_1));
+ editor.on("auxclick", ".rendered-widget a.internal-link", _this_1.onInternalLinkClick.bind(_this_1));
+ editor.on("contextmenu", ".rendered-widget a.internal-link", _this_1.onInternalLinkContextMenu.bind(_this_1));
+ // editor.on("mouseover", ".rendered-widget a.internal-link", this.onInternalLinkMouseover.bind(this));
+ editor.on("click", ".rendered-widget a.external-link", _this_1.onExternalLinkClick.bind(_this_1));
+ editor.on("click", ".rendered-widget a.footnote-link", _this_1.onFootnoteLinkClick.bind(_this_1));
+ editor.on("click", ".rendered-widget .task-list-item-checkbox", _this_1.onCheckboxClick.bind(_this_1));
+ editor.on("click", ".rendered-widget a.tag", _this_1.onTagClick.bind(_this_1));
+ editor.on("click", ".rendered-widget a.internal-query", _this_1.onInternalQueryClick.bind(_this_1));
+ editor.on("click", ".rendered-widget .heading-collapse-indicator", _this_1.onHeadingCollapseClick.bind(_this_1));
+ editor.on("click", ".rendered-widget li > .list-collapse-indicator", _this_1.onListCollapseClick.bind(_this_1));
+ // editor.on("click", ".rendered-widget img", this.onImageClick.bind(this));
+ }
+ }, 100);
+ return old.call(this);
+ };
+ },
+ belongsToMe: function (old) {
+ return function (el) {
+ // save the original element so we can pass it to the original method
+ var _el = el;
+ // check to see if the element is a sibling of a rendered widget
+ for (; el;) {
+ if (el.hasClass("rendered-widget") && el.tagName !== "IMG") {
+ return true;
+ }
+ var parentEl = el.parentElement;
+ if (!parentEl)
+ return old.call(this, _el);
+ el = parentEl;
+ }
+ };
+ },
+ });
+ this.register(patchRenderer);
+ };
+ ObsidianCodeMirrorOptionsPlugin.prototype.registerCommands = function () {
+ var _this_1 = this;
+ this.addCommand({
+ id: "toggle-openmd",
+ name: "Toggle OpenMD Mode",
+ callback: function () {
+ _this_1.settings.enableOpenMD = !_this_1.settings.enableOpenMD;
+ _this_1.saveData(_this_1.settings);
+ _this_1.updateCodeMirrorOption("mode", _this_1.settings.enableOpenMD ? "openmd" : "hypermd");
+ },
+ });
+ this.addCommand({
+ id: "toggle-hide-tokens",
+ name: "Toggle Hide Markdown Tokens",
+ callback: function () {
+ _this_1.settings.editModeHideTokens = !_this_1.settings.editModeHideTokens;
+ _this_1.saveData(_this_1.settings);
+ _this_1.updateCodeMirrorOption("hmdHideToken", _this_1.settings.editModeHideTokens ? _this_1.settings.tokenList : false);
+ _this_1.applyBodyClasses();
+ },
+ });
+ this.addCommand({
+ id: "toggle-click-handler",
+ name: "Toggle Edit Mode Click Handler",
+ callback: function () {
+ _this_1.settings.editModeClickHandler = !_this_1.settings.editModeClickHandler;
+ _this_1.saveData(_this_1.settings);
+ _this_1.updateCodeMirrorOption("hmdClick", _this_1.settings.editModeClickHandler);
+ },
+ });
+ this.addCommand({
+ id: "toggle-collapse-links",
+ name: "Toggle Collapse External Links",
+ callback: function () {
+ _this_1.settings.foldLinks = !_this_1.settings.foldLinks;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses();
+ _this_1.updateCodeMirrorOption("hmdFold", {
+ image: _this_1.settings.foldImages,
+ link: _this_1.settings.foldLinks,
+ html: _this_1.settings.renderHTML,
+ code: _this_1.settings.renderCode,
+ math: _this_1.settings.renderMath,
+ });
+ },
+ });
+ this.addCommand({
+ id: "toggle-render-images-inline",
+ name: "Toggle Render Images Inline",
+ callback: function () {
+ _this_1.settings.foldImages = !_this_1.settings.foldImages;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses();
+ _this_1.updateCodeMirrorOption("hmdFold", {
+ image: _this_1.settings.foldImages,
+ link: _this_1.settings.foldLinks,
+ html: _this_1.settings.renderHTML,
+ code: _this_1.settings.renderCode,
+ math: _this_1.settings.renderMath,
+ });
+ },
+ });
+ this.addCommand({
+ id: "toggle-render-html",
+ name: "Toggle Render HTML",
+ callback: function () {
+ _this_1.settings.renderHTML = !_this_1.settings.renderHTML;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses();
+ _this_1.updateCodeMirrorOption("hmdFold", {
+ image: _this_1.settings.foldImages,
+ link: _this_1.settings.foldLinks,
+ html: _this_1.settings.renderHTML,
+ code: _this_1.settings.renderCode,
+ math: _this_1.settings.renderMath,
+ });
+ },
+ });
+ this.addCommand({
+ id: "toggle-render-math",
+ name: "Toggle Render Math",
+ callback: function () {
+ _this_1.settings.renderMath = !_this_1.settings.renderMath;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses();
+ _this_1.updateCodeMirrorOption("hmdFold", {
+ image: _this_1.settings.foldImages,
+ link: _this_1.settings.foldLinks,
+ html: _this_1.settings.renderHTML,
+ code: _this_1.settings.renderCode,
+ math: _this_1.settings.renderMath,
+ });
+ },
+ });
+ this.addCommand({
+ id: "toggle-render-math-preview",
+ name: "Toggle Render Math Preview",
+ callback: function () {
+ _this_1.settings.renderMathPreview = !_this_1.settings.renderMathPreview;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses();
+ if (_this_1.settings.renderMathPreview) {
+ _this_1.app.workspace.iterateCodeMirrors(function (cm) {
+ init_math_preview(cm);
+ });
+ }
+ else {
+ var previewEl = document.querySelector("#math-preview");
+ if (previewEl) {
+ document.querySelector("#math-preview").detach();
+ }
+ _this_1.app.workspace.iterateCodeMirrors(function (cm) {
+ unload_math_preview(cm);
+ });
+ }
+ },
+ });
+ this.addCommand({
+ id: "toggle-render-code",
+ name: "Toggle Render Code",
+ callback: function () {
+ _this_1.settings.renderCode = !_this_1.settings.renderCode;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses();
+ _this_1.updateCodeMirrorOption("hmdFold", {
+ image: _this_1.settings.foldImages,
+ link: _this_1.settings.foldLinks,
+ html: _this_1.settings.renderHTML,
+ code: _this_1.settings.renderCode,
+ math: _this_1.settings.renderMath,
+ });
+ },
+ });
+ this.addCommand({
+ id: "toggle-render-dataview",
+ name: "Toggle Render Dataview",
+ callback: function () {
+ _this_1.settings.renderDataview = !_this_1.settings.renderDataview;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses();
+ _this_1.updateCodeMirrorOption("hmdFoldCode", {
+ admonition: _this_1.settings.renderAdmonition,
+ chart: _this_1.settings.renderChart,
+ query: _this_1.settings.renderQuery,
+ dataview: _this_1.settings.renderDataview,
+ });
+ },
+ });
+ this.addCommand({
+ id: "toggle-render-chart",
+ name: "Toggle Render Charts",
+ callback: function () {
+ _this_1.settings.renderChart = !_this_1.settings.renderChart;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses();
+ _this_1.updateCodeMirrorOption("hmdFoldCode", {
+ admonition: _this_1.settings.renderAdmonition,
+ chart: _this_1.settings.renderChart,
+ query: _this_1.settings.renderQuery,
+ dataview: _this_1.settings.renderDataview,
+ });
+ },
+ });
+ this.addCommand({
+ id: "toggle-render-admonition",
+ name: "Toggle Render Admonitions",
+ callback: function () {
+ _this_1.settings.renderAdmonition = !_this_1.settings.renderAdmonition;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses();
+ _this_1.updateCodeMirrorOption("hmdFoldCode", {
+ admonition: _this_1.settings.renderAdmonition,
+ chart: _this_1.settings.renderChart,
+ query: _this_1.settings.renderQuery,
+ dataview: _this_1.settings.renderDataview,
+ });
+ },
+ });
+ this.addCommand({
+ id: "toggle-render-query",
+ name: "Toggle Render Search Queries",
+ callback: function () {
+ _this_1.settings.renderQuery = !_this_1.settings.renderQuery;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses();
+ _this_1.updateCodeMirrorOption("hmdFoldCode", {
+ admonition: _this_1.settings.renderAdmonition,
+ chart: _this_1.settings.renderChart,
+ query: _this_1.settings.renderQuery,
+ dataview: _this_1.settings.renderDataview,
+ });
+ },
+ });
+ this.addCommand({
+ id: "toggle-container-attributes",
+ name: "Toggle Container Attributes",
+ callback: function () {
+ _this_1.settings.containerAttributes = !_this_1.settings.containerAttributes;
+ _this_1.saveData(_this_1.settings);
+ _this_1.updateCodeMirrorHandlers("renderLine", _this_1.onRenderLineBound, _this_1.settings.containerAttributes, true);
+ },
+ });
+ this.addCommand({
+ id: "toggle-dynamic-cursor-size",
+ name: "Toggle Dynamic Cursor Size",
+ callback: function () {
+ _this_1.settings.dynamicCursor = !_this_1.settings.dynamicCursor;
+ _this_1.saveData(_this_1.settings);
+ _this_1.updateCodeMirrorOption("singleCursorHeightPerLine", !_this_1.settings.dynamicCursor);
+ },
+ });
+ this.addCommand({
+ id: "toggle-style-active-selection",
+ name: "Toggle Style Active Selection",
+ callback: function () {
+ _this_1.settings.markSelection = !_this_1.settings.markSelection;
+ _this_1.saveData(_this_1.settings);
+ _this_1.updateCodeMirrorOption("styleSelectedText", _this_1.settings.markSelection);
+ _this_1.applyBodyClasses();
+ },
+ });
+ this.addCommand({
+ id: "toggle-retain-active-line",
+ name: "Toggle Retain Active Line on Selection",
+ callback: function () {
+ _this_1.settings.activeLineOnSelect = !_this_1.settings.activeLineOnSelect;
+ _this_1.saveData(_this_1.settings);
+ _this_1.updateCodeMirrorOption("styleActiveLine", _this_1.settings.activeLineOnSelect ? { nonEmpty: true } : true);
+ },
+ });
+ this.addCommand({
+ id: "toggle-edit-mode-syntax",
+ name: "Toggle Edit Mode Syntax Highlighting",
+ callback: function () {
+ _this_1.settings.syntaxHighlighting = !_this_1.settings.syntaxHighlighting;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses(true);
+ },
+ });
+ this.addCommand({
+ id: "toggle-preview-mode-syntax",
+ name: "Toggle Preview Mode Syntax Highlighting",
+ callback: function () {
+ _this_1.settings.enablePrismJSStyling = !_this_1.settings.enablePrismJSStyling;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses(true);
+ },
+ });
+ this.addCommand({
+ id: "toggle-codemirror-in-preview-mode",
+ name: "Toggle CodeMirror in Preview Mode",
+ callback: function () {
+ _this_1.settings.enableCMinPreview = !_this_1.settings.enableCMinPreview;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses(true);
+ },
+ });
+ this.addCommand({
+ id: "toggle-cm-line-numbers-in-preview-mode",
+ name: "Toggle CM Line Numbers in Preview Mode",
+ callback: function () {
+ _this_1.settings.showLineNums = !_this_1.settings.showLineNums;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses(true);
+ },
+ });
+ this.addCommand({
+ id: "toggle-cm-copy-button-in-preview-mode",
+ name: "Toggle Copy Button in Preview Mode",
+ callback: function () {
+ _this_1.settings.copyButton = !_this_1.settings.copyButton;
+ _this_1.saveData(_this_1.settings);
+ _this_1.applyBodyClasses(true);
+ },
+ });
+ this.addCommand({
+ id: "toggle-auto-align-table",
+ name: "Toggle Auto Align Tables",
+ callback: function () {
+ _this_1.settings.autoAlignTables = !_this_1.settings.autoAlignTables;
+ _this_1.saveData(_this_1.settings);
+ _this_1.updateCodeMirrorOption("hmdTableAlign", _this_1.settings.autoAlignTables);
+ },
+ });
+ };
+ ObsidianCodeMirrorOptionsPlugin.prototype.injectCM = function (el) {
+ var _a;
+ // only get code block elements with a language but not any that have already been colorized
+ var preElement = el.firstChild;
+ var codeElement = (_a = el.firstChild) === null || _a === void 0 ? void 0 : _a.firstChild;
+ if (!codeElement)
+ return;
+ if (codeElement.tagName !== "CODE")
+ return;
+ // TODO: Add an option to configure excluded languages
+ if (codeElement.hasClass("language-mermaid"))
+ return;
+ if (!codeElement.classList.value.includes("language-")) {
+ if (this.settings.copyButtonOnPRE) {
+ this.addCopyButton(preElement);
+ }
+ return;
+ }
+ if (preElement.classList.value.includes("cm-s-obsidian"))
+ return;
+ codeElement.classList.forEach(function (className) {
+ if (className.startsWith("language-")) {
+ // set data-lang to the code block language for easier colorize usage
+ var language = className.replace("language-", "");
+ switch (language) {
+ case "html":
+ language = "htmlmixed";
+ break;
+ case "js":
+ language = "javascript";
+ break;
+ case "json":
+ language = "javascript";
+ break;
+ }
+ codeElement.setAttribute("data-lang", language);
+ }
+ });
+ //@ts-ignore
+ CodeMirror.colorize([codeElement], null, this.settings.showLineNums);
+ preElement.querySelector(".copy-code-button").remove();
+ this.addCopyButton(preElement);
+ };
+ ObsidianCodeMirrorOptionsPlugin.prototype.addCopyButton = function (element) {
+ if (this.settings.copyButton) {
+ var codeBlock_1 = element;
+ var copyButton_1 = document.createElement("button");
+ copyButton_1.className = "copy";
+ copyButton_1.type = "button";
+ // copyButton.ariaLabel = 'Copy code to clipboard';
+ copyButton_1.innerText = "Copy";
+ codeBlock_1.append(copyButton_1);
+ copyButton_1.addEventListener("click", function () {
+ // exclude line numbers when copying code to clipboard
+ var code = codeBlock_1.querySelector("code");
+ var clone = code.cloneNode(true);
+ clone.findAll("span.cm-linenumber").forEach(function (e) { return e.remove(); });
+ var codeText = clone.textContent.trim();
+ window.navigator.clipboard.writeText(codeText);
+ copyButton_1.innerText = "Copied";
+ setTimeout(function () {
+ copyButton_1.innerText = "Copy";
+ }, 4000);
+ });
+ }
+ };
+ ObsidianCodeMirrorOptionsPlugin.prototype.registerCodeMirrorSettings = function () {
+ var _this_1 = this;
+ this.registerCodeMirror(function (cm) {
+ cm.setOption("styleSelectedText", _this_1.settings.markSelection);
+ cm.setOption("singleCursorHeightPerLine", !_this_1.settings.dynamicCursor);
+ cm.setOption("styleActiveLine", _this_1.settings.activeLineOnSelect ? { nonEmpty: true } : true);
+ if (_this_1.settings.enableOpenMD)
+ cm.setOption("mode", "openmd");
+ cm.setOption("hmdHideToken", _this_1.settings.editModeHideTokens ? _this_1.settings.tokenList : false);
+ cm.setOption("hmdClick", _this_1.settings.editModeClickHandler);
+ cm.setOption("hmdTableAlign", _this_1.settings.autoAlignTables);
+ cm.setOption("cursorBlinkRate", _this_1.settings.cursorBlinkRate);
+ cm.setOption("hmdFold", {
+ image: _this_1.settings.foldImages,
+ link: _this_1.settings.foldLinks,
+ html: _this_1.settings.renderHTML,
+ code: _this_1.settings.renderCode,
+ math: _this_1.settings.renderMath,
+ });
+ cm.setOption("hmdFoldCode", {
+ admonition: _this_1.settings.renderAdmonition,
+ chart: _this_1.settings.renderChart,
+ query: _this_1.settings.renderQuery,
+ dataview: _this_1.settings.renderDataview,
+ });
+ if (_this_1.settings.renderMathPreview)
+ init_math_preview(cm);
+ if (_this_1.settings.containerAttributes)
+ _this_1.updateCodeMirrorHandlers("renderLine", _this_1.onRenderLineBound, true, true);
+ });
+ };
+ ObsidianCodeMirrorOptionsPlugin.prototype.applyBodyClasses = function (refresh) {
+ if (refresh === void 0) { refresh = false; }
+ this.settings.editModeHideTokens
+ ? !document.body.hasClass("hide-tokens")
+ ? document.body.addClass("hide-tokens")
+ : null
+ : document.body.removeClass("hide-tokens");
+ this.settings.styleCheckBox
+ ? !document.body.hasClass("style-check-box")
+ ? document.body.addClass("style-check-box")
+ : null
+ : document.body.removeClass("style-check-box");
+ this.settings.markSelection
+ ? !document.body.hasClass("style-active-selection")
+ ? document.body.addClass("style-active-selection")
+ : null
+ : document.body.removeClass("style-active-selection");
+ this.settings.enablePrismJSStyling
+ ? !document.body.hasClass("fallback-highlighting")
+ ? document.body.addClass("fallback-highlighting")
+ : null
+ : document.body.removeClass("fallback-highlighting");
+ this.settings.showLineNums
+ ? !document.body.hasClass("cm-show-line-nums")
+ ? document.body.addClass("cm-show-line-nums")
+ : null
+ : document.body.removeClass("cm-show-line-nums");
+ this.settings.copyButtonOnPRE
+ ? !document.body.hasClass("cm-show-copy-button-on-pre")
+ ? document.body.addClass("cm-show-copy-button-on-pre")
+ : null
+ : document.body.removeClass("cm-show-copy-button-on-pre");
+ this.settings.syntaxHighlighting
+ ? !document.body.hasClass("unified-cm-highlighting")
+ ? document.body.addClass("unified-cm-highlighting")
+ : null
+ : document.body.removeClass("unified-cm-highlighting");
+ this.settings.foldImages
+ ? !document.body.hasClass("cm-render-images-inline")
+ ? document.body.addClass("cm-render-images-inline")
+ : null
+ : document.body.removeClass("cm-render-images-inline");
+ this.settings.foldLinks
+ ? !document.body.hasClass("cm-collapse-external-links")
+ ? document.body.addClass("cm-collapse-external-links")
+ : null
+ : document.body.removeClass("cm-collapse-external-links");
+ this.settings.renderBanner
+ ? !document.body.hasClass("cm-render-banners")
+ ? document.body.addClass("cm-render-banners")
+ : null
+ : document.body.removeClass("cm-render-banners");
+ this.settings.enableCMinPreview
+ ? this.registerMarkdownPostProcessor(this.mdProcessor)
+ : obsidian.MarkdownPreviewRenderer.unregisterPostProcessor(this.mdProcessor);
+ if (refresh)
+ this.refreshPanes();
+ };
+ ObsidianCodeMirrorOptionsPlugin.prototype.unsetCodeMirrorOptions = function () {
+ var _this_1 = this;
+ this.app.workspace.iterateCodeMirrors(function (cm) {
+ // revert CodeMirror options back to the CM/Obsidian defaults
+ cm.setOption("styleSelectedText", false);
+ cm.setOption("singleCursorHeightPerLine", true);
+ cm.setOption("styleActiveLine", true);
+ cm.setOption("mode", "hypermd");
+ cm.setOption("hmdHideToken", false);
+ cm.setOption("hmdFold", { image: false, link: false, html: false, code: false, math: false });
+ cm.setOption("hmdTableAlign", false);
+ cm.setOption("hmdClick", false);
+ cm.setOption("cursorBlinkRate", 530);
+ cm.off("renderLine", _this_1.onRenderLineBound);
+ unload_math_preview(cm);
+ // cm.off("imageClicked", this.onImageClick);
+ cm.refresh();
+ });
+ document.body.classList.remove("style-active-selection", "style-check-box", "hide-tokens", "fallback-highlighting");
+ document.body.classList.remove("cm-render-banners", "cm-collapse-external-links", "cm-render-images-inline");
+ document.body.classList.remove("unified-cm-highlighting", "cm-show-copy-button-on-pre", "cm-show-line-nums");
+ };
+ ObsidianCodeMirrorOptionsPlugin.prototype.refreshPanes = function () {
+ this.app.workspace.getLeavesOfType("markdown").forEach(function (leaf) {
+ if (leaf.view instanceof obsidian.MarkdownView) {
+ leaf.view.previewMode.rerender(true);
+ }
+ });
+ };
+ ObsidianCodeMirrorOptionsPlugin.prototype.getActiveCmEditor = function () {
+ var _a;
+ var view = this.app.workspace.getActiveViewOfType(obsidian.MarkdownView);
+ //@ts-ignore
+ if (view)
+ return (_a = view.sourceMode) === null || _a === void 0 ? void 0 : _a.cmEditor;
+ return null;
+ };
+ ObsidianCodeMirrorOptionsPlugin.prototype.onunload = function () {
+ this.unsetCodeMirrorOptions();
+ obsidian.MarkdownPreviewRenderer.unregisterPostProcessor(this.mdProcessor);
+ this.refreshPanes();
+ document.off("contextmenu", "img.hmd-image", this.onImageContextMenu, false);
+ document.off("contextmenu", ".rendered-widget img:not(.hmd-image)", this.onImageContextMenu, false);
+ };
+ return ObsidianCodeMirrorOptionsPlugin;
+}(obsidian.Plugin));
+
+module.exports = ObsidianCodeMirrorOptionsPlugin;
diff --git a/notes/.obsidian/plugins/obsidian-codemirror-options/manifest.json b/notes/.obsidian/plugins/obsidian-codemirror-options/manifest.json
new file mode 100644
index 0000000..d0aec33
--- /dev/null
+++ b/notes/.obsidian/plugins/obsidian-codemirror-options/manifest.json
@@ -0,0 +1,9 @@
+{
+ "id": "obsidian-codemirror-options",
+ "name": "CodeMirror Options",
+ "version": "0.6.0",
+ "description": "Customize the functionality and appearance of Obsidian's edit mode",
+ "author": "NothingIsLost",
+ "authorUrl": "https://github.com/nothingislost",
+ "isDesktopOnly": true
+}
diff --git a/notes/.obsidian/plugins/obsidian-codemirror-options/styles.css b/notes/.obsidian/plugins/obsidian-codemirror-options/styles.css
new file mode 100644
index 0000000..cb99754
--- /dev/null
+++ b/notes/.obsidian/plugins/obsidian-codemirror-options/styles.css
@@ -0,0 +1,1339 @@
+/* @settings
+name: CodeMirror Options
+id: CodeMirror Options
+settings:
+ -
+ id: cm-header-theme
+ title: Syntax Highlighting Theme
+ type: heading
+ level: 1
+ collapsed: false
+ -
+ id: cm-theme-selection
+ title: Theme
+ type: class-select
+ allowEmpty: false
+ default: cm-theme-custom
+ options:
+ -
+ label: Solarized Light
+ value: cm-theme-solarized-light
+ -
+ label: Material Palenight
+ value: cm-theme-material-palenight
+ -
+ label: Dracula
+ value: cm-theme-dracula
+ -
+ label: Custom
+ value: cm-theme-custom
+ -
+ id: cm-header-styles
+ title: Syntax Highlighting Styling
+ type: heading
+ level: 1
+ collapsed: true
+ -
+ id: cm-font-monospace
+ title: Code Block Font
+ type: variable-text
+ default: 'Jetbrains Mono, SFMono-Regular, Consolas, "Roboto Mono",
+ monospace'
+ -
+ id: cm-font-size
+ title: Code Block Font Size
+ type: variable-text
+ default: '16px'
+ -
+ id: cm-line-height
+ title: Code Block Line Height
+ type: variable-number
+ default: 1.5
+ -
+ id: cm-font-weight
+ title: Code Block Font Weight
+ type: variable-number
+ default: 500
+ -
+ id: cm-wrap-lines
+ title: Code Block Wrap Lines in Peview
+ type: variable-select
+ default: 'pre-wrap'
+ options:
+ -
+ label: Wrap Lines
+ value: pre-wrap
+ -
+ label: Do Not Wrap Lines
+ value: pre
+ -
+ id: cm-header-colors
+ title: Syntax Highlighting Custom Colors (select theme "Custom" to enable)
+ type: heading
+ level: 1
+ collapsed: true
+ -
+ id: cm-background-color
+ title: Code Block Background Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#292d3e'
+ default-dark: '#292d3e'
+ -
+ id: cm-active-line-background-color
+ title: Code Block Active Line Background-Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#353a50'
+ default-dark: '#353a50'
+ -
+ id: cm-foreground-color
+ title: Code Block Foreground Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#d4d4d4'
+ default-dark: '#d4d4d4'
+ -
+ id: cm-keyword
+ title: Code Block Keyword Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#c792ea'
+ default-dark: '#c792ea'
+ -
+ id: cm-atom
+ title: Code Block Atom Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#f78c6c'
+ default-dark: '#f78c6c'
+ -
+ id: cm-number
+ title: Code Block Number Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#ff5370'
+ default-dark: '#ff5370'
+ -
+ id: cm-type
+ title: Code Block Type Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#decb6b'
+ default-dark: '#decb6b'
+ -
+ id: cm-def
+ title: Code Block Definition Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#82aaff'
+ default-dark: '#82aaff'
+ -
+ id: cm-definition
+ title: Code Block Definition-2 Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#82aaff'
+ default-dark: '#82aaff'
+ -
+ id: cm-property
+ title: Code Block Property Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#c792ea'
+ default-dark: '#c792ea'
+ -
+ id: cm-variable
+ title: Code Block Variable Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#f07178'
+ default-dark: '#f07178'
+ -
+ id: cm-variable-2
+ title: Code Block Variable-2 Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#eeffff'
+ default-dark: '#eeffff'
+ -
+ id: cm-variable-3
+ title: Code Block Variable-3 Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#f07178'
+ default-dark: '#f07178'
+ -
+ id: cm-callee
+ title: Code Block Callee Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#89ddff'
+ default-dark: '#89ddff'
+ -
+ id: cm-qualifier
+ title: Code Block Qualifier Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#decb6b'
+ default-dark: '#decb6b'
+ -
+ id: cm-operator
+ title: Code Block Operator Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#89ddff'
+ default-dark: '#89ddff'
+ -
+ id: cm-hr
+ title: Code Block HR Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#98e342'
+ default-dark: '#98e342'
+ -
+ id: cm-link
+ title: Code Block Link Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#696d70'
+ default-dark: '#696d70'
+ -
+ id: cm-error-bg
+ title: Code Block Error Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#ff5370'
+ default-dark: '#ff5370'
+ -
+ id: cm-header
+ title: Code Block Header Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#da7dae'
+ default-dark: '#da7dae'
+ -
+ id: cm-builtin
+ title: Code Block Builtin Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#ffcb6b'
+ default-dark: '#ffcb6b'
+ -
+ id: cm-meta
+ title: Code Block Meta Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#ffcb6b'
+ default-dark: '#ffcb6b'
+ -
+ id: cm-matching-bracket
+ title: Code Block Matching Bracket Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#ffffff'
+ default-dark: '#ffffff'
+ -
+ id: cm-tag
+ title: Code Block Tag Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#ff5370'
+ default-dark: '#ff5370'
+ -
+ id: cm-tag-in-comment
+ title: Code Block Tag in Comment Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#ff5370'
+ default-dark: '#ff5370'
+ -
+ id: cm-string-2
+ title: Code Block String-2 Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#f07178'
+ default-dark: '#f07178'
+ -
+ id: cm-bracket
+ title: Code Block Bracket Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#ff5370'
+ default-dark: '#ff5370'
+ -
+ id: cm-comment
+ title: Code Block Comment Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#676e95'
+ default-dark: '#676e95'
+ -
+ id: cm-string
+ title: Code Block String Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#c3e88d'
+ default-dark: '#c3e88d'
+ -
+ id: cm-attribute
+ title: Code Block Attribute Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#c792ea'
+ default-dark: '#c792ea'
+ -
+ id: cm-attribute-in-comment
+ title: Code Block Attribute In Comment Color
+ type: variable-themed-color
+ format: hex
+ default-light: '#c792ea'
+ default-dark: '#c792ea'
+
+*/
+
+:root {
+ --cm-font-weight: 500;
+ --cm-font-size: var(--editor-font-size);
+ --cm-font-monospace: Jetbrains Mono, SFMono-Regular, Consolas, "Roboto Mono", monospace;
+ --cm-wrap-lines: pre-wrap;
+ --cm-line-height: 1.5;
+}
+
+:root,
+.unified-cm-highlighting.cm-theme-custom {
+ /* material: palenight theme */
+ --cm-keyword: #c792ea;
+ --cm-atom: #f78c6c;
+ --cm-number: #ff5370;
+ --cm-type: #decb6b;
+ --cm-def: #82aaff;
+ --cm-property: #c792ea;
+ --cm-variable: #f07178;
+ --cm-variable-2: #eeffff;
+ --cm-variable-3: #f07178;
+ --cm-definition: #82aaff;
+ --cm-callee: #89ddff;
+ --cm-qualifier: #decb6b;
+ --cm-operator: #89ddff;
+ --cm-hr: #98e342;
+ --cm-link: #696d70;
+ --cm-error-bg: #ff5370;
+ --cm-header: #da7dae;
+ --cm-builtin: #ffcb6b;
+ --cm-meta: #ffcb6b;
+ --cm-matching-bracket: #ffffff;
+ --cm-tag: #ff5370;
+ --cm-tag-in-comment: #ff5370;
+ --cm-string-2: #f07178;
+ --cm-bracket: #ff5370;
+ --cm-comment: #676e95;
+ --cm-string: #c3e88d;
+ --cm-attribute: #c792ea;
+ --cm-attribute-in-comment: #c792ea;
+ --cm-background-color: #292d3e;
+ --cm-active-line-background-color: #353a50;
+ --cm-foreground-color: #d4d4d4;
+}
+
+body.unified-cm-highlighting.theme-light.cm-theme-dracula,
+body.unified-cm-highlighting.theme-dark.cm-theme-dracula {
+ --cm-background: #282a36;
+ --cm-foreground: #f8f8f2;
+ --cm-comment: #6272a4;
+ --cm-string: #f1fa8c;
+ --cm-string-2: #f1fa8c;
+ --cm-number: #bd93f9;
+ --cm-variable: #50fa7b;
+ --cm-variable-2: #ffffff;
+ --cm-def: #50fa7b;
+ --cm-operator: #ff79c6;
+ --cm-keyword: #ff79c6;
+ --cm-atom: #bd93f9;
+ --cm-meta: #f8f8f2;
+ --cm-tag: #ff79c6;
+ --cm-attribute: #50fa7b;
+ --cm-qualifier: #50fa7b;
+ --cm-property: #66d9ef;
+ --cm-builtin: #50fa7b;
+ --cm-variable-3: #ffb86c;
+ --cm-type: #ffb86c;
+ --cm-activeline-background: #414458;
+ --cm-matchingbracket: #fffff;
+}
+
+body.unified-cm-highlighting.theme-light.cm-theme-material-palenight,
+body.unified-cm-highlighting.theme-dark.cm-theme-material-palenight {
+ /* material: palenight theme */
+ --cm-keyword: #c792ea;
+ --cm-atom: #f78c6c;
+ --cm-number: #ff5370;
+ --cm-type: #decb6b;
+ --cm-def: #82aaff;
+ --cm-property: #c792ea;
+ --cm-variable: #f07178;
+ --cm-variable-2: #eeffff;
+ --cm-variable-3: #f07178;
+ --cm-definition: #82aaff;
+ --cm-callee: #89ddff;
+ --cm-qualifier: #decb6b;
+ --cm-operator: #89ddff;
+ --cm-hr: #98e342;
+ --cm-link: #696d70;
+ --cm-error-bg: #ff5370;
+ --cm-header: #da7dae;
+ --cm-builtin: #ffcb6b;
+ --cm-meta: #ffcb6b;
+ --cm-matching-bracket: #ffffff;
+ --cm-tag: #ff5370;
+ --cm-tag-in-comment: #ff5370;
+ --cm-string-2: #f07178;
+ --cm-bracket: #ff5370;
+ --cm-comment: #676e95;
+ --cm-string: #c3e88d;
+ --cm-attribute: #c792ea;
+ --cm-attribute-in-comment: #c792ea;
+ --cm-background-color: #292d3e;
+ --cm-active-line-background-color: #353a50;
+ --cm-foreground-color: #d4d4d4;
+}
+
+body.unified-cm-highlighting.theme-light.cm-theme-solarized-light,
+body.unified-cm-highlighting.theme-dark.cm-theme-solarized-light {
+ /* solarized */
+ --cm-keyword: #cb4b16;
+ --cm-atom: #d33682;
+ --cm-number: #d33682;
+ --cm-type: #6c71c4;
+ --cm-def: #2aa198;
+ --cm-property: #2aa198;
+ --cm-variable: #839496;
+ --cm-variable-2: #b58900;
+ --cm-variable-3: #6c71c4;
+ --cm-definition: #82aaff;
+ --cm-callee: #89ddff;
+ --cm-qualifier: #b58900;
+ --cm-operator: #6c71c4;
+ --cm-hr: #98e342;
+ --cm-link: #93a1a1;
+ --cm-error-bg: #ff5370;
+ --cm-header: #586e75;
+ --cm-builtin: #d33682;
+ --cm-meta: #859900;
+ --cm-matching-bracket: #859900;
+ --cm-tag: #93a1a1;
+ --cm-tag-in-comment: #ff5370;
+ --cm-string-2: #b58900;
+ --cm-bracket: #cb4b16;
+ --cm-comment: #586e75;
+ --cm-string: #859900;
+ --cm-attribute: #2aa198;
+ --cm-attribute-in-comment: #c792ea;
+ --cm-background-color: #fdf6e3;
+ --cm-active-line-background-color: #fffcf4;
+ --cm-foreground-color: #657b83;
+}
+
+/* Settings Styling */
+
+.mod-settings .setting-item.setting-disabled {
+ display: none;
+}
+
+.codemirror-options-settings .info {
+ font-size: 1rem;
+ color: var(--text-accent);
+}
+
+.token-list-setting .setting-item-description {
+ user-select: text !important;
+}
+
+.token-list-setting .setting-item-description {
+ max-width: 24em;
+}
+
+/* START: Style rendered code blocks */
+
+/* This element causes top padding and isn't needed, so we hide it */
+.rendered-code-block-wrapper span[cm-text] {
+ display: none;
+}
+
+/* Allow text selection */
+.rendered-code-block-wrapper {
+ user-select: text;
+}
+
+.cm-s-obsidian .rendered-code-block-wrapper pre.HyperMD-codeblock-begin {
+ padding: 0;
+}
+
+/* Remove the default code block background and let the rendered element set it */
+.rendered-code-block-wrapper .HyperMD-codeblock-bg {
+ opacity: 0;
+}
+/* Admonitions have margins by default. We don't need these in edit mode */
+/* You can add the margins back in, if you want, but you'll need to adjust the button positioning */
+.rendered-code-block-wrapper .admonition {
+ margin: 0em;
+}
+
+/* END: Style rendered code blocks */
+
+/* START: Reset default theme styling of rendered tables */
+
+.cm-s-obsidian .CodeMirror-linewidget table.dataview td,
+.cm-s-obsidian .CodeMirror-linewidget table.dataview th,
+.cm-s-obsidian .hmd-fold-html table.dataview td,
+.cm-s-obsidian .hmd-fold-html table.dataview th {
+ border: unset;
+ padding: 4px 10px;
+}
+
+.cm-s-obsidian .CodeMirror-linewidget .table-view-table.dataview > thead > tr > th {
+ font-weight: 700;
+ font-size: larger;
+ border-top: none;
+ border-left: none;
+ border-right: none;
+ border-bottom: solid;
+ max-width: 100%;
+ padding: 0px;
+}
+
+/* START: Banner rendering */
+
+body.cm-render-banners div[data-banner] .CodeMirror-code {
+ margin-top: var(--banner-height);
+ margin-bottom: calc(-1 * var(--banner-height));
+}
+/* the style below is needed to ensure the banner isn't removed when there is
+ no vertical scroll bar */
+body.cm-render-banners div[data-banner] .CodeMirror-vscrollbar {
+ display: block;
+ bottom: 0;
+}
+body.cm-render-banners div[data-banner] .CodeMirror-vscrollbar::before {
+ content: "";
+ height: var(--banner-height);
+ width: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+ background: var(--banner);
+ background-size: cover;
+ background-position: var(--banner_x) var(--banner_y);
+}
+body.cm-render-banners div[data-banner] .CodeMirror-gutter.CodeMirror-linenumbers,
+.mod-root .CodeMirror-gutter.CodeMirror-foldgutter {
+ background: transparent;
+}
+body.cm-render-banners div[data-banner][data-banner-style="gradient"] .CodeMirror-vscrollbar::before {
+ -webkit-mask-image: linear-gradient(to bottom, black, transparent);
+}
+
+/* END: Banner rendering */
+
+/* START: Rendered code & html block button styling and placement */
+
+.rendered-code-block-wrapper .CodeMirror-line .CodeMirror-widget,
+.rendered-html-block-wrapper .CodeMirror-line .CodeMirror-widget {
+ position: absolute;
+ left: 5px;
+ top: -1.5em;
+ padding-bottom: 0.5em;
+ z-index: 3;
+ line-height: 1.5;
+ display: none;
+}
+.cm-s-obsidian .CodeMirror-linewidget.rendered-html-block,
+.cm-s-obsidian .CodeMirror-linewidget.rendered-code-block {
+ padding: 0 5px;
+}
+.rendered-html-block-wrapper:hover .CodeMirror-line .CodeMirror-widget,
+.rendered-code-block-wrapper:hover .CodeMirror-line .CodeMirror-widget {
+ display: inline-flex;
+}
+.rendered-html-block-wrapper .CodeMirror-linewidget,
+.rendered-code-block-wrapper .CodeMirror-linewidget {
+ /* this is needed to have CM properly calculate the widget height */
+ /* when using display: block, margins on child elements don't cause the parent to expand */
+ display: grid;
+}
+
+.cm-s-obsidian .CodeMirror-widget :where(.hmd-fold-code-stub, .hmd-fold-html-stub) {
+ font-size: 0.7rem;
+ font-family: var(--font-monospace);
+ font-weight: 600;
+ margin: 0;
+ padding: 0em 0.2em;
+ line-height: 1.75em;
+}
+
+/* .rendered-code-block-wrapper.rendered-query-wrapper .CodeMirror-line .CodeMirror-widget {
+ right: 0.1em;
+ top: 0.1em;
+}
+
+.rendered-code-block-wrapper.rendered-dataview-wrapper .CodeMirror-line .CodeMirror-widget {
+ right: 0;
+ top: 0.2em;
+}
+
+.rendered-code-block-wrapper.rendered-chart-wrapper .CodeMirror-line .CodeMirror-widget {
+ right: 0.2em;
+ top: 0.2em;
+} */
+
+/* END: Rendered code block button styling and placement */
+
+/* START: Render HTML Styling */
+
+.cm-s-obsidian .hmd-fold-html {
+ position: relative;
+ border: 1px solid transparent;
+}
+
+/* END: Render HTML Styling */
+
+/* Ozan doesn't have a setting to only disable image rendering
+ so here we try and hide them if the "render images" setting is on */
+.cm-render-images-inline
+ .oz-image-widget
+ img:where([src*=".png"], [src*=".gif"], [src*=".svg"], [src*=".bmp"], [src*=".jpg"], [src*=".jpeg"]) {
+ display: none;
+}
+
+/* prevent images from wrapping when embedded in list items */
+.cm-render-images-inline .cm-s-obsidian .HyperMD-list-line img.hmd-image {
+ max-width: 99%;
+}
+
+.cm-render-images-inline .cm-s-obsidian img.hmd-image {
+ vertical-align: baseline;
+}
+
+/* Hide Tokens Styling */
+/* Note: Most of the token hiding styling is already in the base Obsidian theme */
+
+.hide-tokens .cm-s-obsidian pre.hmd-inactive-line.HyperMD-hr span.cm-hr {
+ color: transparent;
+ background-color: transparent;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-hr {
+ left: 0;
+ right: 0;
+ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAQAAAAziH6sAAAADklEQVR42mOc+Z9x5n8ACTkDM4ikM1IAAAAASUVORK5CYII=)
+ repeat-x 0 center;
+}
+
+/* Table Styling */
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row span.cm-hmd-table-sep:before {
+ content: "|";
+ color: transparent;
+ top: 0;
+ height: 100%;
+ position: absolute;
+ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mOc+R8AAjcBmvywMWoAAAAASUVORK5CYII=)
+ repeat-y center 0;
+ pointer-events: none;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row > span {
+ display: inline-block;
+ border-top: 1px solid #999;
+ margin-right: 50px;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row.HyperMD-table-row-0 > span,
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row.HyperMD-table-row-1 > span,
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row.HyperMD-table-row-2 > span {
+ border-top: 0;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row span.cm-hmd-table-sep {
+ width: 15px;
+ text-align: center;
+ box-sizing: content-box;
+ font-weight: 400;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row span.cm-hmd-table-sep.cm-hmd-table-sep-dummy {
+ width: 1em;
+}
+.cm-s-obsidian .HyperMD-table-row > :last-child {
+ padding-right: 0px !important;
+}
+.hide-tokens
+ .cm-s-obsidian
+ pre.hmd-inactive-line.HyperMD-table-row
+ span.cm-hmd-table-sep.cm-hmd-table-sep-dummy:before {
+ display: none;
+}
+.hide-tokens .cm-s-obsidian pre.hmd-inactive-line.HyperMD-table-row-1 > span {
+ color: transparent !important;
+ text-shadow: none;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row span.cm-hmd-table-sep:before {
+ content: "|";
+ color: transparent;
+ top: 0;
+ height: 100%;
+ position: absolute;
+ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mOc+R8AAjcBmvywMWoAAAAASUVORK5CYII=)
+ repeat-y center 0;
+ pointer-events: none;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row.HyperMD-table-row-0 {
+ font-weight: 600;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row.HyperMD-table-row-0 span.cm-strong {
+ font-weight: 800;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row .hmd-table-column-content {
+ padding: 4px 1px;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row.HyperMD-table-row-1 {
+ line-height: 8px;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row.HyperMD-table-row-1 > span {
+ border-bottom: 0;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row.HyperMD-table-row-1 .hmd-table-column-content {
+ padding: 1px;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row.HyperMD-table-row-0 > span {
+ border-bottom: 0;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row.HyperMD-table-row-0 span.hmd-table-column-content {
+ padding-bottom: 1px;
+}
+.hide-tokens .cm-s-obsidian pre.HyperMD-table-row.HyperMD-table-row-2 span.hmd-table-column-content {
+ padding-top: 1px;
+}
+
+.cm-s-obsidian span.hmd-hidden-token.cm-formatting-link,
+.cm-s-obsidian span.hmd-hidden-token.cm-formatting-highlight,
+.cm-s-obsidian span.hmd-hidden-token.cm-internal-link-url,
+.cm-s-obsidian span.hmd-hidden-token.cm-internal-link-ref {
+ display: inline;
+ font-size: 1px !important;
+ letter-spacing: -1ch;
+ font-family: monospace;
+ color: transparent;
+}
+.hide-tokens .cm-s-obsidian pre.hmd-inactive-line span.cm-formatting-quote {
+ color: transparent;
+}
+
+/* fold links */
+.cm-s-obsidian .hmd-link-icon::after {
+ content: " " !important;
+ text-shadow: none !important;
+ display: inline-block;
+ width: 0.8em;
+ height: 0.8em;
+ margin-left: 4px;
+ opacity: 1;
+ padding-left: 1px;
+ background-color: var(--text-accent);
+ -webkit-mask-repeat: no-repeat;
+ -webkit-mask-image: url('data:image/svg+xml;utf8,');
+}
+
+body .cm-s-obsidian span.hmd-link-icon {
+ opacity: 0.6;
+}
+
+.cm-s-obsidian.HyperMD-with-meta span.cm-url,
+.cm-s-obsidian.HyperMD-with-meta span.cm-link,
+.cm-s-obsidian.HyperMD-with-meta span.cm-hmd-internal-link,
+.cm-s-obsidian.HyperMD-with-meta .cm-link + .CodeMirror-widget,
+.cm-s-obsidian.HyperMD-with-meta span.cm-hashtag,
+.cm-s-obsidian.HyperMD-with-ctrl span.cm-url,
+.cm-s-obsidian.HyperMD-with-ctrl span.cm-link,
+.cm-s-obsidian.HyperMD-with-ctrl span.cm-hmd-internal-link,
+.cm-s-obsidian.HyperMD-with-ctrl .cm-link + .CodeMirror-widget,
+.cm-s-obsidian.HyperMD-with-ctrl span.cm-hashtag {
+ cursor: pointer;
+}
+
+/* set the new text selection mode to use --text-selection */
+body.style-active-selection span.CodeMirror-selectedtext {
+ background-color: var(--text-selection) !important;
+}
+
+/* disable the default CodeMirror selection */
+body.style-active-selection .CodeMirror-selected {
+ background: transparent !important;
+}
+
+/* these two styles are needed for line nums and copy blocks to position properly */
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian[class*="language-"],
+body.unified-cm-highlighting.cm-show-copy-button-on-pre[class*="theme-"] .markdown-preview-view pre {
+ position: relative;
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian[class*="language-"] code,
+body.unified-cm-highlighting.cm-show-copy-button-on-pre[class*="theme-"] .markdown-preview-view pre code {
+ position: static !important;
+}
+
+/* START Setting: Show Line Numbers === true */
+body.unified-cm-highlighting.cm-show-line-nums[class*="theme-"] .cm-linenumber {
+ position: absolute;
+ left: 0.5em;
+ user-select: none;
+ color: var(--cm-comment);
+}
+
+body.unified-cm-highlighting.cm-show-line-nums[class*="theme-"] .markdown-preview-view pre {
+ padding-left: 3em !important;
+}
+
+/* END Setting: Show Line Numbers === true */
+
+/* START Copy button */
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view button.copy {
+ display: inline-block;
+ height: 30px;
+ padding: 0 12px;
+ color: var(--cm-foreground-color);
+ text-align: center;
+ font-size: 11px !important;
+ font-weight: 600;
+ line-height: 30px;
+ letter-spacing: 0.1rem;
+ text-transform: uppercase !important;
+ text-decoration: none;
+ white-space: nowrap;
+ background-color: transparent;
+ border-radius: 4px;
+ border: 1px solid var(--cm-foreground-color);
+ cursor: pointer;
+ box-sizing: border-box;
+}
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view button.copy {
+ color: var(--cm-foreground-color);
+ position: absolute;
+ right: 0rem;
+ top: 0.6rem;
+ opacity: 0;
+ z-index: 1;
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre:hover button.copy {
+ background: var(--cm-background-color);
+ opacity: 1;
+}
+/* END Copy button */
+
+/* body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock,
+body.fallback-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock {
+ --code-bg: var(--cm-background-color);
+ --note: var(--cm-background-color);
+} */
+
+body.unified-cm-highlighting[class*="theme-"] .HyperMD-codeblock-bg,
+body.fallback-highlighting[class*="theme-"] .HyperMD-codeblock-bg {
+ /* this is required to override YingYang's !important declaration */
+ /* will remove as soon as it's removed from YinYang */
+ --pre-code: var(--cm-background-color);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-section code {
+ /* this is required to override YingYang's !important declaration */
+ /* will remove as soon as it's removed from YinYang */
+ --inline-code: var(--cm-foreground-color);
+}
+
+/* Reasoning for body.unified-cm-highlighting[class*="theme-"] */
+/* I had to get very specific to override the styling from Editor Syntax Highlighing and themes like Yin and Yang */
+
+/* Setting the cursor since the cursor is black by default in the base theme
+ * and it gets lost in a code black with a black background */
+body.unified-cm-highlighting[class*="theme-"] .CodeMirror-cursor {
+ --cursor-color: #afbaff;
+ border-color: var(--cursor-color);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-opening-tag,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-closing-tag {
+ color: var(--cm-comment) !important;
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView,
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian,
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-gutter,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian div.HyperMD-codeblock-bg, /* code block in edit mode */
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.CodeMirror-linebackground, /* frontmatter block in edit mode */
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .templater-command-bg, /* templater block in edit mode */
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .templater-inline .cm-templater-command, /* templater inline in edit mode */
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.CodeMirror-linebackground, /* math block in edit mode */
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian[class*="language-"],
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian[class*="language-"] code /* code block in preview mode */ {
+ background: var(--cm-background-color);
+ background-color: var(--cm-background-color);
+ text-shadow: none; /* just no */
+}
+
+/* edit modes */
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter,
+body.unified-cm-highlighting[class*="theme-"] .cm-templater-command,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math,
+body.unified-cm-highlighting[class*="theme-"] .HyperMD-codeblock,
+body.unified-cm-highlighting[class*="theme-"] .cm-hmd-codeblock {
+ background: transparent;
+ --font-monospace: var(--cm-font-monospace);
+ color: var(--cm-foreground-color);
+ font-family: var(--cm-font-monospace);
+ font-weight: var(--cm-font-weight);
+ line-height: var(--cm-line-height);
+ font-size: var(--cm-font-size);
+ white-space: pre-wrap; /* lines must wrap in edit mode or it breaks CM */
+}
+
+/* preview modes */
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian[class*="language-"],
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view code[class*="language-"],
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view .HyperMD-codeblock,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view .cm-hmd-codeblock {
+ --font-monospace: var(--cm-font-monospace);
+ color: var(--cm-foreground-color);
+ font-family: var(--cm-font-monospace);
+ font-weight: var(--cm-font-weight);
+ line-height: var(--cm-line-height);
+ font-size: var(--cm-font-size);
+ white-space: var(--cm-wrap-lines);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-keyword,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-keyword,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-keyword,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-keyword,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-keyword,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-keyword {
+ color: var(--cm-keyword);
+ font-weight: normal;
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-atom,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-atom,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-atom,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-atom,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-atom,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-atom {
+ color: var(--cm-atom);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-number,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-number,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-number,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-number,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-number,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-number {
+ color: var(--cm-number);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines span.cm-type,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-hmd-frontmatter.cm-type,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-templater-command.cm-type,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-math.cm-type,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock span.cm-type,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian span.cm-type {
+ color: var(--cm-type);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-def,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-def,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-def,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-def,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-def,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-def {
+ color: var(--cm-def);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines span.cm-property,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-hmd-frontmatter.cm-property,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-templater-command.cm-property,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-math.cm-property,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock span.cm-property,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian span.cm-property {
+ color: var(--cm-property);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines span.cm-variable,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-hmd-frontmatter.cm-variable,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-templater-command.cm-variable,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-math.cm-variable,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock span.cm-variable,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian span.cm-variable {
+ color: var(--cm-variable);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines span.cm-variable-2,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-hmd-frontmatter.cm-variable-2,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-templater-command.cm-variable-2,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-math.cm-variable-2,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock span.cm-variable-2,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian span.cm-variable-2 {
+ color: var(--cm-variable-2);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines span.cm-variable-3,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-hmd-frontmatter.cm-variable-3,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-templater-command.cm-variable-3,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian span.cm-math.cm-variable-3,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock span.cm-variable-3,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian span.cm-variable-3 {
+ color: var(--cm-variable-3);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-type.cm-def,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-type.cm-def,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-type.cm-def,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-type.cm-def,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-type.cm-def,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-type.cm-def {
+ color: var(--cm-definition);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-callee,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-callee,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-callee,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-callee,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-callee,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-callee {
+ color: var(--cm-callee);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-operator,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-operator,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-operator,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-operator,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-operator,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-operator {
+ color: var(--cm-operator);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-qualifier,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-qualifier,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-qualifier,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-qualifier,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-qualifier,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-qualifier {
+ color: var(--cm-qualifier);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-tag,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-tag,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-tag,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-tag,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-tag,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-tag {
+ color: var(--cm-tag);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-tag.cm-bracket,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-tag.cm-bracket,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-tag.cm-bracket,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-tag.cm-bracket,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-tag.cm-bracket,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-tag.cm-bracket {
+ color: var(--cm-bracket);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-attribute,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-attribute,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-attribute,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-attribute,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-attribute,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-attribute {
+ color: var(--cm-attribute);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-comment,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-comment,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-comment,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-comment,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-comment,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-comment {
+ color: var(--cm-comment);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-comment.cm-attribute,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-comment.cm-attribute,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-comment.cm-attribute,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-comment.cm-attribute,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-comment.cm-attribute,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-comment.cm-attribute {
+ color: var(--cm-attribute-in-comment);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-comment.cm-tag,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-comment.cm-tag,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-comment.cm-tag,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-comment.cm-tag,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-comment.cm-tag,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-comment.cm-tag {
+ color: var(--cm-tag-in-comment);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-string,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-string,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-string,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-string,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-string,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-string {
+ color: var(--cm-string);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-string-2,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-string-2,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-string-2,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-string-2,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-string-2,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-string-2 {
+ color: var(--cm-string-2);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-meta,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-meta,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-meta,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-meta,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-meta,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-meta {
+ color: var(--cm-meta);
+ /* background: var(--cm-background-color); */
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-builtin,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-builtin,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-builtin,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-builtin,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-builtin,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-builtin {
+ color: var(--cm-builtin);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-header,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-header,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-header,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-header,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-header,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-header {
+ color: var(--cm-header);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-hr,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-hr,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-hr,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-hr,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-hr,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-hr {
+ color: var(--cm-hr);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-link,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-link,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-link,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-link,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-link,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-link {
+ color: var(--cm-link);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .cm-error,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.cm-error,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.cm-error,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.cm-error,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .cm-error,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .cm-error {
+ color: white;
+ background-color: var(--cm-error-bg);
+}
+
+body.unified-cm-highlighting[class*="theme-"]
+ .CodeView
+ .cm-s-obsidian
+ .CodeMirror-lines
+ .CodeMirror-activeline-background,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.CodeMirror-activeline-background,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.CodeMirror-activeline-background,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.CodeMirror-activeline-background,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .HyperMD-codeblock-bg.CodeMirror-activeline-background,
+body.unified-cm-highlighting[class*="theme-"]
+ .markdown-preview-view
+ pre.cm-s-obsidian
+ .CodeMirror-activeline-background {
+ background: var(--cm-active-line-background-color);
+}
+
+body.unified-cm-highlighting[class*="theme-"] .CodeView .cm-s-obsidian .CodeMirror-lines .CodeMirror-matchingbracket,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-hmd-frontmatter.CodeMirror-matchingbracket,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-templater-command.CodeMirror-matchingbracket,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian .cm-math.CodeMirror-matchingbracket,
+body.unified-cm-highlighting[class*="theme-"] .cm-s-obsidian pre.HyperMD-codeblock .CodeMirror-matchingbracket,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre.cm-s-obsidian .CodeMirror-matchingbracket {
+ text-decoration: underline;
+ color: rgb(var(--cm-matching-bracket)) !important;
+}
+
+/* END CODE BLOCK EDITOR MODE SYNTAX HIGHLIGHTING[class*="theme-"] */
+
+/* FALL BACK CODE BLOCK PREVIEW MODE SYNTAX HIGHLIGHTING */
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre[class*="language-"] {
+ /* material: palenight theme */
+ background-color: var(--cm-background-color);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code,
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code * {
+ text-shadow: none;
+ color: var(--cm-foreground-color);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.keyword {
+ color: var(--cm-keyword);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.class-name {
+ color: var(--cm-def);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.class {
+ color: var(--cm-qualifier);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.function {
+ color: var(--cm-def);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.punctuation {
+ color: var(--cm-foreground-color);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.operator {
+ color: var(--cm-operator);
+ background: transparent;
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.entity {
+ color: var(--cm-attribute);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.parameter {
+ color: var(--cm-property);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.property {
+ color: var(--cm-property);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.important {
+ color: var(--cm-error-bg);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.attr-name {
+ color: var(--cm-tag);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.attr-value {
+ color: var(--cm-string);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.builtin {
+ color: var(--cm-builtin);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.string {
+ color: var(--cm-string);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.number {
+ color: var(--cm-number);
+}
+
+body.fallback-highlighting[class*="theme-"] .markdown-preview-view pre code span.unit {
+ color: var(--cm-number);
+}
+
+/* END FALL BACK CODE BLOCK PREVIEW MODE SYNTAX HIGHLIGHTING */
+
+/* START Mathjax Preview */
+
+.hmd-math-mathjax mjx-container[jax="CHTML"][display="true"] {
+ margin: 0;
+}
+
+#math-preview.float-win {
+ position: absolute;
+ position: fixed;
+ z-index: 3;
+ background: var(--background-primary);
+ background-image: linear-gradient(to bottom, var(--background-primary), var(--background-primary-alt));
+ border-radius: 5px;
+ overflow: hidden;
+ box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
+ max-width: 70%;
+}
+
+#math-preview.float-win-hidden {
+ display: none;
+}
+
+#math-preview .float-win-close {
+ position: absolute;
+ right: 0;
+ height: 100%;
+ top: 0;
+ color: #fff;
+ border: 0;
+ background-color: transparent;
+ cursor: pointer;
+ width: 28px;
+ border: none !important;
+ margin-right: 4px;
+ padding: 0;
+ vertical-align: middle;
+}
+
+#math-preview .float-win-close:hover {
+ background-color: transparent !important;
+}
+
+#math-preview .float-win-title {
+ position: relative;
+ background: var(--text-accent);
+ font-size: 0.87em;
+ color: var(--background-primary);
+ padding: 5px 15px;
+ padding-right: 50px;
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ cursor: move;
+}
+
+#math-preview .float-win-content {
+ max-height: 80vh;
+ overflow: auto;
+ padding: 10px 20px;
+}
+#math-preview button.float-win-close:focus {
+ box-shadow: none;
+}
+#math-preview .float-win-close .icon {
+ display: inline-block;
+ width: 1.5em;
+ height: 1.5em;
+ stroke-width: 0;
+ color: var(--background-primary);
+ stroke: currentColor;
+ fill: currentColor;
+ vertical-align: bottom;
+}
+/* END Mathjax preview */
diff --git a/notes/ang/Testy.md b/notes/ang/Testy.md
index 2bb5283..dea15c6 100644
--- a/notes/ang/Testy.md
+++ b/notes/ang/Testy.md
@@ -1,7 +1,6 @@
---
tags:
- ang
- - ang/testy
- testy
---
# Testy
diff --git a/notes/ang/listening.md b/notes/ang/listening.md
index 8cd5dff..e049b5c 100644
--- a/notes/ang/listening.md
+++ b/notes/ang/listening.md
@@ -1,7 +1,6 @@
---
tags:
- ang
- - ang/listening
---
# listening
1. A
diff --git a/notes/ang/slovesa.md b/notes/ang/slovesa.md
index 2575a62..f099fd2 100644
--- a/notes/ang/slovesa.md
+++ b/notes/ang/slovesa.md
@@ -1,7 +1,6 @@
---
tags:
- ang
- - ang/slovesa
---
# slovesa
1. beat, beat, beaten
diff --git a/notes/cjl/jména.md b/notes/cjl/jména.md
index 665519d..273d799 100644
--- a/notes/cjl/jména.md
+++ b/notes/cjl/jména.md
@@ -1,7 +1,6 @@
---
tags:
- cjl
- - cjl/jména
---
# jména
@@ -75,4 +74,25 @@ Buclatý, kulatý.
- z hebřejštiny
- kdo je bůh, "mi" -> bůh, "el" -> bůh
## Moša
-- "moša" spása (dítěte) v hebrejštině
\ No newline at end of file
+- "moša" spása (dítěte) v hebrejštině
+## Vít
+- Vojtěch
+- z nemčiny
+## Svoboda
+- svobodný sedlák
+- někdo kdo se vyplatil ze sedlanství
+- kdo měl ukončenou vojenskou službu
+## Lukáš
+- obyvatel Lukánie
+- z řečtiny
+## Kraus
+- kučera, kudrna
+## Alex
+- Saša
+- z ruska
+## Wage
+- ze severských zemí
+- v němčině "váha"
+## Souček
+- české
+- větvička
\ No newline at end of file
diff --git a/notes/data/Pasted image 20211101144629.png b/notes/data/Pasted image 20211101144629.png
new file mode 100644
index 0000000..648a0b8
Binary files /dev/null and b/notes/data/Pasted image 20211101144629.png differ
diff --git a/notes/data/Pasted image 20211101144810.png b/notes/data/Pasted image 20211101144810.png
new file mode 100644
index 0000000..fb5c582
Binary files /dev/null and b/notes/data/Pasted image 20211101144810.png differ
diff --git a/notes/data/Pasted image 20211101144829.png b/notes/data/Pasted image 20211101144829.png
new file mode 100644
index 0000000..8a12270
Binary files /dev/null and b/notes/data/Pasted image 20211101144829.png differ
diff --git a/notes/data/Pasted image 20211101144913.png b/notes/data/Pasted image 20211101144913.png
new file mode 100644
index 0000000..39ced6c
Binary files /dev/null and b/notes/data/Pasted image 20211101144913.png differ
diff --git a/notes/data/Pasted image 20211101145000.png b/notes/data/Pasted image 20211101145000.png
new file mode 100644
index 0000000..65b66ef
Binary files /dev/null and b/notes/data/Pasted image 20211101145000.png differ
diff --git a/notes/data/Pasted image 20211101145017.png b/notes/data/Pasted image 20211101145017.png
new file mode 100644
index 0000000..e178d30
Binary files /dev/null and b/notes/data/Pasted image 20211101145017.png differ
diff --git a/notes/data/Pasted image 20211101145031.png b/notes/data/Pasted image 20211101145031.png
new file mode 100644
index 0000000..5f795ea
Binary files /dev/null and b/notes/data/Pasted image 20211101145031.png differ
diff --git a/notes/data/Pasted image 20211101145057.png b/notes/data/Pasted image 20211101145057.png
new file mode 100644
index 0000000..b003144
Binary files /dev/null and b/notes/data/Pasted image 20211101145057.png differ
diff --git a/notes/data/Pasted image 20211101145113.png b/notes/data/Pasted image 20211101145113.png
new file mode 100644
index 0000000..91c08f0
Binary files /dev/null and b/notes/data/Pasted image 20211101145113.png differ
diff --git a/notes/data/Pasted image 20211101145123.png b/notes/data/Pasted image 20211101145123.png
new file mode 100644
index 0000000..4a87b5f
Binary files /dev/null and b/notes/data/Pasted image 20211101145123.png differ
diff --git a/notes/data/Pasted image 20211101145200.png b/notes/data/Pasted image 20211101145200.png
new file mode 100644
index 0000000..d90d585
Binary files /dev/null and b/notes/data/Pasted image 20211101145200.png differ
diff --git a/notes/data/Pasted image 20211101145306.png b/notes/data/Pasted image 20211101145306.png
new file mode 100644
index 0000000..3235f7b
Binary files /dev/null and b/notes/data/Pasted image 20211101145306.png differ
diff --git a/notes/data/Pasted image 20211101145318.png b/notes/data/Pasted image 20211101145318.png
new file mode 100644
index 0000000..f7d3e75
Binary files /dev/null and b/notes/data/Pasted image 20211101145318.png differ
diff --git a/notes/data/Pasted image 20211101145332.png b/notes/data/Pasted image 20211101145332.png
new file mode 100644
index 0000000..b2f5506
Binary files /dev/null and b/notes/data/Pasted image 20211101145332.png differ
diff --git a/notes/data/Pasted image 20211101145341.png b/notes/data/Pasted image 20211101145341.png
new file mode 100644
index 0000000..2ad2573
Binary files /dev/null and b/notes/data/Pasted image 20211101145341.png differ
diff --git a/notes/data/Pasted image 20211101145351.png b/notes/data/Pasted image 20211101145351.png
new file mode 100644
index 0000000..ce02ac1
Binary files /dev/null and b/notes/data/Pasted image 20211101145351.png differ
diff --git a/notes/data/Pasted image 20211101145401.png b/notes/data/Pasted image 20211101145401.png
new file mode 100644
index 0000000..e21e410
Binary files /dev/null and b/notes/data/Pasted image 20211101145401.png differ
diff --git a/notes/data/Pasted image 20211101145410.png b/notes/data/Pasted image 20211101145410.png
new file mode 100644
index 0000000..fb9194f
Binary files /dev/null and b/notes/data/Pasted image 20211101145410.png differ
diff --git a/notes/data/Pasted image 20211101145419.png b/notes/data/Pasted image 20211101145419.png
new file mode 100644
index 0000000..ab5959b
Binary files /dev/null and b/notes/data/Pasted image 20211101145419.png differ
diff --git a/notes/data/Pasted image 20211101145432.png b/notes/data/Pasted image 20211101145432.png
new file mode 100644
index 0000000..780ace8
Binary files /dev/null and b/notes/data/Pasted image 20211101145432.png differ
diff --git a/notes/dej/Data.md b/notes/dej/Data.md
index b3dbaf8..beedbe6 100644
--- a/notes/dej/Data.md
+++ b/notes/dej/Data.md
@@ -1,3 +1,8 @@
+---
+tags:
+ - dej
+ - generated
+---
# Data
Důležitá data:
```dataviewjs
diff --git a/notes/dej/moderní/1. světová válka.md b/notes/dej/moderní/1. světová válka.md
index d0edc27..a2b5c2d 100644
--- a/notes/dej/moderní/1. světová válka.md
+++ b/notes/dej/moderní/1. světová válka.md
@@ -2,9 +2,10 @@
tags:
- dej
- dej/moderní
- - dej/moderní/první-světová
+ - dej/mdoerní/první-světová
---
# 1. světová válka
+Začíná [[Sarajevský atentát|Sarajevským atentátem]]
## Zájmy velmocí na Balkáně
- od 70. let 19. st. hl. postavou evropského dění **Otto von Bismarck**
- Balkánský poloostrov - styčné území Turecka, Ruska a Rakouska-Uherska
@@ -19,4 +20,10 @@ tags:
- připojení **Itálie** z obavy před Francií (1882)
## Vznik Trojdohody
- protiněmecká smlouva **Francie** a **Ruska** (1894)
-- po vyřešení sporů o sféry vlivu v Evropě i v koloniích připojení **Velké Británie** (1907)
\ No newline at end of file
+- po vyřešení sporů o sféry vlivu v Evropě i v koloniích připojení **Velké Británie** (1907)
+
+## Kam dál
+- [[Čeští vojáci na bojištích světové války]]
+- [[Zbraně]]
+- [[Východní fronta]]
+- [[Západní fronta]]
\ No newline at end of file
diff --git a/notes/dej/moderní/1. světová válka/František Ferdinand d`Este.md b/notes/dej/moderní/1. světová válka/František Ferdinand d`Este.md
new file mode 100644
index 0000000..c149cd7
--- /dev/null
+++ b/notes/dej/moderní/1. světová válka/František Ferdinand d`Este.md
@@ -0,0 +1,10 @@
+---
+desc: Rakousko-uherský císař
+years: 1863 - 1914
+tags:
+ - dej
+ - osobnosti
+---
+# František Ferdinand d\`Este
+## František Ferdinand d\`Este
+
diff --git a/notes/dej/moderní/1. světová válka/Použití plynů.md b/notes/dej/moderní/1. světová válka/Použití plynů.md
index aa9e0ca..7739d6d 100644
--- a/notes/dej/moderní/1. světová válka/Použití plynů.md
+++ b/notes/dej/moderní/1. světová válka/Použití plynů.md
@@ -3,13 +3,14 @@ tags:
- dej
- dej/moderní
- dej/moderní/první-světová
- - dej/moderní/první-světová/plyny
---
# Použití plynů
Francie byla první zemí, která použila proti nepříteli plyn cloraceton, dne 3. srpna 1914.
Němci použili podobnou bojovou látku v říjnu 1914 u Nouve Chapelle.
+*Další zbraně: [[Zbraně]]*
+
## Yperit
Yperit (horčičný plyn) je vojenský plyn který použili Němci u belgického města Ypres.
diff --git a/notes/dej/moderní/1. světová válka/Sarajevský atentát.md b/notes/dej/moderní/1. světová válka/Sarajevský atentát.md
index 20b2f82..1a032e2 100644
--- a/notes/dej/moderní/1. světová válka/Sarajevský atentát.md
+++ b/notes/dej/moderní/1. světová válka/Sarajevský atentát.md
@@ -5,7 +5,6 @@ tags:
- dej
- dej/moderní
- dej/moderní/první-světová
- - dej/moderní/první-světová/atentát
---
# Sarajevský atentát
28.6.1914
@@ -15,12 +14,4 @@ tags:
- **Rakousko** vyhlašuje válku **Srbsku** -> **Rusko** vstupuje na obranu -> **Německo** mu vyhlašuje válku, následně **Francii** (přelom července a srpna)
- po napadení neutrální Belgie vstupuje do války i **Velká Británie**
-## František Ferdinand d\`Este
-
-
-## Bojiště 1. sv. války
-### Fronty
-- **Západní** (Německo x France)
-- **Východní**
-
-Nebojuje se jen v Evropě, ale také v koloniích (Afrika) a na moři.
\ No newline at end of file
+![[František Ferdinand d`Este]]
\ No newline at end of file
diff --git a/notes/dej/moderní/1. světová válka/Východní fronta.md b/notes/dej/moderní/1. světová válka/Východní fronta.md
index 0b3a9e0..18227c3 100644
--- a/notes/dej/moderní/1. světová válka/Východní fronta.md
+++ b/notes/dej/moderní/1. světová válka/Východní fronta.md
@@ -3,7 +3,6 @@ tags:
- dej
- dej/moderní
- dej/moderní/první-světová
- - dej/moderní/první-světová/východní-fronta
---
# Východní fronta
- bitva u Tannenburgu a Mazurských jezer (1914)
diff --git a/notes/dej/moderní/1. světová válka/Zbraně.md b/notes/dej/moderní/1. světová válka/Zbraně.md
index 1529a68..2f56b17 100644
--- a/notes/dej/moderní/1. světová válka/Zbraně.md
+++ b/notes/dej/moderní/1. světová válka/Zbraně.md
@@ -3,11 +3,12 @@ tags:
- dej
- dej/moderní
- dej/moderní/první-světová
- - dej/moderní/první-světová/zbraně
---
# Zbraně
- **strojní pušky** (kulomety), dělostřelectvo, minomety, granáty, plamenomety
- **ponorky** - využívají zejména Němci (Středozemní moře, kolem V. Británie)
- **tanky** - reakce na bezvýchodnost zákopové války, poprvé v září 1916 na Sommě.
- **letadla** - z průzkumných prostředků se stává účinná zbraň -> rytířské souboje, bombardování
-- **chemické zbraně** - jedovaté plyny: chlor, yperit
\ No newline at end of file
+- **chemické zbraně** - jedovaté plyny: chlor, yperit
+
+[[Použití plynů]]
\ No newline at end of file
diff --git a/notes/dej/moderní/1. světová válka/Západní fronta.md b/notes/dej/moderní/1. světová válka/Západní fronta.md
index af576a9..b173706 100644
--- a/notes/dej/moderní/1. světová válka/Západní fronta.md
+++ b/notes/dej/moderní/1. světová válka/Západní fronta.md
@@ -3,7 +3,6 @@ tags:
- dej
- dej/moderní
- dej/moderní/první-světová
- - dej/moderní/první-světová/západní-fronta
---
# Západní fronta
- blesková a zákopová válka, patová situace
diff --git a/notes/dej/moderní/1. světová válka/Český zahraniční odboj.md b/notes/dej/moderní/1. světová válka/Český zahraniční odboj.md
new file mode 100644
index 0000000..9187fda
--- /dev/null
+++ b/notes/dej/moderní/1. světová válka/Český zahraniční odboj.md
@@ -0,0 +1,24 @@
+---
+tags:
+ - dej
+ - dej/moderní
+ - dej/moderní/první-světová
+---
+# Český zahraniční odboj
+- Česká národní rada: T.G. **Masaryk**, E. **Beneš**, M.R. **Štefánik**
+- snaha přesvědčit státy Dohody o nutnosti rozbít Rakousko-Uhersko
+- organizace legií, následky bolševického převratu, transsibiřská anabáze
+- Čeljabinský incident
+- léto 1918 - Národní rada československá uznána Francií a Velkou Británií
+- říjen 1918 - **Washingtonská deklarace** (program prozatimní vlády)
+
+
+![[Pasted image 20211101145306.png]]
+![[Pasted image 20211101145318.png]]
+![[Pasted image 20211101145332.png]]
+![[Pasted image 20211101145341.png]]
+![[Pasted image 20211101145351.png]]
+![[Pasted image 20211101145401.png]]
+![[Pasted image 20211101145410.png]]
+![[Pasted image 20211101145419.png]]
+![[Pasted image 20211101145432.png]]
\ No newline at end of file
diff --git a/notes/dej/moderní/1. světová válka/Čeští vojáci na bojištích světové války.md b/notes/dej/moderní/1. světová válka/Čeští vojáci na bojištích světové války.md
new file mode 100644
index 0000000..f2d256a
--- /dev/null
+++ b/notes/dej/moderní/1. světová válka/Čeští vojáci na bojištích světové války.md
@@ -0,0 +1,25 @@
+---
+tags:
+ - dej
+ - dej/moderní
+ - dej/moderní/první-světová
+---
+# Čeští vojáci na bojištích světové války
+1. v rakouském vojsku
+2. na straně Dohody
+- první voj. oddíly českých krajanů - Česká družina (Rusko), rota Nazdar (Francie)
+- od 1915 vize česko-slovenské budoucnosti (Clevelandská dohoda)
+- československé legie: Rusko (80 tis.), Francie (10 tis.), Itálie (20 tis.)
+- doplňovány přestupy zajatců
+- jejich úspěchy = argument pro čs. samostatnost -> bitva u Zborova (2.7.1917)
+
+
+[[Český zahraniční odboj]]
+
+![[Pasted image 20211101144913.png]]
+![[Pasted image 20211101145000.png]]
+![[Pasted image 20211101145017.png]]
+![[Pasted image 20211101145031.png]]
+![[Pasted image 20211101145057.png]]
+![[Pasted image 20211101145113.png]]
+![[Pasted image 20211101145123.png]]
diff --git a/notes/dej/starší/úvod.md b/notes/dej/starší/úvod.md
index 6834706..13217c0 100644
--- a/notes/dej/starší/úvod.md
+++ b/notes/dej/starší/úvod.md
@@ -37,4 +37,9 @@ tags:
- zpracování kovu
- ve Středomoří se doba bronzová a železná již prolíná se starověkem
- železo - od Chetitů, důvod převahy Dórů
- - kutí, lití kovu, ražení mincí
\ No newline at end of file
+ - kutí, lití kovu, ražení mincí
+
+## Místa
+- [[Hrad Kalich]]
+- [[Stonehenge]]
+- [[Jeskyně pod Býčí skálou]]
\ No newline at end of file
diff --git a/notes/dej/Úvod.md b/notes/dej/Úvod.md
index 6bb7300..dad9c4d 100644
--- a/notes/dej/Úvod.md
+++ b/notes/dej/Úvod.md
@@ -2,13 +2,15 @@
desc: Dějepis
tags:
- dej
- - dej/README
- README
---
# Úvod
- humanitní a společenská věda
- dějiny člověka a jeho civilizace
+## Kde začít
+- [[1. světová válka]]
+- [[dej/starší/úvod|Úvod do pre-historie]]
## Důležitá data
![[Data#^806fb9]]
## Prameny
diff --git a/notes/ech/Mendělejev.md b/notes/ech/Mendělejev.md
index 74be86f..61643d6 100644
--- a/notes/ech/Mendělejev.md
+++ b/notes/ech/Mendělejev.md
@@ -1,7 +1,8 @@
---
+years: 1834 - 1907
+desc: Autor Periodické soustavy prvků
tags:
- ech
- - ech/Mendělejev
- osobnosti
---
# Mendělejev
diff --git a/notes/ech/Názvosloví.md b/notes/ech/Názvosloví.md
index 7907734..514a680 100644
--- a/notes/ech/Názvosloví.md
+++ b/notes/ech/Názvosloví.md
@@ -1,3 +1,7 @@
+---
+tags:
+ - ech
+---
# Názvosloví
## Trivální
"jednoduché" názvy
@@ -5,4 +9,73 @@
- **voda** $H_2O$
- **sulfan** $H_2S$
- **amoniak** $NH_3$
-- **peroxid vodíku** $H_2O_2$
\ No newline at end of file
+- **peroxid vodíku** $H_2O_2$
+
+## Systematické
+### Kyslíkaté kyseliny
+$H^{+I}Cl^?O^{-II}$
+Název se řídí ox. číslem centrálního prvku
+
+| náboj | název | zkratka |
+| ------------------------- | ------------ | -------- |
+| $H^{+I}Cl^{+I}O^{-II}$ | kys.chlorná | $HClO$ |
+| $H^{+I}Cl^{+III}O^{-II}_2$ | kys.chloritá | $HClO_2$ |
+
+#### Kyselina sírová
+- $H^{+I}S^{+VI}O^{-II}$
+- $H_2^{+I}S^{+VI}O^{-II}$
+- $H_2^{+I}S^{+VI}O^{-II}_4$ -> **$H_2SO_4$**
+
+#### Příklady
+- kys. dusičná $HNO_3$
+- kys. siřičitá
+- kys. uhličitá $H_2CO_3$
+- kys. chromitá
+- $HPO_2$
+- $H_2SO_4$
+- $H_2SiO_3$
+- $HBrO$
+
+[další](./prvky.md)
+
+### Kyslíkaté kyseliny s více vodíky
+Název se řídí ox. číslem centrálního prvku.
+Počet vodíku je v názvu uveden.
+
+- $H_3PO_3$ - kys. trihydrogenfosforitá
+- $H_5IO_6$ - kys. pentahydrogeniodistá
+- $H_5MNO_6$ - kys. pentahydrogenmanganistá
+- $H_3PO_4$ - kys. trihydrogenfosforečná
+
+### Síran sodný
+- kys. sírová $H_2SO_4$
+- odtrhneme vodíky a vytvoříme aniont síranový $SO_4^{2-}$
+- doplníme kationt $Na^+SO_4^{2-}$
+- bilancujeme náboj $Na_2SO_4$
+
+### Dusičnan rtuťnatý
+- kys. dusičná $HNO_3$
+- odtrhneme vodíky a vytvoříme aniont dusičnanový $NO_3^-$
+- doplníme kationt $Hg^{2+}NO_3^-$
+- bilancujeme náboj $HG(NO_3)_2$
+
+### Síran hlinitý
+- kys. sírová $H_2SO_4$
+- odtrhneme vodíky a vytvoříme aniont síranový $SO_4^{2-}$
+- doplníme kationt $Al^{+III}SO_4^{2-}$
+- bilancujeme náboj $Al_2(SO_4)_3$
+
+## Soli
+$$MnSO_4$$
+- lze se opřít o ox. číslo kyslíku -II. $MnSO_4^{-II}$
+- platí že aniont musí mít náboj buď 2- nebo jen -, zde zřejmě 2- $SO_4^{2-}$
+- ox. čísla manganu je tedy zřejmě +II
+- ox. číslo síry získám z původní kyseliny $H_2S^{VI}O_4$
+$$Mn^{+II}S^{VI}O_4^{-II}$$
+Jedna se tedy o manganatou sůl kys. sírové, tedy **síran manganatý**
+
+## Hydrogensoli kyselin
+- Oxokyseliny, které mají více vodíků se nemusí zbavovat všech. Některé si ponechají a přesto vytvoří sůl.
+- kys. sírová $H_2SO_4$
+- odtrhneme vodíky a vytvoříme aniont hydrogensíranový $HSO_4^-$
+- **hydrogensíran draselný** $KHSO_4$
\ No newline at end of file
diff --git a/notes/ech/Vazby.md b/notes/ech/Vazby.md
index f53499c..2bcbbc5 100644
--- a/notes/ech/Vazby.md
+++ b/notes/ech/Vazby.md
@@ -1,7 +1,6 @@
---
tags:
- ech
- - ech/vazby
---
# Vazby
## Vazebná energie a Disociační energie
diff --git a/notes/ech/hmota.md b/notes/ech/hmota.md
index 667f1a0..76d194f 100644
--- a/notes/ech/hmota.md
+++ b/notes/ech/hmota.md
@@ -1,7 +1,6 @@
---
tags:
- ech
- - ech/hmota
---
# hmota
## Částice
diff --git a/notes/ech/obal atomu.md b/notes/ech/obal atomu.md
index eaf674c..0b134e5 100644
--- a/notes/ech/obal atomu.md
+++ b/notes/ech/obal atomu.md
@@ -1,9 +1,6 @@
---
tags:
- ech
- - ech/atom
- - ech/shrodingerova-rovnice
- - ech/kvantová-čísla
---
# obal atomu
- Obsazování orbitalů elektrony
diff --git a/notes/ech/prvky.md b/notes/ech/prvky.md
index 92ec768..03d0929 100644
--- a/notes/ech/prvky.md
+++ b/notes/ech/prvky.md
@@ -1,6 +1,22 @@
+---
+tags:
+ - ech
+---
# prvky
$$ ^{28}_{14}Si $$
$$ ^{33}_{43}Tc $$
$$ ^{133}_{56}Cs $$
+---
+
+- Oxid fosforečný $P_2O_5$
+- Hydroxid manganatý $Mn(OH)_2$
+- Sulfid germaničitý $GeS_2$
+- Hydrogensulfid draselný $KHS$
+- Oxid fosforitý $P_2O_3$
+- $TiO_2$ Oxid titaničitý
+- $H_2S$ sulfan / sirovodík
+- $KOH$ Hydroxid draselný
+- $MgO_2$ Oxid hořčitý
+- $Mn(HS)_2$ Hydrogensulfid manganatý
\ No newline at end of file
diff --git a/notes/ech/radioaktivita.md b/notes/ech/radioaktivita.md
index ada10d2..52a504b 100644
--- a/notes/ech/radioaktivita.md
+++ b/notes/ech/radioaktivita.md
@@ -1,9 +1,6 @@
---
tags:
- ech
- - ech/radioaktivita
- - ech/radioaktivita/fúzní
- - ech/radioaktivita/rozklad
---
# radioaktivita
- přírodní proces
diff --git a/notes/ele/Náboj, proud, napětí a odpor.md b/notes/ele/Náboj, proud, napětí a odpor.md
index 54a8de6..6ffe5dc 100644
--- a/notes/ele/Náboj, proud, napětí a odpor.md
+++ b/notes/ele/Náboj, proud, napětí a odpor.md
@@ -1,9 +1,6 @@
---
tags:
- ele
- - ele/náboj
- - ele/proud
- - ele/napětí
---
# Náboj, proud, napětí a odpor
![[Pasted image 20210920101314.png]]
diff --git a/notes/ele/Polovodiče.md b/notes/ele/Polovodiče.md
index f7bab33..bdc29d0 100644
--- a/notes/ele/Polovodiče.md
+++ b/notes/ele/Polovodiče.md
@@ -2,7 +2,6 @@
tags:
- ele
- ele/vodiče
- - ele/vodiče/polovodiče
---
# Polovodiče
Polovodiče mají valenční elektrony za normálních podmínek pevně vázané. Elektrický proud vedou za změny podmínek.
\ No newline at end of file
diff --git a/notes/ele/Vodiče.md b/notes/ele/Vodiče.md
index 965d584..1115c17 100644
--- a/notes/ele/Vodiče.md
+++ b/notes/ele/Vodiče.md
@@ -2,8 +2,6 @@
tags:
- ele
- ele/vodiče
- - ele/vodiče/polovodiče
- - ele/vodiče/izolanty
---
# Vodiče
Rozdělení:
diff --git a/notes/fyz/Exponencionální zápis.md b/notes/fyz/Exponencionální zápis.md
index 91351d0..fbb0d78 100644
--- a/notes/fyz/Exponencionální zápis.md
+++ b/notes/fyz/Exponencionální zápis.md
@@ -1,7 +1,6 @@
---
tags:
- fyz
- - fyz/exponencionální-zápis
---
# Exponencionální zápis
Jedna cifra před desetinou čárkou (ne nula), krát 10 na exponent.
diff --git a/notes/fyz/Jednotky SI.md b/notes/fyz/Jednotky SI.md
index 5219273..2200a81 100644
--- a/notes/fyz/Jednotky SI.md
+++ b/notes/fyz/Jednotky SI.md
@@ -2,8 +2,6 @@
tags:
- fyz
- fyz/SI
- - fyz/SI/jednotky
- - fyz/SI/příklady
---
# Jednotky SI
– metr, kilogram, sekunda, Kelvin, ampér, mol, kandela
diff --git a/notes/fyz/Pohyb.md b/notes/fyz/Pohyb.md
index 4fca4fe..0cbf49e 100644
--- a/notes/fyz/Pohyb.md
+++ b/notes/fyz/Pohyb.md
@@ -2,6 +2,7 @@
tags:
- fyz
- fyz/pohyb
+ - fyz/veličiny
---
# Pohyb
## Mechanický
@@ -39,4 +40,9 @@ $$ t_1 = 20min = \frac{1}{3}h $$
$$ v_1 = 30\frac{km}{h} $$
$$ t_2 = 10min = \frac{1}{6}h $$
$$ v_2 = (s - t_1 * v_1) / t_2 = (30km - \frac{1}{3} * 30 \frac{km}{h}) / \frac{1}{6}h = (30km - 10) / \frac{1}{6} = 20 / \frac{1}{6} = 20 * 6 = 120 \frac{km}{h}$$
-- Musí jet rychlostí $120 \frac{km}{h}$ aby to stihl.
\ No newline at end of file
+- Musí jet rychlostí $120 \frac{km}{h}$ aby to stihl.
+
+## Perioda pohybu T
+- doba, za níž se rovnoměrný pohyb po kružnici opakuje.
+- $f=\frac{1}{T}$ - frekvence
+- $[T]=s$
\ No newline at end of file
diff --git a/notes/fyz/Příklad.md b/notes/fyz/Příklad.md
index 9dfbd3e..81e711e 100644
--- a/notes/fyz/Příklad.md
+++ b/notes/fyz/Příklad.md
@@ -1,7 +1,6 @@
---
tags:
- fyz
- - fyz/příklady
---
# Příklad
$$
diff --git a/notes/fyz/Rychlost.md b/notes/fyz/Rychlost.md
index d6d6b3a..785830c 100644
--- a/notes/fyz/Rychlost.md
+++ b/notes/fyz/Rychlost.md
@@ -1,7 +1,7 @@
---
tags:
- fyz
- - fyz/rychlost
+ - fyz/veličiny
---
# Rychlost
## Příklady
diff --git a/notes/fyz/Veličiny.md b/notes/fyz/Veličiny.md
index 9fe606c..c2071f0 100644
--- a/notes/fyz/Veličiny.md
+++ b/notes/fyz/Veličiny.md
@@ -2,19 +2,7 @@
tags:
- fyz
- fyz/veličiny
- - fyz/veličiny/vektory
- - fyz/veličiny/síla
- - fyz/veličiny/rychlost
- - fyz/veličiny/zrychlení
- - fyz/veličiny/zrychlení/tíhové
- - fyz/veličiny/délka
- - fyz/veličiny/hmotnost
- - fyz/veličiny/teplota
- - fyz/veličiny/čas
- - fyz/veličiny/náboj
- fyz/SI
- - fyz/SI/jednotky
- - fyz/SI/předpony
---
# Veličiny
Některé písmenka mohou mít více přiřazených veličin:
diff --git a/notes/har/CPU.md b/notes/har/CPU.md
index 6850f1e..7f2dd6d 100644
--- a/notes/har/CPU.md
+++ b/notes/har/CPU.md
@@ -1,13 +1,6 @@
---
tags:
- har
- - har/cpu
- - har/cpu/alu
- - har/cpu/fpu
- - har/cpu/gpu
- - har/cpu/controller
- - har/cpu/registers
- - har/cpu/cache
---
# CPU
Základní úlohou mikroprocesoru je pracovat podle pokynů určitého programu nebo hardwaru v počítači či jiném podobném zařízení (tablet, smart phone...)
diff --git a/notes/har/IQRF.md b/notes/har/IQRF.md
index d00e7b9..f68677c 100644
--- a/notes/har/IQRF.md
+++ b/notes/har/IQRF.md
@@ -1,7 +1,7 @@
---
tags:
- har
- - har/IQRF
+ - iot
---
# IQRF
IoT, chytré spotřebiče/domácnost/škola.
diff --git a/notes/har/historie počítačů.md b/notes/har/historie počítačů.md
index cbd36dd..4a2fbec 100644
--- a/notes/har/historie počítačů.md
+++ b/notes/har/historie počítačů.md
@@ -2,7 +2,6 @@
tags:
- har
- dej
- - har/history
- dej/počítače
---
# historie počítačů
diff --git a/notes/mat/Druhá odmocnina.md b/notes/mat/Druhá odmocnina.md
index 6cd9c95..5fcf3c0 100644
--- a/notes/mat/Druhá odmocnina.md
+++ b/notes/mat/Druhá odmocnina.md
@@ -1,7 +1,6 @@
---
tags:
- mat
- - mat/druhá-odmocnina
---
# Druhá odmocnina
$\sqrt{x}$
diff --git a/notes/mat/Matematika.md b/notes/mat/Matematika.md
index 76a7242..46c7e1f 100644
--- a/notes/mat/Matematika.md
+++ b/notes/mat/Matematika.md
@@ -1,8 +1,9 @@
---
desc: Matematika
tags:
- - mat/README
+ - mat
- README
+ - generated
---
# Matematika
```dataviewjs
diff --git a/notes/mat/Množiny.md b/notes/mat/Množiny.md
index f624dba..e817954 100644
--- a/notes/mat/Množiny.md
+++ b/notes/mat/Množiny.md
@@ -2,11 +2,6 @@
tags:
- mat
- mat/množiny
- - mat/množiny/průnik
- - mat/množiny/podmnožina
- - mat/množiny/sjednocení
- - mat/množiny/doplněk
- - mat/množiny/rozdíl
---
# Množiny
Množina je souhrn nějakých předmětů (prvků množiny).
diff --git a/notes/mat/Násobek a dělitel.md b/notes/mat/Násobek a dělitel.md
index 95875ff..e3f4879 100644
--- a/notes/mat/Násobek a dělitel.md
+++ b/notes/mat/Násobek a dělitel.md
@@ -1,8 +1,6 @@
---
tags:
- mat
- - mat/násobek
- - mat/dělitel
---
# Násobek a dělitel
Číslo $a$ je násobkem čísla $b$ (číslo $b$ je dělitel čísla $a$) právě tehdy, když existuje přirozené číslo $k$ takové, že $a = k * b$.
diff --git a/notes/mat/Rozklad složených čísel na součin prvočísel.md b/notes/mat/Rozklad složených čísel na součin prvočísel.md
index 7810ce6..7fb8212 100644
--- a/notes/mat/Rozklad složených čísel na součin prvočísel.md
+++ b/notes/mat/Rozklad složených čísel na součin prvočísel.md
@@ -1,7 +1,6 @@
---
tags:
- mat
- - mat/prvočísla/rozklad
---
# Rozklad složených čísel na součin prvočísel
diff --git a/notes/mat/Zakrouhlení.md b/notes/mat/Zakrouhlení.md
index 4ddcb69..de2c838 100644
--- a/notes/mat/Zakrouhlení.md
+++ b/notes/mat/Zakrouhlení.md
@@ -1,7 +1,6 @@
---
tags:
- mat
- - mat/zakrouhlení
---
# Zakrouhlení
$$ 0.000000006328 = 6.328*10^{-9} $$
diff --git a/notes/mat/Zlomky.md b/notes/mat/Zlomky.md
index 4de49f5..ffdad6e 100644
--- a/notes/mat/Zlomky.md
+++ b/notes/mat/Zlomky.md
@@ -1,7 +1,6 @@
---
tags:
- mat
- - mat/zlomky
---
# Zlomky
$$
diff --git a/notes/mat/Číselné obory.md b/notes/mat/Číselné obory.md
index 9af2fc3..2b523a0 100644
--- a/notes/mat/Číselné obory.md
+++ b/notes/mat/Číselné obory.md
@@ -1,8 +1,6 @@
---
tags:
- mat
- - mat/číselné-obory
- - mat/imaginárni-číslo
---
# Číselné obory
diff --git a/notes/mat/Číselné soustavy.md b/notes/mat/Číselné soustavy.md
index 2fb4520..e08cd40 100644
--- a/notes/mat/Číselné soustavy.md
+++ b/notes/mat/Číselné soustavy.md
@@ -1,7 +1,6 @@
---
tags:
- mat
- - mat/číselne-soustavy
---
# Číselné soustavy
## Používané
diff --git a/notes/pdv/30 let linuxu.md b/notes/pdv/30 let linuxu.md
index 9c47312..f3c128a 100644
--- a/notes/pdv/30 let linuxu.md
+++ b/notes/pdv/30 let linuxu.md
@@ -2,7 +2,7 @@
Day: 2021-09-16
tags:
- pdv
- - pdv/linux
+ - linux
---
# 30 let linuxu
Necelé 2 týdny zpátky (v době psaní) bylo výročí 30 let od oznámení linuxu. Linus Torvalds 25. srpna poslal email kde psal o tom, jak pracuje na operačním systému pro procesory řady 386/486, a taky napsal že to nebude nic velkého a profesionálního jako GNU (ironicky). Napsal že Linux není portovatelný, protože používá hodně funkcí specifických pro 386 procesory. Nedávno byl naportován na VRChat shader (pomocí emulace RISC-V procesoru, který má úplně jinou architekturu než 386).
diff --git a/notes/pdv/Procesory AMD x Intel.md b/notes/pdv/Procesory AMD x Intel.md
index 48134b4..d427614 100644
--- a/notes/pdv/Procesory AMD x Intel.md
+++ b/notes/pdv/Procesory AMD x Intel.md
@@ -2,6 +2,5 @@
Day: 2021-11-04
tags:
- pdv
- - pdv/procesor
---
# Procesory AMD x Intel
diff --git a/notes/psi/Sítě.md b/notes/psi/Sítě.md
index 48fff2e..07df88a 100644
--- a/notes/psi/Sítě.md
+++ b/notes/psi/Sítě.md
@@ -2,6 +2,7 @@
desc: Počítačové sítě
tags:
- psi
+ - generated
- README
---
# Sítě
diff --git a/notes/psi/Základy komunikace.md b/notes/psi/Základy komunikace.md
index 997627d..42afa21 100644
--- a/notes/psi/Základy komunikace.md
+++ b/notes/psi/Základy komunikace.md
@@ -2,14 +2,6 @@
desc: Základní pojmy a věci okolo internetu.
tags:
- psi
- - psi/protokol
- - psi/iso-osi
- - psi/tcp
- - psi/ip
- - psi/udp
- - psi/mac
- - psi/router
- - psi/switch
---
# Základy komunikace
![[tcpudp.jpg]]