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

Mermaid Support #165

Merged
merged 8 commits into from
Aug 27, 2024
Merged

Mermaid Support #165

merged 8 commits into from
Aug 27, 2024

Conversation

jannis-baum
Copy link
Owner

@jannis-baum jannis-baum commented Aug 26, 2024

Close #132

Mermaid is incredibly annoying to run server-side and it seems they really don't want people to do this. So I ended up making it run client-side by symlinking the Node module into the static/ directory. And turns out the same thing works for Katex, so I did it there as well which cleaned up our repo quite nicely

The client-side parsing on the other hand is very easy to implement, I just followed this example and created the class="mermaid" containers analogously to how we parse Dot/Graphviz.

One consideration might be to let people have Mermaid configuration but it seems that there is quite a bit in those configuration options that can break things so I would hold off on it until someone asks for it.

@jannis-baum jannis-baum marked this pull request as ready for review August 26, 2024 15:27
Copy link
Collaborator

@tuurep tuurep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok looks great, other than the colors on dark theme

image

But I'd say the same goes for "Dot" so if that can be changed as well, I'll give this an 'Approve' in case we want to do those as a separate effort?

@jannis-baum
Copy link
Owner Author

jannis-baum commented Aug 26, 2024

Just for keeping protocol here as well: I added automatic theming, it will now use dark for dark mode and default for light mode. Drawback is that we can't dynamically change this, the page has to be reloaded. Making it change dynamically would be quite hacky so I'd avoid it (at least for now)

EDIT: of course we could always make the whole page reload when the theme changes but I don't know if that's worth it just for this

@jannis-baum jannis-baum force-pushed the issue/132-mermaid-support branch from a959f7a to 1d24c15 Compare August 26, 2024 16:32
@jannis-baum
Copy link
Owner Author

Update: I changed it so that the page refreshes now when the theme changes and there is Mermaid content

@tuurep
Copy link
Collaborator

tuurep commented Aug 26, 2024

Nice approach!

I am quite unable to test this as my system doesn't have a concept of prefers dark/light I think..

Or if you know an alternative way to test if this works, let me know.

(I've had a habit to rebuild the whole thing whenever I make any changes, including CSS. Should probably get better habits.)

@jannis-baum jannis-baum merged commit 9c5f1ff into main Aug 27, 2024
6 checks passed
@jannis-baum jannis-baum deleted the issue/132-mermaid-support branch August 27, 2024 23:44
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

Successfully merging this pull request may close these issues.

Mermaid Support
2 participants