-
Notifications
You must be signed in to change notification settings - Fork 112
🧜♀️ Create images of mermaid diagrams for static exports #2132
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'myst-common': patch | ||
| --- | ||
|
|
||
| Added `options?: PluginOptions` to `TransformSpec` type. Enables passing configuration options to transform plugins. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| 'myst-cli': patch | ||
| --- | ||
|
|
||
| Integrated transform loading from options with proper plugin utilities. | ||
|
|
||
| Added mermaid transform import and configuration | ||
| Integrated mermaid transform into Typst build pipeline. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'myst-spec-ext': patch | ||
| --- | ||
|
|
||
| Added `label`, `identifier`, and `html_id` to `Image` type |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,3 +24,32 @@ flowchart LR | |
| :::{note} | ||
| Both GitHub and JupyterLab ([#101](https://github.com/jupyter/enhancement-proposals/pull/101)) support the translation of a code-block ` ```mermaid ` to a mermaid diagram directly, this can also be used by default in MyST. | ||
| ::: | ||
|
|
||
| ## Rendering for Static Exports | ||
|
|
||
| MyST supports static rendering of Mermaid diagrams for static export formats (PDF, Word, LaTeX, Typst). This feature converts Mermaid syntax to base64-encoded SVG or PNG images during the build process, ensuring consistent rendering across all static output formats. | ||
|
|
||
| :::{important} Prerequisites | ||
| To use static Mermaid rendering, you need the Mermaid CLI installed: | ||
|
|
||
| ```bash | ||
| npm install -g @mermaid-js/mermaid-cli | ||
| ``` | ||
|
|
||
| ::: | ||
|
|
||
| :::{note .dropdown} For CI Environments | ||
|
|
||
| The Mermaid CLI uses Puppeteer which may require special configuration in CI environments. MyST automatically handles this by detecting the `CI` environment variable or you can manually control it: | ||
|
|
||
| ```bash | ||
| # Automatic detection (recommended for CI) | ||
| CI=true npm run build | ||
|
|
||
| # Manual control | ||
| MERMAID_NO_SANDBOX=true npm run build | ||
| ``` | ||
|
Comment on lines
+45
to
+51
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI was way harder to get going than I thought. Should be automatic now though!
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
|
||
| This automatically creates a Puppeteer configuration file with `--no-sandbox` flag to resolve sandbox issues in Linux CI environments. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, this answers part of my question from above. Does generating the config equate to disabling the sandbox? If so, maybe something like:
|
||
|
|
||
| ::: | ||
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.
What is being handled here?
The example is a bit confusing, because
CIis already set on both GH and GitLab, so user would never set it themselves.