microsoft / microsoft/SwiftStreamingMarkdown

[Bug]: Inline LaTeX shows an opaque white fallback in SwiftUI List

Open
#171 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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:

Reproduction:

  1. Render the minimal Markdown in a List using the package's normal iOS renderer.
  2. Use Light appearance.
  3. Scroll through the list and/or navigate away and back.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.