Skip to content

fix(editor): render paired inline HTML tags#550

Merged
murongg merged 2 commits into
mainfrom
fix/issue-543-inline-html
Jul 17, 2026
Merged

fix(editor): render paired inline HTML tags#550
murongg merged 2 commits into
mainfrom
fix/issue-543-inline-html

Conversation

@murongg

@murongg murongg commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • render balanced source-authored inline HTML pairs such as <sup>...</sup> as real inline elements in the visual editor
  • preserve the underlying HTML boundary nodes so nested Markdown remains editable and serialization/reload stay unchanged
  • preserve soft line breaks before inline HTML when the visual editor serializes back into the source pane
  • reuse the existing raw HTML sanitizer for URLs and attributes, while leaving malformed and block-level boundaries on their current path

Why

Milkdown represents inline raw HTML as separate opening and closing atoms. Rendering each atom independently made opening tags disappear and closing tags fall back to visible source.

The Markdown stringifier also normalizes a soft break immediately before an HTML node into a space. In split mode, the deferred visual update then wrote that normalized line back to the source pane. This PR marks single-line HTML tokens only while stringifying so their original line breaks survive without changing the ProseMirror document.

Validation

  • pnpm test passed: 2,412 tests
  • pnpm build passed, including desktop vendor chunk verification
  • pnpm --filter @markra/app typecheck:test passed
  • focused inline HTML, raw HTML, and line-break integration tests passed: 7 tests

Risk

  • paired rendering is limited to a strict inline-tag allowlist
  • rendered attributes pass through the existing sanitizer; unsafe URLs and event attributes remain removed
  • the serializer marker is limited to non-empty, single-line HTML source; multiline block HTML keeps the existing serialization path

Note

&#x20; is the Markdown serializer preserving a trailing space and reproduces without HTML. This PR does not strip it because doing so would make source round-trips lossy.

Closes #543

Render balanced inline HTML through view decorations so nested Markdown remains editable and source serialization stays unchanged. Reuse the existing raw HTML sanitizer for inline attributes.

Closes #543
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
markra-web Ready Ready Preview, Comment Jul 17, 2026 5:59am

@murongg
murongg merged commit 5513ae2 into main Jul 17, 2026
21 checks passed
@murongg
murongg deleted the fix/issue-543-inline-html branch July 17, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: html标签不能正常渲染

1 participant