Skip to content

Release 2.0

Latest

Choose a tag to compare

@objecthub objecthub released this 10 Oct 14:16
· 16 commits to master since this release

Source-incompatible changes:

  • New enum cases TextFragment.underline, TextFragment.strikethrough and ListType.task(_, checked:): switch statements over them have to handle the cases. The type of a task item wraps the original one, so use ListType.marker to get its bullet or number.
  • CustomBlock, CustomTextFragment and the TableRenderer protocols refine Sendable. Subclasses of parsers and generators get the warning "must restate inherited '@unchecked Sendable' conformance": add @unchecked Sendable.
  • HighlightingConfig and AnsiHighlightingConfig are structs (a changed config has to be a var), and TerminalGenerator.init has the new parameters underlineProperties and strikethroughProperties (subclasses overriding it have to adopt them).
  • Coming from 1.4: see 1.5 below for output changes of the parsers and generators. Also, SyntaxHighlighter.proxy is a static let, and HtmlGenerator.init() is init(safeMode:) (a subclass with override init() has to declare init() without override).

New features:

  • FullMarkdownParser (a subclass of ExtendedMarkdownParser) supports all features of MarkdownKit: tables, definition lists, underline (~x~), strikethrough (~~x~~) and task lists (- [ ] to do, - [x] done). The other parsers are unchanged. HTML uses <u>, <del> and <input type="checkbox">, attributed strings ☐ and ☑, and the text generators [ ] and [x]. MarkdownText(string:full:…) uses it if full is true.
  • Highlighting themes are parsed and applied like CSS (whitespace, comments, !important, selectors and specificity). Before, competing rules were merged in a random order and some selector lists were dropped. Text can be bold and italic at once (HighlightingConfig.boldItalicCodeFont), and styling is about 25% faster.
  • New command-line tool MarkdownTermViewer prints the demo document of MarkdownViewer as plain text (--format text, the default) or with ANSI escape codes (--format ansi).

Other changes:

  • MarkdownKit is compiled in Swift 6 language mode. Syntax trees, options, configurations, parsers, generators and SyntaxHighlighter are Sendable (e.g. a Block can be parsed in a background task); the classes are open and conform @unchecked. generateAsync returns sending NSAttributedString. SyntaxHighlighter.proxy can be used from several threads. New ConcurrencyTests (swift test --sanitize=thread).
  • Attributed strings: bullets and checkboxes are right-aligned before the text, like numbers (bulletStyle, checkboxStyle), and a block quote is a single table cell (quoteStyle), because empty cells made text views clip its first lines.
  • A table without rows has no empty <tbody>. CustomTextFragment has the new requirements generateText(via:) with default implementations. The framework builds for watchOS and tvOS again.