Skip to content

Whitespace collapsing bug when in line break mode #402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
hyperlink opened this issue Mar 28, 2025 · 0 comments
Open
3 tasks done

Whitespace collapsing bug when in line break mode #402

hyperlink opened this issue Mar 28, 2025 · 0 comments

Comments

@hyperlink
Copy link

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]
hyperlink added a commit to hyperlink/MarkdownUI that referenced this issue Apr 10, 2025
When using .markdownSoftBreakMode(.lineBreak), trailing spaces after
inline-styled elements (links, bold, italic, strikethrough, inline code)
were being collapsed, causing adjacent text to run together without
proper spacing. This commit ensures whitespace is properly preserved
in these contexts.

Fixes gonzalezreal#402
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

No branches or pull requests

1 participant