Repository navigation
fix(muyajs): preserve nested lists of differing types (#4341) - #4354
Merged
Merged
Conversation
The legacy muya lexer rewrote any nested list whose type differed from its parent (e.g. a ul inside an ol li, or vice versa) into a paragraph, silently dropping the list structure on import. The guard was added in the electron-vite refactor (#4001, commit 85607dd) and is unrelated to sibling mixed lists, which are correctly handled by the in-loop branch at lexer.js:419-453. Remove it so CommonMark-compliant nested mixed lists round-trip and render correctly. Tests: - New vitest spec round-trips ul-in-ol and ol-in-ul and inspects the block tree to assert a nested ul block exists inside the ol li. - New fixture-render Playwright spec loads a mixed-nested fixture and asserts `.editor-component ol li ul li` (and ul li ol li) DOM shape. - The existing `Lists` fixture in test/unit/data/common/Lists.md now separates the deeply-nested ordered sub-list from its sibling text with a blank line, matching the canonical loose-form serialization the exporter produces for a loose-parent context. Fixes #4341 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Website preview ready: https://pr-4354-marktext-website.ransixi.workers.dev Built from |
|
Build artifacts for PR #4354: Run: https://github.com/marktext/marktext/actions/runs/26861390540
|
thimbleberrysystems
pushed a commit
to thimbleberrysystems/WordBird
that referenced
this pull request
Jun 21, 2026
The legacy muya lexer rewrote any nested list whose type differed from its parent (e.g. a ul inside an ol li, or vice versa) into a paragraph, silently dropping the list structure on import. The guard was added in the electron-vite refactor (marktext#4001, commit 5729066) and is unrelated to sibling mixed lists, which are correctly handled by the in-loop branch at lexer.js:419-453. Remove it so CommonMark-compliant nested mixed lists round-trip and render correctly. Tests: - New vitest spec round-trips ul-in-ol and ol-in-ul and inspects the block tree to assert a nested ul block exists inside the ol li. - New fixture-render Playwright spec loads a mixed-nested fixture and asserts `.editor-component ol li ul li` (and ul li ol li) DOM shape. - The existing `Lists` fixture in test/unit/data/common/Lists.md now separates the deeply-nested ordered sub-list from its sibling text with a blank line, matching the canonical loose-form serialization the exporter produces for a loose-parent context. Fixes marktext#4341 Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
ulnested inside anolli(and vice versa) was being silently rewritten as a paragraph by the legacy muya lexer, losing the list structure on import.packages/muyajs/lib/parser/marked/lexer.js:350-365(introduced in the electron-vite refactor Re-Factor MarkText with electron-vite #4001, commit85607dd2) treated any nested list whose type differed from its enclosing list as a paragraph. Sibling mixed lists are handled by a separate code path (lexer.js:419-453) and were unaffected.Tests
packages/desktop/test/unit/specs/markdown-nested-mixed-lists.spec.ts) — round-tripsul-in-olandol-in-ul, plus a structural check that the imported block tree actually contains a nestedulinside theol li(rather than a paragraph). Confirmed RED ondevelop, GREEN after the fix.packages/desktop/test/e2e/data/nested-mixed-lists.md+ a newrunFixture('nested-mixed-lists', ...)block infixture-render.spec.ts) — loads the fixture in the Electron window and asserts.editor-component ol li ul li(and the inverse) DOM shape. Confirmed RED ondevelop, GREEN after the fix.Lists.mdfixture adjustment — the deeply-nested ordered sub-list inside a*item now has a blank line before it. This brings the input in line with the canonical loose-form serialization the exporter emits for a loose-parent context; without this, the previous test was only passing because the buggy parser was collapsing that nested list into a paragraph.Test plan
pnpm -C packages/desktop run test:unit— 553 passed (10 files), incl. the new spec.pnpm -C packages/desktop exec playwright test test/e2e/fixture-render.spec.ts— 10/10 passed.pnpm -C packages/desktop exec playwright test test/e2e/paragraph-blocks.spec.ts test/e2e/editor-input.spec.ts— 13 passed, 2 pre-existing skips.pnpm run lint— 0 errors (existing warnings unchanged).pnpm run typecheck— clean.pnpm run dev, confirm the inner bullets and numbers render as nested lists (not paragraph text), and that theListsfixture still renders the deeply-nested case correctly.🤖 Generated with Claude Code