Skip to content

Fix inline LaTeX fallback rendering - #172

Open
X (xshengcn) wants to merge 1 commit into
microsoft:mainfrom
xshengcn:main
Open

Fix inline LaTeX fallback rendering#172
X (xshengcn) wants to merge 1 commit into
microsoft:mainfrom
xshengcn:main

Conversation

@xshengcn

Copy link
Copy Markdown

Summary

Fix inline LaTeX rendering in List on light backgrounds.

When inline formulas are rendered as text attachments, TextKit can display the attachment's default opaque fallback image. In a SwiftUI List, that fallback appears as a white rectangle and can persist after view reuse. This change uses a transparent fallback attachment and keeps the LaTeX label transparent, so the list background remains visible.

Fixes #171

Validation

  • Built SolveMate for the iOS Simulator (iPhone 17 Pro, iOS 26.5).
  • Verified inline formulas in Light Mode inside List after leaving and re-entering the screen.
  • Verified ScrollView rendering remains unchanged.
  • Confirmed the package and SolveMate build resolve the forked dependency successfully.

OSS readiness

  • No secrets, internal URLs, private identifiers, or product-only service names were added.
  • No public docs, fixtures, or notices are required for this rendering-only fix.
  • Third-party dependency changes (adds, removes, version bumps) are intentional and reviewed.
  • Streaming/incomplete markdown behavior remains covered by existing package tests.

@xshengcn
X (xshengcn) requested review from a team and a lite review from Copilot August 28, 2026 01:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an iOS/macOS TextKit rendering artifact where inline LaTeX attachments can momentarily display an opaque fallback image (notably in SwiftUI List row reuse), by providing a transparent fallback attachment image and ensuring the LaTeX label itself is non-opaque/clear so list backgrounds remain visible.

Changes:

  • Introduces a custom LatexAttachment subclass that returns a transparent 1×1 fallback image instead of the default opaque fallback.
  • Switches inline-LaTeX attachment creation to use LatexAttachment (so TextKit’s fallback drawing stays transparent).
  • Makes the LaTeX label explicitly non-opaque on UIKit to avoid background artifacts.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Sources/MarkdownText/UI/Paragraph/LatexViewProvider.swift Adds LatexAttachment with transparent fallback image; ensures MTMathUILabel is non-opaque/clear on UIKit.
Sources/MarkdownText/Inline/Markdown+InlineConvertible.swift Uses LatexAttachment when producing inline-LaTeX NSTextAttachments so TextKit fallback is transparent.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Sources/MarkdownText/UI/Paragraph/LatexViewProvider.swift
@xshengcn

X (xshengcn) commented Aug 28, 2026 via email

Copy link
Copy Markdown
Author

Use a transparent fallback attachment for inline LaTeX so formula labels stay clear in light-mode lists and remain AppKit-compatible.
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.

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

2 participants