ZhgChgLi/ZMarkupParser

Double line breaks are stripped out

danielallsopp opened this issue · 4 comments

In the following HTML example:
One<br /><b>Two</b><br /><i>Three</i><br /><i><b>Four</b></i><br /><br />New <b>Paragraph</b>!

should render with a line break after the 'Four' and before the 'New Paragraph' is rendered. However, I've noticed when the HTML string is parsed, the second line break is stripped out, so the render ends up like this:

incorrect

instead of this:

correct

Can this functionality be switched off, or is there a bug present?

EDIT: I've found this function in the source code which seems to the be the culprit:

func reduceBreaklineInResultNSAttributedString(_ attributedString: NSAttributedString) -> NSAttributedString

but I can't find anyway of switching it off, or overriding the functionality.

@danielallsopp You can see in my recent PR here I added a policy to modify line break behaviour. #37

For me I found the behaviour was adding more line breaks that I preferred. Maybe there could be another line break policy added that makes no changes to the built-in line breaks. (call it raw or something like that?).

v1.7.0 fixed and release, thanks to @charrondev

@zhgchgli0718 This bug not fixed in 1.7.0

image
In the latest version 1.8.0, the issues have been addressed.
Thank you for your patience.