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

Feature Request: parse HTML into NSAttributedString #88

Closed
newacct opened this issue Sep 25, 2012 · 2 comments
Closed

Feature Request: parse HTML into NSAttributedString #88

newacct opened this issue Sep 25, 2012 · 2 comments

Comments

@newacct
Copy link

newacct commented Sep 25, 2012

So that we don't have to construct the NSAttributedString painstakingly from scratch. At least a few simple tags, like B, I, U, A,

AliSoftware added a commit that referenced this issue Sep 26, 2012
@AliSoftware
Copy link
Owner

Done!

I built the system so that it is easy to add support for new tags, and that is also easy to support multiple tag systems (I currently created parsers for both HTML and a simple markup, for example) :-)

This is open to improvements of course, like adding some other tags.


Note that adding support for links (and <a href=...>...</a> tags) is unfortunately not straightforward, and thus not yet implemented, as there is no official CoreText attribute key for links (see the CT attributes doc).

This is doable anyway, but to implement it we would have to use a custom attribute key to store the link attribute information in our NSAttributedString (or use the one used by UIKit if we can find it… maybe the same NSLinkAttributeKey constant that is used in OSX/AppKit?), and then make the OHAttributedLabel class aware of this custom attribute, so that it is able to interpret it correctly and display the link.

Unfortunately, I don't think I will have time to add this specific custom attribute support just for this soon… but of course feel free to implement yourself in a fork and propose a pull request :-P

@AliSoftware
Copy link
Owner

Late note: Version 3.2.0, released 2 month ago (commit 78b2ff4), did add support for links in NSAttributedString and adds markup for links in both OHASBasicHTMLParser and OHASBasicMarkupParser.

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