ZhgChgLi / ZMarkupParser

ZMarkupParser is a pure-Swift library that helps you convert HTML strings into NSAttributedString with customized styles and tags.
https://link.zhgchg.li/
MIT License
311 stars 24 forks source link

List Formatting #52

Closed chulbert closed 5 months ago

chulbert commented 7 months ago

This is an excellent library that meets all our needs except one: list formatting.

For an unordered list like the following:

<ul>
  <li>ZMarkupParser is a pure-Swift library that helps you convert HTML strings into NSAttributedString with customized styles and tags.</li>
  <li>ZMarkupParser is a pure-Swift library that helps you convert HTML strings into NSAttributedString with customized styles and tags.</li>
  <li>ZMarkupParser is a pure-Swift library that helps you convert HTML strings into NSAttributedString with customized styles and tags.</li>
</ul>

The rendered output is:

Screenshot 2024-03-15 at 11 26 14 AM

This falls short of our need in a couple ways:

  1. There is no spacing between the bullet and the text. This makes them very hard to read.
  2. The wrapped text should align with the start of the first line, similar to the following:
Screenshot 2024-03-15 at 11 35 41 AM

It would be great if this could be achieved. Otherwise lists are fairly unusable.

pykaso commented 5 months ago

You can take a look at my PR, where I am trying to solve this problem.

zhgchgli0718 commented 5 months ago

Thanks @chulbert for reporting this issue and @pykaso for providing the solution PR. Based on the PR provided by @pykaso, I gained a lot of inspiration regarding HTML list formatting. As a result, I studied the entire problem and proposed a more comprehensive fix and solution. Thank you all for your support and patience.

61

zhgchgli0718 commented 5 months ago

It should be fixed in v1.9.3

zhgchgli0718 commented 5 months ago

ref: readme