Headline: a new pure-Swift, cross-platform HTML/CSS → PDF render engine — no platform graphics dependencies — plus RTL/Arabic support and new Numbers & Keynote readers.
SwiftTextRender — HTML/CSS → PDF (new engine)
- End-to-end HTML/CSS → PDF: DOM adapter, styled tree, box tree, block + inline layout, and paint — entirely in Swift, on every platform.
- Paginates to fixed-size pages; honors
@pagesize and margins from CSS. - Tables: block layout,
colspan/rowspan, and per-cellvertical-align(top/middle/bottom). - Lists: item markers,
list-style-type(decimal, alpha, roman, disc/circle/square, none), and correct absolute marker baselines. - Inline:
text-decorationunderline/line-through,letter-spacing/word-spacing,text-indent,white-space:pre(preserved space runs + forced breaks), and<br>. - Images:
<img>for JPEG and PNG with no decoding dependencies. - Fonts: embed arbitrary OpenType fonts (CIDFontType2), WinAnsi (CP1252) encoding, Helvetica-Bold metrics for bold, serif → Times.
- Navigation: clickable links via PDF Link annotations and a PDF outline (bookmarks) generated from headings.
- Collapses adjacent vertical margins; honors
<style>stylesheets andtext-align. - CLI:
pdf --engine swiftselects the cross-platform render path.
RTL & Arabic
- Unicode Bidirectional Algorithm (UAX #9) implemented in pure Swift.
- RTL inline layout: bidi reordering + direction-aware alignment, with automatic base-direction detection for RTL Markdown.
- CSS
directionproperty and thedirattribute. - Arabic shaping: presentation-forms shaper and RTL lists.
- Font fallback: per-run glyph substitution for missing glyphs.
New pure-Swift foundation modules
- SwiftTextOpenType — pure-Swift OpenType/TrueType reader.
- SwiftTextCSS — CSS Syntax Level 3 tokenizer/parser (tinycss2 port), selector parsing + specificity + matching, the cascade with typed computed values, and CSS Color Level 3.
- SwiftTextPDFWriter — cross-platform PDF generator (pydyf port).
- SwiftTextAttributedString — all-platform Markdown → Foundation
AttributedString. - DOM:
HTMLDocument.styleSheets/DOMElement.styleSheets()and resolution of<link rel="stylesheet">.
iWork: Numbers & Keynote (new readers)
- Numbers (
.numbers): extract tables as Markdown, HTML, TSV, or JSON (numbers --json). Reads frozen cell values — numbers, dates, and formula results — as static text. - Keynote (
.key): extract slide text as Markdown (one heading per slide, body as bullets), JSON (title/body/notes per slide), or plain text. - Shared SwiftTextIWA module (Snappy, protobuf,
TSTTableReader); PagesParser converged onto the same table reader. - Legacy iWork '09: Numbers via
index.xml, and the shared '09 table extractor so Pages '09 reads tables too.
CLI
- New
numbersandkeynotesubcommands. pdf --engine swiftfor the cross-platform render engine.render --page-break-beforeto start chapters on new pages.
Tooling, CI & robustness
- SwiftLint linting (CI + pre-commit), mirroring SwiftAgents.
- Portable unit tests now run on Windows and Android;
SwiftTextAttributedStringis genuinely all-platform (AttributedString excluded on Windows for the swift-foundation BigString link gap — see swiftlang/swift#88132).
Cross-platform command-line tool
- The
swifttextCLI now builds and runs on macOS, Linux, and Windows (it was macOS-only before). - Cross-platform subcommands:
docx,pages,numbers,keynote(iWork/DOCX readers),html(text/Markdown), andpdf/render(Markdown/HTML → PDF/DOCX/Pages). - Off macOS,
pdf/renderdefault to the pure-Swift SwiftTextRender engine (no WebKit); on macOS WebKit stays the default and--engine swiftopts in.ocr/overlay(Vision) and the WebKit engine remain macOS-only. - Recognizes native absolute paths on every platform (POSIX
/…and WindowsC:\…/ UNC). - On Linux/Windows the HTML/render paths need libxml2 (
libxml2-devon Linux, vcpkg on Windows).
Full changelog: 1.2.0...2.0.0