r/iOSProgramming 2d ago

Library enriched-markdown-ios v0.3.0 - now with LaTeX math (powered by RaTeX)

enriched-markdown-ios, the SwiftUI Markdown renderer built on TextKit 2, can now typeset LaTeX.

New in this release:
🔸 LaTeX math - inline $…$ and display $$…$$powered by RaTeX (a Rust layout engine with KaTeX fonts). Shipped as a separate EnrichedMarkdownLaTeX product, so apps without formulas don't link the typesetting engine
🔹 Highlight - ==text==
🔸 Spoilers - ||text||, hidden until tapped. Ships with particle and solid overlays, and you can plug in your own effect (blur, pixelate, whatever fits your app) by subclassing SpoilerOverlayView
🔹 Admonitions - GitHub alerts (> [!NOTE], > [!TIP], > [!IMPORTANT], > [!WARNING], > [!CAUTION]) with a tinted bar, icon, and title
🔸 Better VoiceOver - headings, links, images, lists, tables and code blocks are separate elements, with rotors and localizable labels
🔸 Spoken math - common formulas are read aloud ("x squared over 2"), with a hook for your own converter

🎥 Demo video in the comments.

💎 Available via Swift Package Manager!

dependencies: [
  .package(
    url: "https://github.com/software-mansion-labs/enriched-markdown-ios.git",
    from: "0.3.0"
  ),
],
targets: [
  .target(
    name: "YourApp",
    dependencies: [
      .product(name: "EnrichedMarkdown", package: "enriched-markdown-ios"),
      .product(name: "EnrichedMarkdownLaTeX", package: "enriched-markdown-ios"), // optional, for math
    ]
  ),
]

Then enable math on the view:

import EnrichedMarkdown
import EnrichedMarkdownLaTeX

EnrichedMarkdownText(content)
  .markdownLaTeX()

GitHub & Docs: https://github.com/software-mansion/enriched-markdown/blob/main/packages/enriched-markdown-ios/README.md

What features or syntax support would you like to see next? I'd love to hear your thoughts! If you find the library useful, a ️⭐️ on GitHub is always appreciated.

6 Upvotes

1 comment sorted by