AliSoftware / OHAttributedLabel

UILabel that supports NSAttributedString
https://github.com/AliSoftware/OHAttributedLabel/wiki
1.51k stars 344 forks source link

Update 'a href' regular expression #175

Closed MindaugasV closed 10 years ago

MindaugasV commented 10 years ago

Updated regular expression ignores additional parameter added to a href tag and extracts correct URL

example to test:<a href="http://google.com" target="_blank">google</a>

AliSoftware commented 10 years ago

Thanks for this PR. But I'm not sure I'll accept it, as if I start to accept stuff like that, people will expect my OHASBasicHTMLParser to actually be an HTML parser and parse more complex HTML tags, whereas the aim of this parser, as explicitly explained in the README, is NOT to parse existing and complex HTML, but to help users build an NSAttributedString with tags they already know (like tags coming from the HTML vocabulary).

The idea behing this is that when you need to add attributes to a string, you will explicitly create a string and add tags to indicate where you want your bold and italics attributes. The idea is not to get already existing HTML text and use OHAttributedLabel as "a view capable to display a (potentially complex) HTML text". So you typically won't add the "target" attribute to your string.

So I'm afraid that starting to make the regex'es more lenient will let people think that this intends to be a real parser for HTML content, whereas is should only be seen as a helper to build NSAttributedString (instead of adding the attributes to your string one by one using NSRanges).

Unfortunately I didn't have time to really maintain OHAttributedLabel since the last year, and as this class is becoming less and less useful now that iOS6 natively supports NSAttributedStrings, I merely keep it alive for the sake of compatibility and for people still using it… but I have to admit that don't intend to make it evolve now

MindaugasV commented 10 years ago

I have to agree with you. And since you are not going to evolve with this project I will try to find better solution for my problem. Or just write own my own parser.

Thanks for your effort.

MindaugasV commented 10 years ago

However there is one issue with iOS6 native support of NSAttributedStrings which keeps me from using them. They do not support link attributed.