Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to integrate with markdown-it as plugin #9

Open
julianlam opened this issue Jul 2, 2019 · 3 comments
Open

Unable to integrate with markdown-it as plugin #9

julianlam opened this issue Jul 2, 2019 · 3 comments

Comments

@julianlam
Copy link

julianlam commented Jul 2, 2019

Hi there. Looking at #4, I was able to get the plugin registered with markdown-it, but as it stands right now it is not doing anything.

Here is my code:

// `parser` is the object you get from `new MarkdownIt()`
parser.use(require('markdown-it-mermaid').default);

console.log(parser.render(`\`\`\`mermaid
graph TD
	A[Christmas] -->|Get money| B(Go shopping)
	B --> C{Let me think}
	C -->|One| D[Laptop]
	C -->|Two| E[iPhone]
	C -->|Three| F[Car]
\`\`\``));

The following code is output:

<div class="mermaid">graph TD
        A[Christmas] -->|Get money| B(Go shopping)
        B --> C{Let me think}
        C -->|One| D[Laptop]
        C -->|Two| E[iPhone]
        C -->|Three| F[Car]</div>

So it doesn't look like it's generating any SVG code... unless I am misunderstanding something with the implementation?

Thanks for any help you can provide!

@KCErb
Copy link

KCErb commented Jun 2, 2020

This means mermaid.initialize is not being called at a point where that div is actually in the DOM.

@EverSeenTOTOTO
Copy link

EverSeenTOTOTO commented Jun 25, 2021

I'm using [email protected], it seems there is a init method need to be call...

// each time when dom is changed: 
mermaid.initialize({
      // startOnLoad: true,
      theme: 'default',
      gantt: {
        axisFormatter: [
          ['%Y-%m-%d', (d) => {
            return d.getDay() === 1;
          }],
        ],
      },
    });
mermaid.init();

@PeterWone
Copy link

PeterWone commented Nov 7, 2023

See mermaid-js/mermaid#3886

They won't fix it because without a browser they can't measure label strings in the layout engine. If you ask me, CSS control for font-family and font-size is far less important that being able to run headless, but it's not my project and if I forked it to impose common sense, I would then be saddled with maintaining it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants