rubymotion-community / sugarcube

Some sugar for your cocoa. RubyMotion helpers.
Other
421 stars 66 forks source link

Adds method on NSString to generate an NSAttributedString from html. #175

Closed markrickert closed 10 years ago

markrickert commented 10 years ago

I'm open to changes in the method name, but it was the best I could come up with for a method that takes an HTML formatted NSString and turns it into a NSAttributedString.

colinta commented 10 years ago

Awesome! I was nervous for a sec that there was gonna be some mini-html parser in there, glad to see its using cocoa (I didn't know anything about this html parsing option). Good stuff. I'll merge it when I get to work.

On Nov 13, 2014, at 9:37 PM, Mark Rickert notifications@github.com wrote:

I'm open to changes in the method name, but it was the best I could come up with for a method that takes an HTML formatted NSString and turns it into a NSAttributedString.

You can merge this Pull Request by running

git pull https://github.com/MohawkApps/sugarcube nsattributedstring_from_html Or view, comment on, or merge it at:

https://github.com/rubymotion/sugarcube/pull/175

Commit Summary

Adds method on NSString to generate an NSAttributedString from html. Merge branch 'master' into nsattributedstring_from_html File Changes

M lib/cocoa/sugarcube-attributedstring/nsattributedstring.rb (7) M spec/ios/nsattributedstring_spec.rb (15) Patch Links:

https://github.com/rubymotion/sugarcube/pull/175.patch https://github.com/rubymotion/sugarcube/pull/175.diff \ Reply to this email directly or view it on GitHub.

markrickert commented 10 years ago

Note the commented out tests... i can't figure out how to determine is something is bold or italic since the font instances are different from what's automatically created via the cocoa api... and yes, this was added in iOS 7... there's also an RTF formatter so you can read an RTF file from disk and turn it into an attributedString!

colinta commented 10 years ago

Yeah saw that, I'm not too worried; it creates an NSAttributedString, the rest is kind of up to Apple to get right.

colinta commented 10 years ago

Available in 2.12.0

markrickert commented 10 years ago

:+1:

markrickert commented 10 years ago

Also, note the unrelated failing test:

UIView tumble animation
2014-11-13 20:48:30.087 SugarCube[3052:7125] *** Terminating app due to uncaught exception 'NoMethodError', reason: 'animation_chain.rb:61:in `block in do_next': undefined method `call' for nil:NilClass (NoMethodError)
    from uiview.rb:91:in `animate:'
    from animation_chain.rb:59:in `do_next'
    from animation_chain.rb:48:in `block in do_next'