HTMLAttributor

master

Attribute string from HTML
michaelnisi/hattr

hattr - parse HTML

The hattr iOS package provides a naïve HTML parser to efficiently transform HTML into attributed strings.

Goals

  • No dependencies except UIKit
  • Offloadable from main thread
  • Simple and fast

50X faster than NSAttributedString.init(data:options:documentAttributes:)

At least 50X less correct.

Example

import HTMLAttributor

let hattr = HTMLAttributor()
let tree = try! hattr.parse(html)
let attributedText = try! hattr.attributedString(tree)

Find a runnable example in HTMLPlayground.playground.

Install

📦 Add https://github.com/michaelnisi/hattr to your package dependencies.

License

MIT License

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Apr 11 2024 20:48:56 GMT-0900 (Hawaii-Aleutian Daylight Time)