Skip to content
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

Word-Wrapping Issue #304

Open
gerrylu1 opened this issue Mar 13, 2024 · 0 comments
Open

Word-Wrapping Issue #304

gerrylu1 opened this issue Mar 13, 2024 · 0 comments

Comments

@gerrylu1
Copy link

gerrylu1 commented Mar 13, 2024

Thank you for contributing to MarkdownUI!

Before you submit an issue, please complete the report with all the relevant details for your bug and go through every item in the checklist.

Describe the bug
As the title suggests, this is a word-wrapping issue.

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
Please refer to the code here:

import SwiftUI
import MarkdownUI

struct MarkdownTestView: View {
    private var screenWidth: CGFloat {
        UIScreen.main.bounds.width
    }
    
    private var markdownText = "This shipment has been been delivered."
    
    var body: some View {
        VStack(spacing: 8) {
            HStack(alignment: .bottom, spacing: 8) {
                markdownMessageView
            }
            
            HStack {
                markdownMessageView
            }
            
            ZStack {
                HStack{
                    Spacer()
                }
                Markdown{
                    """
                    ## Using a Markdown Content Builder
                    Use Markdown strings or an expressive domain-specific language
                    to build the content.
                    
                    This shipment has been been delivered.
                    """
                    Heading(.level2) {
                      "Try MarkdownUI"
                    }
                    Paragraph {
                      Strong("MarkdownUI")
                      " is a native Markdown renderer for SwiftUI"
                      " compatible with the "
                      InlineLink(
                        "GitHub Flavored Markdown Spec",
                        destination: URL(string: "https://github.github.com/gfm/")!
                      )
                      "."
                    }
                }
            }
            .padding(12)
            .background(
                RoundedRectangle(cornerRadius: 12, style: .continuous)
                    .foregroundColor(Color.secondary.opacity(0.2))
            )
            
        }
        .padding(.trailing, screenWidth * 0.2)
    }
    
    private var markdownMessageView: some View {
        HStack {
            Markdown {
                markdownText
            }
            .multilineTextAlignment(.leading)
            .padding(12)
            .background(Color.red)
            
            Spacer()
        }
        .background(
            RoundedRectangle(cornerRadius: 12, style: .continuous)
                .foregroundColor(Color.secondary.opacity(0.2))
        )
    }
}

Expected behavior
The repeated word "been" should have stayed in the line above since there was still space for the word.

Screenshots
If applicable, add screenshots to help explain your problem.
simulator_screenshot_6942D5AE-7905-4F82-B269-A618949FC987

Version information

  • MarkdownUI: 2.3.0
  • OS: iOS 17.2
  • Xcode: 15.2
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