Skip to content

1.3.4: share view layer between mrkd and QL, add test suite#16

Merged
jahala merged 1 commit into
masterfrom
jahala/viewmd-feature-catalog
May 14, 2026
Merged

1.3.4: share view layer between mrkd and QL, add test suite#16
jahala merged 1 commit into
masterfrom
jahala/viewmd-feature-catalog

Conversation

@jahala

@jahala jahala commented May 14, 2026

Copy link
Copy Markdown
Owner

What

  • Shared MarkdownViewController between the mrkd app and QL extension. QL preview now has TOC sidebar, article-width cap, themed Open button hover, fragment links, scroll-position sync — all from the same view layer the main app uses.
  • ThemeManager reads route through CFPreferences (process-independent) so the sandboxed QL extension reads the same prefs as the main app.
  • PreviewViewController went from 263 lines to 53. ~210 lines of duplicate code deleted.
  • Added a test suite under Sources/Tests/ — 47 cases covering all the shared engine functions and view-layer integration points.
  • release.yml now runs swift test before the Release build so failing tests block the release.

Test plan

  • Tests pass locally: swift test reports 47 / 0 / 0.04s.
  • Xcode build succeeds: xcodebuild -scheme mrkd build.
  • Local Debug install renders QL preview with TOC sidebar when panel is wider than 1280pt.

🤖 Generated with Claude Code

…uite (1.3.4)

Refactor — pure consolidation, ~210 lines deleted:
- ThemeManager preference reads now route through CFPreferencesCopyAppValue
  with the main app's bundle ID rather than UserDefaults.standard. The QL
  extension's sandbox has its own UserDefaults domain (empty for these
  keys) but reads the same on-disk plist via CFPreferences as the main
  app. Setters keep the UserDefaults + persistPref pair so the main
  app's in-process cache stays warm.
- project.yml's QLPlugin target now compiles Sources/UI/MarkdownViewController
  and its dependencies (TOCFloatingView, OpenWithButton, ReloadBannerView,
  TextInteractionHandler, FragmentLinkHandler, FontSizeManager) plus
  Sources/Platform/FileWatcher. Same source files, two targets.
- PreviewViewController slimmed from 263 → 53 lines. It hosts a
  MarkdownViewController as a child VC; everything else (theme
  resolution, scroll view, render, themed Open button) comes from the
  shared MVC.
- AppDelegate's first-render hook decoupled from MarkdownViewController
  via NotificationCenter so MVC compiles into both targets.
- QL preview now inherits: TOC sidebar, article-width cap, themed
  Open button with hover, fragment link resolution, scroll-position
  sync, smart typography, code-block fixes — without per-target drift.

Tests added — Sources/Tests/, 47 cases passing:
- BlockSplitter: fence-aware splitting, blank-line handling.
- SmartTypography: quotes / em-dash / en-dash / ellipsis curling,
  skip rules for code spans / fenced blocks / link URLs / GFM tables.
- FragmentLinkHandler: GitHub-style slug, idempotence, lookup.
- TOCBuilder: heading extraction order and trimming.
- MarkdownRenderer: heading-level attributes, smart-typo opt-out,
  leading-newline strip in code blocks.
- ThemeManager: CFPreferences fallback + actual read of user-set
  preferences (validates the migration above).
- MarkdownViewController: init from URL + loadView smoke tests.
- PreviewHostingContract: end-to-end render → TOCBuilder pipeline
  matches between main app and QL preview.

CI:
- release.yml now runs `swift test` before xcodebuild Release. Failing
  tests block the release.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jahala jahala merged commit cbfb10f into master May 14, 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