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

Multiple bytemd invocations on page confuse mermaid plugin. #4

Closed
kefahi opened this issue Sep 2, 2020 · 4 comments
Closed

Multiple bytemd invocations on page confuse mermaid plugin. #4

kefahi opened this issue Sep 2, 2020 · 4 comments

Comments

@kefahi
Copy link
Contributor

kefahi commented Sep 2, 2020

Hello,

I have a CMS engine, that lists posts with bytemd and mermaid plugin.

Bytemd uses div with a fixed id bytemd-mermaid-${i} where i is the ordinal of mermaid within that bytemd block.

The problem is when there are multiple bytemd-based posts on the same html page they are given the same (conflicting) sequence of div ids. which causes the rendering of mermaid drawings to be badly broken.

My initial fix was to add randomizatoin to that div id as follows bytemd-mermaid-${Math.floor(Math.random()*1000)}-${i}

The problem was solved for me this way; but not sure if this is the best solution; if so would you please consider as a fix and accept the change?

Thanks.

@kefahi kefahi changed the title Multiple bytemd invokations on page confuse mermaid plugin. Multiple bytemd invocations on page confuse mermaid plugin. Sep 2, 2020
@pd4d10
Copy link
Owner

pd4d10 commented Sep 2, 2020

Sounds great. PRs welcome!

@pd4d10
Copy link
Owner

pd4d10 commented Sep 2, 2020

How about using timestamp? Date.now()

kefahi added a commit to kefahi/bytemd that referenced this issue Sep 2, 2020
@kefahi
Copy link
Contributor Author

kefahi commented Sep 2, 2020

How about using timestamp? Date.now()

Sounds even better. PR is done and passed testing.

Thanks!

pd4d10 pushed a commit that referenced this issue Sep 2, 2020
* Randomize the id of mermaid div

This is a fix for issue #4

* Update index.ts
@pd4d10
Copy link
Owner

pd4d10 commented Sep 2, 2020

Thanks! @bytemd/plugin-mermaid v0.1.1 published

@pd4d10 pd4d10 closed this as completed Sep 2, 2020
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

2 participants