stackedit.js
stackedit.js copied to clipboard
Mermaid and Katex not rendered
my code for replacing mermaid content:
const mermaidNodes = document.getElementsByClassName('language-mermaid');
const stackedit = new Stackedit();
for(var node of mermaidNodes) {
var fileName = Math.random().toString(36).substring(2, 10);
var completeContent = '\`\`\`mermaid\n' + node.innerText + '\n\`\`\`';
console.log(completeContent);
stackedit.openFile({
name: fileName,
content: {
text: completeContent,
properties: {
extensions: {
mermaid: {
enabled: true
}
}
}
}
}, true);
stackedit.on('fileChange', (file) => {
console.log(file.content.html);
});
}
- console.log(completeContent); got sth like:
graph LR
A --> B
graph TD
A --> C
- console.log(file.content.html); got sth like:
<pre><code class="prism language-mermaid">graph TD A --> C </code></pre>
- expected result: complete mermaid svg code instead of original code style
any plan to fix the bug?
Same problem. @GARENFEATHER What does your code do? Were you successful getting SVG of the mermaid markdown with the above code?
I found a workaround for the problem. I searched for all KaTeX and mermaid HTML elements, and rendered them using Katex and mermaid libraries. Code is here https://github.com/jaipara/StackeditJS-example.git
Hope it helps.
@benweet so any plan to fix the bugs?