/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // main.ts var main_exports = {}; __export(main_exports, { default: () => MathJaxWikiLinks }); module.exports = __toCommonJS(main_exports); var import_obsidian = require("obsidian"); function convertLink(link) { var _a; const linkText = (_a = link.textContent) == null ? void 0 : _a.trim(); if (linkText == null ? void 0 : linkText.contains("$")) { const sections = mathSplit(linkText); let isMath = false; link.innerText = ""; for (let i = 0; i < sections.length; i++) { if (isMath) { link.createSpan().replaceWith((0, import_obsidian.renderMath)(sections[i], false)); } else { link.createSpan().innerText += sections[i]; } isMath = !isMath; } (0, import_obsidian.finishRenderMath)(); } } function mathSplit(input) { let output = [""]; let backslashes = 0; for (let i = 0; i < input.length; i++) { let curr = input[i]; if (curr == "\\") { backslashes++; } else { for (let j = 0; j < Math.ceil(backslashes / 2); j++) { output[output.length - 1] = output[output.length - 1] + "\\"; } if (curr == "$" && backslashes % 2 == 0) { output.push(""); } else { output[output.length - 1] = output[output.length - 1] + curr; } backslashes = 0; } } return output; } var MathJaxWikiLinks = class extends import_obsidian.Plugin { async onload() { await (0, import_obsidian.loadMathJax)(); this.registerMarkdownPostProcessor((element, context) => { element.querySelectorAll(".internal-link").forEach(convertLink); }); } };