SwiftUI Formatted Text

screenshot of SwiftUI Formatted Text

A simple proof-of-concept SwiftUI application that renders a HTML-like language using SwiftUI Text elements.

Overview

The SwiftUI-Formatted-Text application serves as an intriguing proof-of-concept that explores the potential of a custom HTML-like language tailored for SwiftUI Text elements. While it aims to provide a way to render formatted text using a syntax reminiscent of HTML, users should be aware that both the parser and renderer are still in a buggy developmental phase. This project targets those familiar with HTML, as the syntax and structure bear a close resemblance, making it easier for experienced users to adapt.

Despite its current state, the application showcases an innovative approach to handling formatted localized strings and loading text from databases. With the foundation laid for further enhancements, it’s an exciting tool for developers interested in text rendering in SwiftUI, albeit with the caveat that it is a work-in-progress.

Features

  • Basic Formatting Tags: Support for essential formatting tags such as largeTitle, title, headline, and body, allowing for various text styles to be applied.

  • Font Attributes: Users can specify font family and size along with color attributes using hex values, although both family and size must be included for the effects to apply.

  • Simple Parsing: The application parses input strings into an abstract syntax tree utilizing Tag structs, paving the way for rendering in SwiftUI.

  • Localized String Support: Designed to support formatted localized strings, making it suitable for dynamic text rendering based on user language preferences.

  • User-Defined Formatting: Users have the ability to format text as desired, offering a customizable experience for content presentation.

  • Manual Newline Handling: Newlines can be inserted using "\n" or "", providing a straightforward method for text layout despite the absence of certain block elements.

  • Development Stage: This project is acknowledged as a proof-of-concept and not intended for application use, highlighting the necessity for further refinement and debugging.

This early-stage application sets the groundwork for future developments in the realm of SwiftUI text formatting, catering to developers looking to experiment with custom rendering techniques.