A Swift library that wraps @mozilla/readability and generalizes the Firefox Reader, which enhances web pages for better reading. This library provides a seamless way to detect, parse, and display reader-friendly content from any web page by integrating with WKWebView. Forked from Ryu0118/swift-readability to remove UI components.
- Parsing
Parse a URL or HTML string into a structured article using @mozilla/readability.
- Swift: 6.0 or later
- Xcode: 16.0 or later
swift-readability is available via the Swift Package Manager
.package(url: "https://github.com/git-shawn/swift-readability", exact: "0.1.1")You can parse an article either from a URL or directly from an HTML string.
Parsing from a URL:
import Readability
let readability = Readability()
let result = try await readability.parse(url: URL(string: "https://example.com/article")!)Parsing from an HTML string:
import Readability
let html = """
<html>
<!-- Your HTML content here -->
</html>
"""
let result = try await readability.parse(html: html)