I often quote snippets of Common Lisp in my blog. I thought it'd be cool if I could colorize them, so I generated this app that takes Common Lisp and outputs a syntax colored version in standalone HTML suitable for pasting into a blog. The output HTML has a ton of <span> tags that apply a color style to the text. No stylesheet is necessary.
3 comments:
There's also highlight-lisp: https://github.com/orthecreedence/highlight-lisp it has themes and it can highlight matching parens.
Don't use a LLM to do syntax highlighting, that ridiculously overdoing it and non-deterministic! What's wrong with simply using Pygments or even emacs in batch mode (cf https://world-playground-deceit.net/blog/2025/07/emacs-htmlize-as-batch-script.html).
Also, using external CSS is probably a better idea, to avoid HTML size explosion.
I agree that using an LLM to do syntax highlighting is absurd. This was an exercise in seeing if it would work. As you pointed out, it is non-deterministic.
I don't think we can avoid HTML size explosion, though. There are still going to be a ton of span tags, and whether they have "color" or "class" is going to be about the same.
Nothing wrong with doing it with Pygments or emacs in batch mode, just wanted to see if it would work this way.
Post a Comment