HubSpot/NSAttributedString-DDHTML

Name: NSAttributedString-DDHTML

Owner: HubSpot

Description: Simplifies working with NSAttributedString by allowing you to use HTML to describe formatting behaviors.

Forked from: dbowen/NSAttributedString-DDHTML

Created: 2017-11-10 17:12:34.0

Updated: 2017-12-06 10:45:30.0

Pushed: 2017-11-10 17:16:53.0

Homepage: null

Size: 74

Language: Objective-C

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

NSAttributedString+DDHTML

Simplifies working with attributed strings by allowing you to use HTML to describe formatting behaviors.

NSAttributedString+DDHTML isn't intended to support full HTML rendering. Instead it provides a quick, effient and light-weight implementation for leveraging attributed strings when utilizing native UIKit interface elements.

License

It is open source and covered by a standard BSD license. That means you have to mention Derek Bowen @ Deloite Digital as the original author of this code.

Requirements

NSAttributedString+DDHTML requires a minimum iOS deployment target of iOS 7.0 because of:

Setup

Using CocoaPods

One of the easiest ways to integrate NSAttributedString+DDHTML in your project is to use CocoaPods:

  1. Add the following line to your Podfile:

    "NSAttributedString-DDHTML"
    
  2. In your project directory, run pod update

  3. You should now be able to add #import <NSAttributedString-DDHTML/NSAttributedString+DDHTML.h> to any of your target's source files to use the library!

Manual
  1. Add NSAttributedString+DDHTML.m/h to your project.
  2. Add libxml2.dylib to the “Link Binary With Libraries” section of your target's build phase.
  3. Add ${SDKROOT}/usr/include/libxml2 to your project's Header Search Paths under Build Settings.
  4. Start using it!
Usage

#import "NSAttributedString+DDHTML.h"

...

NSAttributedString *attributedString = [NSAttributedString attributedStringFromHTML:@"My <b>formatted</b> string."];

...
Supported Tags

b, strong - Bold (iOS, watchOS, tvOS)
i - Italics (iOS, watchOS, tvOS)
u - Underline (iOS, watchOS, tvOS)
strike - Strikethrough (iOS, watchOS, tvOS)
stroke - Stroke (iOS, watchOS, tvOS)
shadow - Shadow (iOS, tvOS)
font - Font (iOS, watchOS, tvOS)
br - Line Break (iOS, watchOS, tvOS)
p - Paragraph (iOS, watchOS, tvOS)
img - Image (iOS, tvOS)

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.