Skip to content

Fix Prism resources after initial preview render#427

Open
mrrnb wants to merge 2 commits into
schuyler:mainfrom
mrrnb:fix-initial-prism-highlight
Open

Fix Prism resources after initial preview render#427
mrrnb wants to merge 2 commits into
schuyler:mainfrom
mrrnb:fix-initial-prism-highlight

Conversation

@mrrnb
Copy link
Copy Markdown

@mrrnb mrrnb commented May 6, 2026

Summary

  • Tracks the generated preview resource signature (<head> plus script tags) before using body-only DOM replacement.
  • Falls back to a full preview reload when CSS or script resources change, including newly discovered Prism language scripts.
  • Fixes the first-open path where an early empty preview kept a stale script set until the user clicked Rendering → Reload.

Testing

  • xcodebuild -quiet -workspace "MacDown 3000.xcworkspace" -scheme MacDown -configuration Release -destination 'platform=macOS,arch=arm64' build\n- Installed the Release app locally at /Applications/MacDown 3000.app.\n- Verified with a temporary DOM dump that first open includes prism-bash.min.js, span.token elements, and the Bash show-language label without pressing Reload.

mrrnb added 2 commits May 6, 2026 16:52
- 在预览 WebView 主 frame 完成加载后显式调用 Prism.highlightAll()
- 让首次打开 Markdown 的代码块高亮行为与设置里 Reload 后保持一致
- 已验证 Release 构建通过,并安装到本机 /Applications/MacDown 3000.app
- 比较预览 HTML 的 head 与 script 标签资源签名
- 当 Prism 语言脚本等资源变化时跳过 body-only DOM replacement,避免沿用旧脚本集合
- 已用临时 DOM dump 验证首次打开包含 prism-bash、token span 与 Bash 语言标签
- 已验证 Release 构建通过,并安装到本机 /Applications/MacDown 3000.app
@mrrnb mrrnb changed the title Fix Prism highlighting after initial preview load Fix Prism resources after initial preview render May 6, 2026
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.

1 participant