stackedit.js icon indicating copy to clipboard operation
stackedit.js copied to clipboard

Mermaid and Katex not rendered

Open rhinenoir opened this issue 7 years ago • 4 comments

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&#10;A --&gt; C&#10;</code></pre>&#10;
  • expected result: complete mermaid svg code instead of original code style

rhinenoir avatar Mar 22 '18 12:03 rhinenoir

any plan to fix the bug?

rhinenoir avatar Apr 12 '18 06:04 rhinenoir

Same problem. @GARENFEATHER What does your code do? Were you successful getting SVG of the mermaid markdown with the above code?

para2402 avatar Apr 26 '18 19:04 para2402

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.

para2402 avatar Apr 27 '18 22:04 para2402

@benweet so any plan to fix the bugs?

rhinenoir avatar Jun 30 '18 19:06 rhinenoir