Add macOS BlockMathView using NSViewRepresentable with iosMath - #103
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR replaces the macOS BlockMathView placeholder rendering with an NSViewRepresentable wrapper around iosMath’s MTMathUILabel, aligning macOS behavior with the existing iOS math rendering, and re-enables macOS support in the Swift Package manifest.
Changes:
- Implement
BlockMathViewfor macOS viaNSViewRepresentablebacked byMTMathUILabel. - Switch macOS sizing to use
intrinsicContentSize(instead ofsizeToFit()). - Add
.macOS(.v14)back toPackage.swiftplatforms.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Sources/MarkdownText/UI/BlockMathView.swift | Adds a macOS NSViewRepresentable implementation for block math rendering using iosMath. |
| Package.swift | Re-enables macOS 14+ as a supported platform for the package. |
Replace the macOS placeholder (monospaced Text) with a proper NSViewRepresentable wrapping MTMathUILabel. iosMath already supports macOS via its MTConfig.h typedef layer. Uses intrinsicContentSize instead of sizeToFit since NSView lacks the latter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Jun Yan (junyan72)
force-pushed
the
macos-block-math
branch
from
June 24, 2026 21:00
b0303a7 to
6541311
Compare
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
Replace the macOS placeholder (monospaced
Textshowing raw LaTeX source) with a properNSViewRepresentablewrappingMTMathUILabel. iosMath already supports macOS natively via itsMTConfig.htypedef layer (MTView→NSView,MTColor→NSColor, etc.).NSViewRepresentableimplementation mirroring the iOSUIViewRepresentableversionintrinsicContentSizeinstead ofsizeToFit()sinceNSViewlacks the latter.macOS(.v14)toPackage.swiftplatformsimport iosMathoutside the#ifguard since it compiles on both platformsRefs #92
Validation
xcodebuild build -scheme SwiftStreamingMarkdown -destination 'platform=macOS'— BUILD SUCCEEDEDxcodebuild test -scheme SwiftStreamingMarkdown -destination 'platform=iOS Simulator'— TEST SUCCEEDED (all 68 tests)swiftlint --strict— 0 violationsOSS readiness