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

Simple line breaks in markdown or using Text() #91

Open
markstamer opened this issue Jul 4, 2024 · 4 comments
Open

Simple line breaks in markdown or using Text() #91

markstamer opened this issue Jul 4, 2024 · 4 comments

Comments

@markstamer
Copy link
Collaborator

markstamer commented Jul 4, 2024

It seems that line breaks are ignored in markdown. This is all rendered inline:

Text(markdown: """
Sollicitudin Etiam
Etiam Sem 42
12345 Purus 
""")

Also it would be great to have simple line breaks that don't introduce space between two lines to work, e.g. by ending a line with a backslash. I couldn't achieve this with Text either, e.g. by putting multiple text elements in a Group. It would be great for something like displaying an address.

@henrikac
Copy link
Contributor

henrikac commented Jul 4, 2024

Not sure if you have tried this but try end lines with two or more spaces.

Markdown Guide - Line Break Best Practices

@markstamer
Copy link
Collaborator Author

Thanks for your comment but it doesn't work either. I have "Automatically trimming trailing whitespace" in Xcode enabled but turning it off didn't work either.

@cpah
Copy link

cpah commented Sep 12, 2024

There is a simple workaround. Xcode's markdown parser supports inline HTML. Add <br> at the end of each line. If you want a paragraph-style double space between lines, use <br><br>

Text(markdown: """
Sollicitudin Etiam<br>
Etiam Sem 42<br>
12345 Purus 
""")

@markstamer
Copy link
Collaborator Author

Awesome, it works. Thanks @cpah I wonder if there is a reason why this does not work out of the box and what the best approach would be to make it work. Either on Swift Markdown parser level or even Ignite.

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

3 participants