This repository was archived by the owner on May 29, 2026. It is now read-only.
fix: revert @muyajs/core to 0.0.39 to unblock Features/Themes preview#103
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Reverts @muyajs/core from 0.1.0 back to 0.0.39 to restore working MarkdownToHtml.renderHtml() behavior, and reintroduces an explicit mermaid dependency + manual rendering path to keep Features/Themes previews rendering diagrams reliably.
Changes:
- Downgrade
@muyajs/coreto^0.0.39and addmermaidas a direct dependency. - Add
rewrapMermaidSource()inmarkdownToHtmlto detect “lost language” mermaid code blocks and wrap them as<div class="mermaid">…</div>. - Reintroduce manual mermaid rendering in
Feature.tsxandTheme.tsx.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/markdownToHtml.ts | Adds a workaround to rewrap mermaid sources when muya/marked loses the code language across calls. |
| src/components/Feature.tsx | Reintroduces mermaid initialization and a mermaid.run() render pass for the Diagram feature. |
| src/components/Theme.tsx | Reintroduces mermaid rendering for the theme preview and attempts to switch mermaid theme based on selected UI theme. |
| package.json | Reverts @muyajs/core version and adds mermaid dependency. |
| pnpm-lock.yaml | Updates lockfile for the dependency revert and reintroduced mermaid dependency. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for (const code of codes) { | ||
| const preEle = code.parentNode as HTMLElement | ||
| const mermaidContainer = document.createElement('div') | ||
| mermaidContainer.innerHTML = code.innerHTML |
Comment on lines
+75
to
+83
| const codes = muyaContainerRef.current.querySelectorAll('code.language-mermaid') | ||
| for (const code of codes) { | ||
| const preEle = code.parentNode as HTMLElement | ||
| const mermaidContainer = document.createElement('div') | ||
| mermaidContainer.innerHTML = code.innerHTML | ||
| mermaidContainer.classList.add('mermaid') | ||
| preEle.replaceWith(mermaidContainer) | ||
| } | ||
| mermaid.init({}, muyaContainerRef.current.querySelectorAll('div.mermaid')) |
Comment on lines
86
to
+95
| const selectTheme = (theme: ThemeItem) => { | ||
| if (/dark/i.test(theme.label)) { | ||
| mermaid.initialize({ | ||
| theme: 'dark' | ||
| }) | ||
| } else { | ||
| mermaid.initialize({ | ||
| theme: 'default' | ||
| }) | ||
| } |
Comment on lines
1210
to
1212
| dompurify@3.3.0: | ||
| resolution: {integrity: sha512-r+f6MYR1gGN1eJv0TVQbhA7if/U7P87cdPl3HN5rikqaBSBxLiCb/b9O+2eG0cxz0ghyU+mU1QkbsOwERMYlWQ==} | ||
|
|
@muyajs/core@0.1.0 ships its mermaid integration as separate ESM chunks that have a circular import between chunk-5ZQYHXKU and mermaid.core. The consumer chunk runs `var Ie = pe()` at module init while `pe` (the default-export of mermaid.core, lazily wrapped through the `t` helper) hasn't been assigned yet, so it throws `TypeError: pe is not a function` inside MarkdownToHtml.renderHtml(). The promise rejects and both Feature.tsx and Theme.tsx fall into their `.catch` branches, rendering "Error rendering content" / "Error rendering theme content" on the live site (https://marktext.me) and any local build using 0.1.0. Revert PR #99 to restore @muyajs/core@^0.0.39, the explicit `mermaid` dependency, and the existing `rewrapMermaidSource` + manual `mermaid.run()` workaround for 0.0.39's walkTokens accumulation bug. Re-upgrade once @muyajs/core ships a release that fixes the circular chunk init. This reverts commit aae5452.
e01b6e3 to
e400860
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MarkdownToHtml.renderHtml()on first call, so the Features and Themes previews render "Error rendering content" / "Error rendering theme content" both locally and at https://marktext.me.mermaiddep and therewrapMermaidSource+ manualmermaid.run()workaround for the pre-existing 0.0.39 walkTokens accumulation bug.Root cause
@muyajs/core@0.1.0ships its mermaid integration as separate ESM chunks with a circular import betweenchunk-5ZQYHXKU-CWjquzqa.mjsandmermaid.core-CXkc5gBm.mjs. The consumer chunk runsvar Ie = pe()at module init, butpe(the default-export ofmermaid.core, lazily wrapped through thethelper) hasn't been assigned yet, so it throwsTypeError: pe is not a functioninsiderenderHtml(). The promise rejects andFeature.tsx/Theme.tsxboth fall into their.catchbranches.Re-upgrade once
@muyajs/coreships a release that fixes the circular chunk init.Test plan
pnpm install --no-frozen-lockfile && pnpm dev— visithttp://localhost:8080, confirm Features (Table/Diagram/Inline/Math/Code) and all six Themes render withoutError rendering ….pnpm build && pnpm preview— same checks on the production build athttp://localhost:4173.pnpm type-checkpasses.🤖 Generated with Claude Code