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

spacingPolicy missing from Builder API even though mentioned in README #50

Closed
cameroncooke opened this issue Mar 11, 2024 · 6 comments
Closed

Comments

@cameroncooke
Copy link

cameroncooke commented Mar 11, 2024

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.

@zhgchgli0718
Copy link
Member

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

@cameroncooke
Copy link
Author

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?

@cameroncooke
Copy link
Author

paragraphSpacing seems to do absolutely nothing, certainly with SwiftUI.

@zhgchgli0718
Copy link
Member

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.

@cameroncooke
Copy link
Author

cameroncooke commented Mar 27, 2024 via email

@zhgchgli0718
Copy link
Member

paragraphSpacing seems to do absolutely nothing, certainly with SwiftUI.

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

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

2 participants