Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

CSS option does not properly apply the CSS to the SVG #17

Closed
kellerj opened this issue Nov 7, 2017 · 5 comments
Closed

CSS option does not properly apply the CSS to the SVG #17

kellerj opened this issue Nov 7, 2017 · 5 comments

Comments

@kellerj
Copy link

kellerj commented Nov 7, 2017

In the mermaid setup, the choice of theme pulls one of the CSS files from the mermaid install during the process into the style element of the SVG tag. The existing logic in the CLI pulls the CSS into the style sheet of the surrounding HTML page.

To make the CSS apply, this CSS needs to replace the CSS inside the SVG. I was able to make this work by adding the code below after the window.mermaid.init(undefined, container) call so as to replace CSS embedded in there by mermaid with the desired style sheet.

I don't know the setup well enough to know how brittle this is. But it did work.

    if (myCSS) {
      window.document.getElementById('mermaidChart0').getElementsByTagName('style')[0].innerHTML = myCSS;
    }
@kellerj
Copy link
Author

kellerj commented Nov 7, 2017

#18 Applies this proposed change

@agusmba
Copy link
Contributor

agusmba commented Nov 14, 2017

Thinking again about this, I see the css config as the "recommended" way of adding css (as seen in the mermaid docs.)

That said, the themes in mermaid have some bugs, and overriding them could be a way of fixing them. Maybe your approach could be an additional option on the cli: "-T" = "--customTheme"?

@tylerlong what do you think?

@kellerj
Copy link
Author

kellerj commented Nov 18, 2017

An additional CLI option works for me. I'll work on making that as the change instead of replacing the internal CSS. (I admit - I'm not sure of the relationship between CSS outside the SVG element and that inside and how they affect each other. Though - it's clear that they do.)

@tylerlong
Copy link
Contributor

I want to fix this issue in the mermaid project. So that there is a mermaid option which allows you to specify a custom theme.

@tylerlong
Copy link
Contributor

Please refer to #24 (comment)

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

No branches or pull requests

3 participants