Closed JodliDev closed 9 months ago
I added a fix for an unexpected source of crashes (when the HTML string is empty).
About the failing tests: At the moment I am on a tight schedule, so I dont really have the capacity to look into library development and figure out how to run tests (I assume its not that complicated, but I don't really have the head space right now đŸ˜… ). So please see this PR as a starting point for improvement. I you want to just "steal" my changes and close this PR, I am fine with that as well :)
will fix tests and review later, thanks.
I still working on it.
Thank you for your contribution, but in the latest version 1.8.0, I have completely refactored the line break logic and implemented it to directly match the browser's line break behavior. Therefore, this pull request is no longer needed. Thank you again for your contribution.
Fix1:
When evaluating container tags (like
div
orp
) they always have a break line before them. Which in general is what we want. But when the container tag is at the start, this would lead to an empty line before it.So for example this
<div>This is one line</div>
is evaluated as:instead of (notice that there is to empty line above):
Or more importantly this:
would create something like this:
Fix2:
Having something like this
A<br><br><br>B
would be evaluated as:instead of:
I hope this is helpful for you :)
Disclaimer 1: I tested my changes with data from the app, where the library is used and I am content that it works as expected. But I did not run (or fix) any UnitTests because my knowledge of pure library development is limited.
Disclaimer 2: In case Fix 2 breaks intended behaviour, you can just revert my change in this line: https://github.com/JodliDev/ZMarkupParser/blob/2c6a74edc37678efd888d41c07bcdab7d0500bab/Sources/ZMarkupParser/Core/Processor/MarkupNSAttributedStringVisitor.swift#L23