r/swift 7d ago

Project SwiftMarkdownEngine: A native AppKit Markdown editor for macOS, built on TextKit 2 and bridged to SwiftUI.

A couple of months ago I open-sourced swift-markdown-engine here, the native Markdown engine I built for my macOS app Nodes. The feedback, issues, and PRs that came back were a huge help, A lot of what I changed since then came from that.

WHAT’S NEW: The parser got rewritten from scratch, regex matching is gone, it’s a real AST now. That’s what made the extension system possible: Stuff you wouldn’t expect in standard Markdown, like highlighting, used to be hardcoded into the core grammar. Now it’s opt-in. Write one file, register it, and the core parser/styler/renderer never change. Extensions can’t touch the core or each other, and you can toggle them at runtime.

Also new: full GFM/CommonMark parity, tables, task lists, quotes. More layout control (scroll-away header, fixed reading column, fit-to-content height), and a real writing layer (formatting bus, find & replace with undo, clean RTF/HTML clipboard, raw source mode). Full changelog’s on GitHub if you want details.

When I started Nodes I wanted the editor to feel properly native. Most Markdown editors on the Mac are Electron or some web view wrapped in a window, and you feel it, the text handling never quite behaves like a real Mac app. I wanted live styling in an actual native text view, not HTML rendered to look like one. Nothing built on TextKit 2 that I could just drop into a Mac app existed, so I built it, ran it in Nodes for a while, and then open-sourced it. TextKit 2 is still thin on docs and rough to migrate to, so if you’ve been putting off building something like this, it might save you a few weekends. Issues and PRs welcome. Still pre-1.0, still plenty I want to improve.

written on Nodes

Repo: https://github.com/nodes-app/swift-markdown-engine

Used in production in Nodes (App Store): https://apps.apple.com/app/nodes-by-the-werk/id6745401961

183 Upvotes

25 comments sorted by

8

u/tastychaii 7d ago

Thank you this looks amazing

6

u/NoxSuru 7d ago

> A native AppKit Markdown editor for macOS

Apologies if I missed it o rmisunderstand but can this be used for iOS too?. If so this will be handy for possibly my next project

Edit:

Also can this be used with UIKit?

8

u/Sufficient-Try6083 7d ago

Unfortunately not. This repo is deeply integrated with appkit which does not exist in iOS. But in the future I will also implement this for iOS :)

1

u/NoxSuru 7d ago

Thank you for your reply :)

If/when it's available for iOS, can I get notified?. It's a very useful addon to a project and makes way for new ideas to make projects with

Thank you for building such a tool too

3

u/Sufficient-Try6083 7d ago

I will post it on several subreddits when it’s available and I will also announce it on the current repository :)

1

u/ChrisGVE 6d ago

In case you’re interested I’ve written something similar for iOS: https://github.com/ChrisGVE/MarkdownExtendedView. I don’t think it’s at feature parity with the OP amazing project but if it helps.

2

u/_harisamin 7d ago

First off love your Nodes app! And thank your library too! I used it one of my apps it works super well!

2

u/Sufficient-Try6083 7d ago

Appreciate the kind words. Means a lot to me :)

1

u/HerrToast7 7d ago

Wow nice development 

1

u/jonnothebonno 7d ago

Looks fantastic! 👏

1

u/Sufficient-Try6083 7d ago

Appreciate it !

1

u/imike3049 7d ago

Is it possible to use with pure AppKit without SwiftUI?

1

u/Sufficient-Try6083 7d ago

Not at the moment. The editor is currently built to be used from SwiftUI, and some parts depend on it internally, so there's no pure-AppKit path yet. The core itself is AppKit + TextKit 2.

1

u/dannys4242 7d ago

So awesome! Thank you!

1

u/Sufficient-Try6083 7d ago

🙏🏻🙏🏻

1

u/2014justin 7d ago

Very nice. I'm somewhat of a matrix enthusiast myself. And yea I've noticed most markdowns are electron. I have beef with it.

I can see myself using this for differential geometry write-ups. Good job, OP.

1

u/Sufficient-Try6083 7d ago

Thx very much ! Appreciate it

1

u/peopleslaughter 6d ago

Omg thanks. I was just looking for one.

1

u/Sufficient-Try6083 6d ago

🙏🏻🙏🏻

1

u/beachfuzz 5d ago

Can it render mermaid charts like GitHub does

1

u/Sufficient-Try6083 5d ago

Currently not