-
Notifications
You must be signed in to change notification settings - Fork 307
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
Newlines ("\n") get lost and replaced with a whitespace #269
Comments
Hi @ndemie , so there is a specific option to use to treat these "soft breaks" (what you're getting) as "hard breaks" (what you want). By default, all single newlines are considered soft breaks. You want to pass in this option to the parser, so something like: let attributedString = try down.toAttributedString(.hardBreaks, styler: DownStyler(configuration: .testConfiguration) Let me know how it goes. |
That fixes it, thanks! |
Multiple breaks still seem to get lost though. Test\nTest\n\nTest
while I would expect
Any solution for this @johnxnguyen? |
Also, unrelated (so let me know if you want this in a seperate issue), but none of the custom glyph's seem to get rendered for me e.g. codeBlockBackground, quoteStripe and thematicBreak. Any clue where the issue could be? |
@ndemie those custom attributes require the use of the |
@ndemie regarding the line break issue, I'll need to try it out myself and do some debugging, not sure if it's an issue with the parsing or the styling. I have a bit of a backlog of things to do for this repo so I won't be able to jump on this immediately. Feel free to come back and remind me if there's no activity here. |
Multiple breaks isn't working for me either with the solution. Is the fix still in the backlog? |
Any update on this @johnxnguyen? |
Hi @johnxnguyen, it's been a while. I was wondering if you had the chance to take a look at this yet? |
Do you still have time to fix this issue? @johnxnguyen |
I have encountered the same problem, and this problem has a great impact on me. Do you have time to solve it? Thanks very much! |
Running into this issue as well, is this currently unsupported or are there ways to work around this @johnxnguyen? Hope your doing well btw, has been a while! |
I was able to fix rendering multiple line breaks by adjusting my custom styler to style paragraphs accordingly. open func style(paragraph str: NSMutableAttributedString) {
let style = NSMutableParagraphStyle()
style.paragraphSpacing = 20
str.addAttributes([.paragraphStyle: style], range: NSRange(location: 0, length: str.length))
} |
Please help prevent duplicate issues before submitting a new one:
Report
Newlines seem to get lost when creating an attributed string using DownStyler and get replaced with a whitespace
What did you do?
"Test Test"
What did you expect to happen?
"Test\nTest"
Before this we used a stylesheet which didn't cause this issue. I've tried replacing newlines by double newlines but that renders two newlines causing too much spacing.
The text was updated successfully, but these errors were encountered: