Looking for syntax highlighted QuickLook code previews? Look no further

I’d like to introduce you to the latest member of the PreviewApp family: PreviewCode, which provides syntax-coloured QuickLook previews and Finder icon thumbnails for over 50 programming languages, including Swift, Objective-C, C++, Rust, JavaScript and Python, and data file types for macOS. You can choose to preview your source code any of 100 dark and light themes.

Previewed code courtesy of PreviewCode

Available now from the Mac App Store for a very modest consideration, PreviewCode delivers its previews and thumbnails through a pair of app extensions, but the main is app is where you apply your preferences:

  • Select the monospace font in which your code will be presented.
  • Choose the code’s text size.
  • Pick a preview theme.

PreviewCode lets you choose from any monospace font installed on your Mac, in a range of sizes from 10pt to 28pt.

Pick a theme, any theme…

PreviewCode’s themes are listed alphabetically, and you can choose to view them all, or just the dark or light ones. Preview settings are applied as soon as you click on the Preferences pane’s Save button, so you check out your choices immediately — and go straight back and make a different selection if your current choices are not to your satisfaction.

Did I mention there are lots of themes?

All of the themes and the code that applies them are provided by Highlight.js, a popular JavaScript framework designed to colourise source code presented by websites. Seeking a suitable Swift wrapper for Hightlight.js, I discovered Highlightr, but quickly found it to be based on an old version of the library that the Highlight.js team recommends is no longer used.

Highlightr appears to be no longer actively maintained — it hasn’t been updated since 2018 — and I needed to make some changes as well as bring it up to date with supported Highlight.js code. So the work on PreviewCode resulted in a second project: HighlighterSwift, a new wrapper for Hightlight.js offered as a Swift Package. The code derives from Highlightr, but is now fully commented, uses Highlight.js 10, and includes a number of fixes and improvements. Like Highlighr, it’s available under the terms of the MIT licence for easy inclusion in other projects.

Just a selection of the many languages and data files PreviewCode supports

Here’s the list of languages and files supported by PreviewCode:

  • ActionScript (.as)
  • Ada (.ads, .adb)
  • AppleScript (.applescript)
  • Arduino (.ino)
  • Basic (.bas)
  • Brainfuck (.b, .bf)
  • C (.c, .h)
  • C++ (.cpp, .hpp)
  • C# (.csx)
  • Clojure (.clj, .cljs, .cljc, .edn)
  • CoffeeScript (.coffee)
  • Dart (.dart)
  • Dylan (.dylan, .lid)
  • Elixir (.ex, .exs)
  • Erlang (.erl, .hrl)
  • Fortran (.for)
  • F# (.fs, .fsx, .fsi, .fsscript)
  • Go (.go)
  • Haskell (.hs, .lhs)
  • Java (.java)
  • JavaScript (.js)
  • Julia (.jl)
  • Kotlin (.kt, .kts, .ktm)
  • Lisp (.lisp, .lsp, .l, .cl, .fasl)
  • Lua (.lua)
  • Objective-C (.m)
  • Pascal (.pas)
  • Perl (.perl)
  • PHP (.php)
  • Python (.py)
  • Ruby (.rb)
  • Rust (.rs)
  • Swift (.swift)
  • TypeScript (.tsx)
  • Visual Basic Script (.vbs)
  • Bash (.sh)
  • C Shell (.csh)
  • Korn Shell (.ksh)
  • TCSH (.tsch)
  • Z Shell (.zsh)
  • ARM Assembler (.s)
  • x86-64 Assembler (.asm, .nasm)
  • CSS (.css)
  • LaTex (.tex)
  • Protobuf (.proto)
  • SASS/SCSS (.scss, .sass)
  • SQL script (.sql)
  • Twig (.twig)

Incidentally, my other PreviewApps, PreviewMarkdown and PreviewYaml, have both been recently updated too: patch updates that improve their stability and add some under-the-hood enhancements derived from the work on PreviewCode. You can get them all from the Mac App Store:

The source is available on GitHub.