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

The exported svg has the same className, resulting in style overwriting #2254

Open
Sayi opened this issue Dec 17, 2024 · 4 comments
Open

The exported svg has the same className, resulting in style overwriting #2254

Sayi opened this issue Dec 17, 2024 · 4 comments

Comments

@Sayi
Copy link

Sayi commented Dec 17, 2024

When I use d2 to generate svg, the svg string always has the same class:

<svg id="d2-svg" class="d2-1016141690"

When I display multiple svgs on the same html page, the styles will interfere with each other.

How can I specify that each svg generates a unique class?

Thanks.

@cyborg-ts cyborg-ts added this to D2 Dec 17, 2024
@Sayi
Copy link
Author

Sayi commented Dec 17, 2024

Some styles defined in svg will also be messed up and seem to be not isolated:

.light-code {
display: none
}

.dark-code {
display: block
}

and the html page like this:

<svg id="d2-svg" ...
<svg id="d2-svg" ...
<svg id="d2-svg" ...
<svg id="d2-svg" ...
<svg id="d2-svg" ...

image

@Sayi
Copy link
Author

Sayi commented Dec 17, 2024

use <img src="11.svg"/> will ok, but use svg will failed~~

@alixander
Copy link
Collaborator

@Sayi

<svg id="d2-svg" class="d2-1016141690"

The d2-xxxx should be a unique hash based on some markers of the diagram. So only the same two diagrams will use the same class, which overwriting css is fine. Are you seeing a case where two different diagrams have the same hash? If so, that is a bug and I'd love to see what produced it

@stereobooster
Copy link

So only the same two diagrams will use the same class, which overwriting css is fine. Are you seeing a case where two different diagrams have the same hash? If so, that is a bug and I'd love to see what produced it

dark and light version of the same diagram. Example here at the bottom https://beoe.stereobooster.com/start-here/dark-scheme/

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

No branches or pull requests

3 participants