How to hilight non-racket code with Scribble?

One approach would be to make a stub #lang idris2-for-scribble, give it a color lexer that calls Katla, and then use it from Scribble via something like:

(define (idrisblock . strs)
  (apply typeset-code
         #:keep-lang-line? #f
         "#lang idris2-for-scribble\n"
         strs))

The color lexer protocol is a bit awkward, but, especially if you don't care about interactive use, extending this advice to parse the whole file at once might make it a lot easier:

Beautiful Racket has a good introduction to color lexers: Beautiful Racket: Level up: jsonic revisited.

Depending on how much effort you want to put in, your #lang could also take care of whatever running you want to do, or even make automatic identifier links work. The Zuo documentation is one example of how to make that work for a language not actually implemented in Racket: zuo/zuo-doc at main · racket/zuo · GitHub (rendered at Zuo: A Tiny Racket for Scripting).

Actually, Idris2 has a Racket backend, doesn't it? I haven't looked at its implementation, but that might put developing a real, working #lang idris2 a relatively reasonable project to undertake.

1 Like