NimbusKit / markdown

A Markdown NSAttributedString parser.
Apache License 2.0
656 stars 63 forks source link

Added utility method to NSAttributedStringMarkdown to get string with links #18

Closed NachoSoto closed 10 years ago

NachoSoto commented 10 years ago

I don't know if there was a reason to not make this the default behavior, so I figured I could add this as a separate method.

I was confused at first thinking the problem was that I wasn't displaying the links on the attributed string correctly due to some bug in UITextView in iOS 7, so hopefully this will help other people too :)

jverkoey commented 10 years ago

This is an iOS 7 only feature - I still want this lib to support older OS's at least until 8 comes out. If you add the necessary checks for backwards-compatability I'll merge this in.

NachoSoto commented 10 years ago

My bad :) I didn't realize NSLinkAttributeName is only available since iOS 7.0. I just pushed the fix.

NachoSoto commented 10 years ago

I'm embarrassed :P I should have though of this. I'm way too used to not having to worry about it and work iOS 7 only. Fix incoming!

NachoSoto commented 10 years ago

This should do it? I also made it support OS X :)

NachoSoto commented 10 years ago

That should be it. Actually, by doing this in my own project I realized this can crash if a the parser finds an URL that later fails to be encoded into a NSURL (I think it was some string of the form a.b. Note the missing scheme.).

I checked if link.url is not nil before adding the attribute, but instead you might want to check here?

Let me know which one you think is better I can add it in :)

Thanks!

jverkoey commented 10 years ago

Looks good! Merging nao.

jverkoey commented 10 years ago

Will look at the crash later!

NachoSoto commented 10 years ago

Thanks!