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:
Reproduction:
- Render the minimal Markdown in a
List using 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.
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 aScrollView. The issue is intermittent and can disappear after leaving the screen and opening it again.Minimal markdown input
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
NSTextAttachmentfallback image when the LaTeX view provider is not attached or is being reused. SettingMTMathUILabel.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 aScrollViewdoes not show the artifact. Navigating away and back can make it disappear temporarily. Block/display math was not affected in this reproduction.Validation
Environment:
95bb755Reproduction:
Listusing the package's normal iOS renderer.ScrollView.The issue was reproduced with both static and streaming document rendering. As a local experiment, changing the inline attachment to a custom
NSTextAttachmentthat returns a transparent fallback image removed the artifact in theList, including after scrolling and re-entering the screen. The Demo built and ran successfully against the cloned local package.