-
Notifications
You must be signed in to change notification settings - Fork 649
Add support for mermaid
diagrams in README files
#6587
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
Conversation
interesting, I would've thought that this would need backend support, but if we can solve it on the frontend this might be viable. since the majority of README files don't need support for it we should try to load the |
did you mean something like this? Maby i am missing something but for some reason the code tags of the readme variable have empty class attributes so i don't know a way how to check if it contains some mermaid code.
|
very roughly, yes. but we will need to make sure that the loading state stays active until the |
I did miss something... |
How should we handle a dynamic import error? |
Displaying it unmodified is probably fine in this case, but for the next readme that is displayed we probably should retry it. |
would it be ok if I modify the
|
sure, but probably makes sense to have dedicated tests for this and keep the existing ones as they are. |
Do you think we should change the securitylevel to sandBox? Tbh I am not completely sure what it changes. (I couldn't find anything) About the color theme. I don't think it looks very off, so I am not sure if it is necessary to go through all of the options to customize them right now. another thing that should be done at some point would be to add some sort of zoom/scroll possibility for big graphs like in is there anything left I missed and still needs to change? |
This comment was marked as spam.
This comment was marked as spam.
☔ The latest upstream changes (presumably d169e34) made this pull request unmergeable. Please resolve the merge conflicts. |
mermaid
diagrams in README files
@ToBinio I've rewritten the JS portion of this a little bit using an Ember.js "modifier". In the controller we try to load the library, and in the modifier we will use the library (if it has been loaded) to render the diagrams in the README. I'll keep this PR open a for bit longer to let others chime in if they have any concerns with this. I've also enabled the sandbox mode to ensure we don't open any XSS vectors on crates.io. |
There's a relevant discussion in the docs.rs Zulip stream. I don't think exact feature parity between crates.io and docs.rs for README rendering is a hard requirement, but I do wonder if the frontend-only approach is the right one here. |
I'm open to other alternatives... The Zulip stream mentioned that there are no Rust-based mermaid impls though, so I'm not sure what else to use 🤔 |
This is probably just one of my naive ideas. But I just discovered the mermaid.ink project. Which has an API to render mermaid graphs to images. in theory, this could be used. something similar could also be self-hosted but this would increase the complexity immensely and probably not be reasonable |
We discussed this at the team meeting this week, and I feel better about this after the discussion there, particularly since we don't have a viable backend-only alternative right now (not counting |
This PR is a Proof of Concept for the in #5724 requested Mermaid support.
It is supposed to show what would be required to support mermaid (maybe I am also missing some major problem with it)
points to think about:
mermaid.run()
call be improved (not usingsetTimeout()
)note: this is just a quick and dirty PoC implementation and should most definitely not be merged