ZhgChgLi/ZMarkupParser

spacingPolicy missing from Builder API even though mentioned in README

Closed this issue · 6 comments

I'm trying to control how paragraph spacing works and according to the README I should be able to use a spacingPolicy builder method but it doesn't exist.

Looks like this option was removed in this commit 8eba375#diff-02bc2fdf518816d7a3c9ea9bb354a3c7bf3e7356b3f87a48e16283c8480a0c8e

There is no indication of how to control paragraph behaviour and the documentation gives out-of-date instructions.

I'm sorry, the spacingPolicy parameter has been removed and will now refer directly to the browser's line-breaking rules for implementation.
The documentation will be updated in the next version.
If there are any issues related to line breaks, please feel free to bring them up for discussion.
Thank you.

ref #47

Thanks for the quick reply

refer directly to the browser's line-breaking rules for implementation

What do you mean it will refer to the "browser's" line-breaking rules? I didn't think this library used a web browser to generate the AttributedString?

paragraphSpacing seems to do absolutely nothing, certainly with SwiftUI.

Thanks for the quick reply

refer directly to the browser's line-breaking rules for implementation

What do you mean it will refer to the "browser's" line-breaking rules? I didn't think this library used a web browser to generate the AttributedString?

The initial version of the ZMarkupParser's line-breaking strategy involved directly converting <div>, <p>, or <br/>... tags into line breaks \n.

However, upon comparing the results with those rendered by web browsers, we noticed that browsers tend to merge consecutive <br/> tags:

For example, in the case of <p>This is a paragraph.<br/></p>, the actual line break would be This is a paragraph.\n, rather than This is a paragraph.\n\n.

To replicate this behavior, I implemented a similar line-breaking merge strategy.

As a result, the option paragraphSpacing to externally configure line-breaking rules was removed, and everything now follows the behavior of web browsers.

paragraphSpacing seems to do absolutely nothing, certainly with SwiftUI.

about SwiftUI problems, Please feel free to refer to this comment. thank you.