Lux's goal is to provide a single library to highlight code on websites, in macOS/iOS apps and in terminals.
It is still in development, mainly because the support for several languages will be added before the first stable version.
Still, you can use it already as a Swift package or a command-line tool.
This blog uses Lux to highlight code blocks.
You can download the latest notarized command-line tool as a pkg or zip, and as a tar for Linux distributions (requires Swift to be installed on your Linux distribution).