EmbedBox: Lightweight syntax-highlighted embeds
I was planning posting about something else yesterday, but I wanted to show some GitLab code in a syntax-highlighted embed. When I wasn't able to figure out how to do that, I ended up writing EmbedBox.
The whole thing is best explained with an example. Have an embed:
(Can't see the above? Check out the original file here)
Pretty cool, right? The above is the default settings file for EmbedBox. Given any URL (e.g. https://raw.githubusercontent.com/sbrl/EmbedBox/master/src/settings.default.toml), it will generate a syntax-highlighted embed for it.
It does so using highlight.php to do the syntax-highlighting server-side, Stash PHP for the cache, and without any Javascript in the embed itself.
It comes with a web interface that generates the embed code given the input URL and a few other settings and shows a preview of what it'll look like.
EmbedBox is open-source too (under the Mozilla Public Licence 2.0), so you're welcome to setup your own instance!
To do so, check out the code here: https://github.com/sbrl/EmbedBox/
The installation instructions should be pretty straightforward in theory, but if you get stuck please open an issue.
Now that I've implemented EmbedBox, you can expect to see it appear in future blog posts. I'm planning to write about my organise-photos script in the near future, so expect a blog post about it soon.
Found this interesting? Got a suggestion? Want to say hi? Comment below!