finds.dev← search

// the find

JohnSundell/Splash

★ 1,869 · Swift · MIT · updated May 2024

A fast, lightweight and flexible Swift syntax highlighter for blogs, tools and fun!

Splash is a Swift-only syntax highlighter built by John Sundell, the person behind swiftbysundell.com. It parses Swift source into tokens using a hand-written grammar and outputs HTML, NSAttributedString, or images. If you're building a Swift blog engine or developer tool on macOS/Linux and need Swift highlighting without pulling in a heavy dependency, this is a good fit.

The output format is a protocol, so swapping HTML for a custom renderer is a ten-line change. The tokenizer exposes raw segment data, which means you can build tooling on top of it rather than just pretty-printing. The test suite is thorough — there are dedicated files for closures, enums, optionals, preprocessor directives, and more, which matters a lot for a language with Swift's syntactic variety. It's pure Swift with no dependencies, so it compiles cleanly on Linux for server-side use.

It only handles Swift. If your project mixes Swift with YAML configs, shell scripts, or JSON examples, you're on your own or reaching for a different library. The grammar is hand-written rule matching, not a proper parser, so edge cases in newer Swift syntax (macros, parameter packs) will break silently or produce wrong token types — and the last push was May 2024, so Swift 5.9/6 features are likely partially broken. SplashImageGen is macOS-only, which is fine but underdocumented in the README. There's no published API reference; you're reading source to understand the token model.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →