microsoft / microsoft/SwiftStreamingMarkdown
[Bug]: Inline LaTeX shows an opaque white fallback in SwiftUI List
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 364
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
Description
Summary
Inline LaTeX can render with an opaque white rectangle (or a generic document-like placeholder) behind the formula when the Markdown document is hosted in a SwiftUI List. The same content renders correctly in a ScrollView. The issue is intermittent and can disappear after leaving the screen and opening it again.
Minimal markdown input
- \(a, b, c\): coefficients in \(ax^2 + bx + c = 0\).
- If \(b^2 - 4ac > 0\), the equation has two distinct real roots.
- \(\sqrt{b^2 - 4ac}\) is the square root of the discriminant.
Platform
iOS
Expected behavior
Inline formulas should render with their configured text color and a transparent background in both containers. The rendering should remain stable when List rows are reused, when scrolling, and after navigation.
Actual behavior
In Light mode on iOS, the inline math attachment sometimes displays an opaque white rectangle behind the formula. With a custom attachment UTI, the same artifact becomes a generic white file/document icon, which suggests that TextKit is drawing the NSTextAttachment fallback image when the LaTeX view provider is not attached or is being reused. Setting MTMathUILabel.isOpaque = false, clearing its background, or setting its alpha to 0 did not remove the white region, so the label itself does not appear to be the source.
This is most reproducible for inline math inside a SwiftUI List; the equivalent content in a ScrollView does not show the artifact. Navigating away and back can make it disappear temporarily. Block/display math was not affected in this reproduction.
Validation
Environment:
- SwiftStreamingMarkdown cloned from https://github.com/microsoft/SwiftStreamingMarkdown.git
- Commit:
95bb755 - Xcode 26.6 (build 17F113)
- iOS 26.5 Simulator, iPhone 17 Pro
Reproduction:
- Render the minimal Markdown in a
Listusing the package's normal iOS renderer. - Use Light appearance.
- Scroll through the list and/or navigate away and back.
- Compare with the same Markdown rendered in a
ScrollView.
The issue was reproduced with both static and streaming document rendering. As a local experiment, changing the inline attachment to a custom NSTextAttachment that returns a transparent fallback image removed the artifact in the List, including after scrolling and re-entering the screen. The Demo built and ran successfully against the cloned local package.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the package's normal iOS renderer and trace inline math attachment creation and provider attachment during SwiftUI List row reuse, comparing it with the ScrollView path. Reproduce with the minimal Markdown in Light mode, then verify that inline formulas remain transparent and stable while scrolling and after navigation, without affecting block math.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100