A pure-Swift library for converting HTML strings into NSAttributedString with customizable styles and tag support.
ZMarkupParser is a pure-Swift library that converts HTML strings into NSAttributedString objects for display in iOS and macOS apps. It solves the problem of rendering rich, styled HTML content in native text views (like UILabel and UITextView) with better performance and more customization than Apple's built-in HTML rendering. The library parses HTML tags, corrects invalid markup, and applies customizable styles to produce attributed strings.
iOS and macOS developers who need to display HTML content in native UI components without using a WebView, particularly those working with rich text rendering, chat applications, content displays, or any app requiring styled text from HTML sources.
Developers choose ZMarkupParser for its pure-Swift implementation, superior performance with large HTML strings, extensible tag and style system, and ability to handle real-world HTML with automatic correction. It avoids crashes associated with Apple's HTML renderer and provides fine-grained control over styling.
ZMarkupParser is a pure-Swift library that helps you convert HTML strings into NSAttributedString with customized styles and tags.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses native Swift and regex parsing, outperforming Apple's NSAttributedString.DocumentType.html for larger strings and avoiding crashes with content over 54,600+ characters, as shown in performance benchmarks.
Supports custom tag names via ExtendTagName and customizable styles with MarkupStyle, allowing fine-grained control over HTML rendering without relying on XML-based parsers.
Automatically corrects invalid or mixed HTML tags (e.g., <a>Link<b>LinkBold</a>Bold</b>), making it compatible with real-world, messy HTML input from user-generated content.
Parses inline style attributes and maps class/id selectors to specific styles through HTMLTagClassAttribute and HTMLTagIdAttribute, enabling CSS-like styling directly from HTML strings.
Only pre-defined style attributes (e.g., color, font-size) are supported out-of-the-box; complex CSS properties or external stylesheets require manual extension via ExtendHTMLTagStyleAttribute, adding development overhead.
Exclusively designed for iOS and macOS with UIKit/AppKit, making it unsuitable for cross-platform projects without additional bridging or alternative libraries for other environments.
Requires configuration via the builder pattern for custom styles and tags, which can be verbose compared to simpler, drop-in HTML rendering solutions like WebViews.