Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Web: add mermaid diagram rendering#62678

Merged
camdencheek merged 9 commits into
mainfrom
cc/render-mermaid
May 16, 2024
Merged

Web: add mermaid diagram rendering#62678
camdencheek merged 9 commits into
mainfrom
cc/render-mermaid

Conversation

@camdencheek

@camdencheek camdencheek commented May 14, 2024

Copy link
Copy Markdown
Member

This adds rendering for mermaid diagrams to the web app (both React and Svelte). We do not do this on the backend because mermaid is a JS library. This was not planned work, but it's been requested enough and is easy enough that I figured it was worth a couple hours to slot it in.

Related Slack thread

Test plan

Manual testing. See demo video.

@cla-bot cla-bot Bot added the cla-signed label May 14, 2024
@camdencheek camdencheek changed the title add mermaid diagram rendering Svelte: add mermaid diagram rendering May 14, 2024
@camdencheek camdencheek changed the title Svelte: add mermaid diagram rendering Web app: add mermaid diagram rendering May 15, 2024
@camdencheek camdencheek changed the title Web app: add mermaid diagram rendering Web: add mermaid diagram rendering May 15, 2024

var (
chromaOnly = regexp.MustCompile(`^(?:chroma-[a-zA-Z0-9\-]+)|chroma$`)
chromaOnly = regexp.MustCompile(`^(?:chroma-[a-zA-Z0-9\-]+)|chroma|language-[a-zA-Z]+$`)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

GoldMark already adds a class="language-mermaid", but we were stripping that during sanitization

@camdencheek camdencheek marked this pull request as ready for review May 15, 2024 16:42
@camdencheek camdencheek requested review from a team and removed request for a team May 15, 2024 16:56
@peterguy peterguy linked an issue May 15, 2024 that may be closed by this pull request
@peterguy

peterguy commented May 15, 2024

Copy link
Copy Markdown
Contributor

Screenshot 2024-05-15 at 13 56 13

Screenshot 2024-05-15 at 13 55 57

Examples of light and dark mode in Chrome. Firefox looks similar.

@peterguy peterguy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The render in dark mode isn't great (see previous comment for screenshot), but this otherwise looks a-ok!

@camdencheek

Copy link
Copy Markdown
Member Author

@peterguy good catch on dark mode! I updated the PR to also support dark mode (at least somewhat). It doesn't live-update when the theme changes because that would take a bit more work to manually specify the theme, but it does at least use the theme you have configured.

screenshot-2024-05-16_14-39-18@2x

@camdencheek camdencheek merged commit d84fdc5 into main May 16, 2024
@camdencheek camdencheek deleted the cc/render-mermaid branch May 16, 2024 18:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render Mermaid diagrams in markdown files

2 participants