ZMarkupParser
ZMarkupParser copied to clipboard
spacingPolicy missing from Builder API even though mentioned in README
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 https://github.com/ZhgChgLi/ZMarkupParser/commit/8eba375cdc569bf14ff5cda236bdb33a80f26e62#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.
Got it thank you. I believe CSS as a line break collapsing strategy for paragraphs as well.
Cameron.
On Wed, 27 Mar 2024 at 14:54, ZhgChgLi @.***> wrote:
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
,, or
... tags into line breaks \n.However, upon comparing the results with those rendered by web browsers, we noticed that browsers tend to merge consecutive
tags:For example, in the case of
This is a paragraph.
, 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.
— Reply to this email directly, view it on GitHub https://github.com/ZhgChgLi/ZMarkupParser/issues/50#issuecomment-2022976721, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEZ6SJHPFBYXJDRSXEGJCLY2LMQZAVCNFSM6AAAAABEQHDSSOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRSHE3TMNZSGE . You are receiving this because you authored the thread.Message ID: @.***>
paragraphSpacing
seems to do absolutely nothing, certainly with SwiftUI.
about SwiftUI problems, Please feel free to refer to this comment. thank you.