提交
This commit is contained in:
@@ -32,17 +32,21 @@ function stripLatexDelimiters(latex) {
|
||||
.trim();
|
||||
}
|
||||
|
||||
/** 块/行内统一用 $$ 渲染,保证公式大小一致;排版由 data-wrap + CSS 控制 */
|
||||
function buildLatexContentForRender(latex) {
|
||||
/** 按 data-wrap 选择行内 $ 或块级 $$ 分隔符 */
|
||||
function buildLatexContentForRender(latex, wrapMode) {
|
||||
const raw = stripLatexDelimiters(latex);
|
||||
if (!raw) return '';
|
||||
if (wrapMode === 'inline') {
|
||||
return '$' + raw + '$';
|
||||
}
|
||||
return '$$' + raw + '$$';
|
||||
}
|
||||
|
||||
function prepareWmathElement(element) {
|
||||
const latexContent = element.getAttribute('data-latex');
|
||||
if (!latexContent) return;
|
||||
element.innerHTML = buildLatexContentForRender(latexContent);
|
||||
const wrap = element.getAttribute('data-wrap') || 'block';
|
||||
element.innerHTML = buildLatexContentForRender(latexContent, wrap);
|
||||
}
|
||||
|
||||
// **定义全局渲染方法**
|
||||
|
||||
Reference in New Issue
Block a user