Skip to content

Whitespace collapsing bug when in line break mode #402

@hyperlink

Description

@hyperlink

There's a whitespace collapsing bug where inline-styled elements (links, bold, italic, strikethrough) lose their trailing spaces in .lineBreak mode, causing adjacent text to run together without proper spacing.

Checklist

  • I can reproduce this issue with a vanilla SwiftUI project.
  • I can reproduce this issue using the main branch of this package.
  • This bug hasn't been addressed in an existing GitHub issue.

Steps to reproduce

  1. enable softline break mode: .markdownSoftBreakMode(.lineBreak)
struct ContentView: View {
    var body: some View {
        VStack {
            Markdown {
"""
Begining text
[Link](https://www.example.com) without spaces after?
**Emphasis Text** seems to run together ?
***what*** about strong emphasis?
~~strikethrough~~ are also running running together!
`inline code` is not working?
"""
            }
            .markdownSoftBreakMode(.lineBreak)
        }
        .padding()
        .frame(height: 200)
    }
}

Expected behavior
The whitespace between the text and inline-styled elements should be preserved.

Screenshots

Image

Version information

  • MarkdownUI: [2.4.1]
  • OS: [macOS 15]
  • Xcode: [16.2]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions