版本比较
在 vscode 中使用洛谷的 markdown 新语法
正文
增加 6 行删除 6 行
23 行未改动24252627282829303132333435353637383926 行未改动666768697070717273737475767789 行未改动16716816917017117117217317417571 行未改动24724824925025125125225325425533 行未改动23 行未改动 const stack = []; let hasMathInTitle = false;
const defaultTitles = { 'info': '提示', 'success': '成功', 'warning': '警告', 'info': '提示', 'success': '成功', 'warning': '警告', 'danger': '错误', 'error': '错误' };
// 增强版行内解析:增加数学公式保护逻辑 const miniParse = (str) => { if (!str) return str;
// 1. 识别并提取数学公式,用占位符替代,防止其中的 _ 或 * 被误标记 const mathBlocks = []; let processedStr = str.replace(/\$(.*?)\$/g, (match) => { hasMathInTitle = true;26 行未改动 if (startMatch) { const type = startMatch[2].toLowerCase(); const capturedTitle = startMatch[3]; const isOpen = startMatch[4] === 'open' ? 'open' : '';
let displayTitle = capturedTitle !== undefined ? capturedTitle : (defaultTitles[type] || type.toUpperCase()); displayTitle = miniParse(displayTitle);
stack.push(true); result.push(`<details ${isOpen} class="mpe-container ${type}"><summary class="mpe-container-title"><span>${displayTitle}</span></summary>\n`); } else if (endMatch && stack.length > 0) { stack.pop();89 行未改动 ----------------------------------------------------------- */
/* 针对 details 内部除了 summary 以外的所有元素 */.mpe-container > *:not(.mpe-container-title) { color: #000000; color: #000000; font-size: 0.95em; line-height: 1.6;}
71 行未改动.mpe-container-title em,.mpe-container-title code,.mpe-container-title .katex { /* 关键:强制继承父级(即 .mpe-container-title)的颜色 */ color: inherit !important; color: inherit !important; /* 确保公式和加粗的对比度 */ opacity: 1;}
33 行未改动