Skip to content

[shared] Foldable code blocks in preview and Live Preview#300

Merged
Shpigford merged 1 commit into
mainfrom
fold-code-blocks
Apr 29, 2026
Merged

[shared] Foldable code blocks in preview and Live Preview#300
Shpigford merged 1 commit into
mainfrom
fold-code-blocks

Conversation

@Shpigford

Copy link
Copy Markdown
Owner

Summary

  • Adds a per-block fold chevron in the WKWebView preview (Mac + iOS) and CodeMirror Live Preview, with lang · first line · +N more lines summaries.
  • Persists fold state per-file across reopens, keyed by heading-scoped index ({headingPath, indexUnderHeading}) so unrelated edits don't lose state.
  • Mac and iOS share a new PreviewUserScripts injector; Live Preview uses CodeMirror's foldService over FencedCode nodes; PDF export and QuickLook always render expanded.

Test plan

  • Preview (⌘2) on demo.md: click chevron on each block, verify the right block folds and the summary shows lang + first line + count.
  • Switch files / quit and relaunch: folded blocks stay folded.
  • Live Preview: fold a block, type elsewhere — block stays folded; renaming the enclosing heading expands it.
  • iOS simulator: chevron is tappable, folds persist.
  • Export PDF and QuickLook a file with folded blocks: both render fully expanded.

Fixes #297

Adds a per-block fold chevron in the WKWebView preview (Mac + iOS) and the
CodeMirror Live Preview, with persistence keyed by heading-scoped index per
file. Folded preview blocks show a `lang · first line · +N more` summary;
Live Preview folds via CodeMirror's foldService over FencedCode nodes.
PDF export and QuickLook always render expanded.

Fixes #297
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying clearly with  Cloudflare Pages  Cloudflare Pages

Latest commit: b98c31a
Status: ✅  Deploy successful!
Preview URL: https://4644dcca.clearly-cjz.pages.dev
Branch Preview URL: https://fold-code-blocks.clearly-cjz.pages.dev

View logs

@Shpigford
Shpigford merged commit 60e5eae into main Apr 29, 2026
4 checks passed
@Shpigford
Shpigford deleted the fold-code-blocks branch April 29, 2026 19:12
Shpigford added a commit that referenced this pull request Apr 29, 2026
Adds a per-block fold chevron in the WKWebView preview (Mac + iOS) and the
CodeMirror Live Preview, with persistence keyed by heading-scoped index per
file. Folded preview blocks show a `lang · first line · +N more` summary;
Live Preview folds via CodeMirror's foldService over FencedCode nodes.
PDF export and QuickLook always render expanded.

Fixes #297
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.

Fold Large Code Blocks

1 participant