-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add mermaid support #5383
Add mermaid support #5383
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work. One niche issue:
- When changing dark/light mode, the mermaid.js stuff is not update to dark/light mode: it needs a hard refresh.
Would it be an idea to include a basic test for the markdown stuff so it doesn't break unnoticed? Something like:
kramdown_test.rb
require 'test_helper'
class KramdownTest < Minitest::Test
include ApplicationHelper
def test_mermaid_works
markdown = <<~EOS
This is an example of codeblocks using mermaid:
```mermaid
graph TD;
MoreUsers-->MorePipeline;
MorePipeline-->MoreRevenue;
MoreRevenue-->MoreFeatures;
MoreFeatures-->MoreUsers;
```
EOS
expected_html = <<~EOS
<p>This is an example of codeblocks using mermaid:</p>
<div class="mermaid">graph TD;
MoreUsers-->MorePipeline;
MorePipeline-->MoreRevenue;
MoreRevenue-->MoreFeatures;
MoreFeatures-->MoreUsers;
</div>
EOS
actual_html = markdown_unsafe(markdown)
assert_equal expected_html, actual_html
end
end
This has a way bigger impact than I expected. We should discuss if we really want to add this. Unfortunately, there doesn't seem to be a server-side option. |
@niknetniko I will add the test, thanks :) @bmesuere I'll drop by to discuss |
This pull request adds support for mermaid in dodona.
It adds mermaid as a js dependency. In the backend I added a custom kramdown modification based on this gitlad_kramdown commit.
I prefer this custom solution over using gitlab_kramdown because I was not able to disable the gitlab specific references.
Mermaid js is a relevant increase in our js package size
But this impact is limited as everything is dynamically loaded. Nothing is loaded when no mermaid graphs are on the page.
In most examples I tried, only the package 9465 (674kb unminimized and 295kb minimized) was ever loaded. This package contains the main mermaid and some d3 code.
The packages containing cytoscape and elkjs are probably only loaded for specific graphs when needed.
Closes #4168