-
Notifications
You must be signed in to change notification settings - Fork 341
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
New lines are concatenated and not broken, need two lines #341
Comments
Also ran into this issue this morning. |
Hi @freak4pc, Thanks for reporting this. There has been some discussion in the past about how MarkdownUI renders single line breaks. In Markdown, single line breaks within a paragraph are treated as soft line breaks. Soft line breaks are typically rendered as spaces, which is consistent with what a browser would do. For instance, the following HTML:
Is rendered as:
GitHub's behavior varies depending on the context:
For instance, if you edit the repository's
In Markdown, you can use a backslash struct LineBreakView: View {
var body: some View {
Markdown {
"""
Test1\\
Test2\\
Test3
"""
}
}
} MarkdownUI also supports the struct LineBreakView: View {
var body: some View {
Markdown {
"""
Test1<br />
Test2<br />
Test3
"""
}
}
} Unfortunately, there is currently no workaround if you want to avoid changing the text as suggested above. I don't have the time right now, but it should be feasible to add an environment value to let users configure how a |
Thanks, appreciate the detailed answer :) |
Thanks for working on this, @freak4pc! I really appreciate it. I wouldn't add this configuration to the theme. I like the idea of having a soft break mode enum and add it to the environment using a dedicated view modifier. struct LineBreakView: View {
var body: some View {
Markdown {
"""
Test1
Test2
Test3
"""
}
.markdownSoftBreakMode(.lineBreak)
}
} I will have a look at your PR over the weekend. Thanks again for your contribution! |
Describe the bug
When I have a Markdown as follows:
I get the following result:
If I add an extra line between them, they get separated:
To me, this seems like the wrong behavior, as you can see even from the markdown rendered here in GitHub:
Test1
Test2
Test3
Is there any way to fix it, or control this behavior?
Thanks :)
Checklist
main
branch of this package.Steps to reproduce
Shown in problem description
Expected behavior
Shown in problem description
Screenshots
Shown in problem description
Version information
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: