mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
error handling for Mermaid and Mathjax
This commit is contained in:
parent
1894606c10
commit
2a1cba1fed
@ -9,7 +9,12 @@ var updateHtml = function(html) {
|
|||||||
if (code.parentElement.tagName.toLowerCase() == 'pre') {
|
if (code.parentElement.tagName.toLowerCase() == 'pre') {
|
||||||
if (VEnableMermaid && code.classList.contains('language-mermaid')) {
|
if (VEnableMermaid && code.classList.contains('language-mermaid')) {
|
||||||
// Mermaid code block.
|
// Mermaid code block.
|
||||||
var graph = mermaidAPI.render('mermaid-diagram-' + mermaidIdx++, code.innerText, function(){});
|
try {
|
||||||
|
var graph = mermaidAPI.render('mermaid-diagram-' + mermaidIdx++, code.innerText, function(){});
|
||||||
|
} catch (err) {
|
||||||
|
content.setLog("err: " + err);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var graphDiv = document.createElement('div');
|
var graphDiv = document.createElement('div');
|
||||||
graphDiv.classList.add(VMermaidDivClass);
|
graphDiv.classList.add(VMermaidDivClass);
|
||||||
graphDiv.innerHTML = graph;
|
graphDiv.innerHTML = graph;
|
||||||
@ -24,8 +29,12 @@ var updateHtml = function(html) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VEnableMathjax && (typeof MathJax != 'undefined')) {
|
if (VEnableMathjax) {
|
||||||
MathJax.Hub.Queue(["Typeset", MathJax.Hub, placeholder]);
|
try {
|
||||||
|
MathJax.Hub.Queue(["Typeset", MathJax.Hub, placeholder]);
|
||||||
|
} catch (err) {
|
||||||
|
content.setLog("err: " + err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,11 @@ var updateText = function(text) {
|
|||||||
handleToc(needToc);
|
handleToc(needToc);
|
||||||
renderMermaid('lang-mermaid');
|
renderMermaid('lang-mermaid');
|
||||||
if (VEnableMathjax) {
|
if (VEnableMathjax) {
|
||||||
MathJax.Hub.Queue(["Typeset", MathJax.Hub, placeholder]);
|
try {
|
||||||
|
MathJax.Hub.Queue(["Typeset", MathJax.Hub, placeholder]);
|
||||||
|
} catch (err) {
|
||||||
|
content.setLog("err: " + err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,12 @@ var renderMermaid = function(className) {
|
|||||||
var code = codes[i];
|
var code = codes[i];
|
||||||
if (code.classList.contains(className)) {
|
if (code.classList.contains(className)) {
|
||||||
// Mermaid code block.
|
// Mermaid code block.
|
||||||
var graph = mermaidAPI.render('mermaid-diagram-' + mermaidIdx++, code.innerText, function(){});
|
try {
|
||||||
|
var graph = mermaidAPI.render('mermaid-diagram-' + mermaidIdx++, code.innerText, function(){});
|
||||||
|
} catch (err) {
|
||||||
|
content.setLog("err: " + err);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var graphDiv = document.createElement('div');
|
var graphDiv = document.createElement('div');
|
||||||
graphDiv.classList.add(VMermaidDivClass);
|
graphDiv.classList.add(VMermaidDivClass);
|
||||||
graphDiv.innerHTML = graph;
|
graphDiv.innerHTML = graph;
|
||||||
|
@ -123,7 +123,11 @@ var updateText = function(text) {
|
|||||||
handleToc(needToc);
|
handleToc(needToc);
|
||||||
renderMermaid('lang-mermaid');
|
renderMermaid('lang-mermaid');
|
||||||
if (VEnableMathjax) {
|
if (VEnableMathjax) {
|
||||||
MathJax.Hub.Queue(["Typeset", MathJax.Hub, placeholder]);
|
try {
|
||||||
|
MathJax.Hub.Queue(["Typeset", MathJax.Hub, placeholder]);
|
||||||
|
} catch (err) {
|
||||||
|
content.setLog("err: " + err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ language=System
|
|||||||
editor_font_size=12
|
editor_font_size=12
|
||||||
; 0 - Hoedown, 1 - Marked, 2 - Markdown-it
|
; 0 - Hoedown, 1 - Marked, 2 - Markdown-it
|
||||||
markdown_converter=2
|
markdown_converter=2
|
||||||
enable_mermaid=true
|
enable_mermaid=false
|
||||||
enable_mathjax=true
|
enable_mathjax=false
|
||||||
|
|
||||||
[session]
|
[session]
|
||||||
tools_dock_checked=true
|
tools_dock_checked=true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user