# How to hilight non-racket code with Scribble?

**URL:** <https://racket.discourse.group/t/how-to-hilight-non-racket-code-with-scribble/2832>\
**Category:** General\
**Tags:** scribble\
**Created:** [March 24, 2024, 9:52pm UTC](https://racket.discourse.group/t/how-to-hilight-non-racket-code-with-scribble/2832 "2024-03-24T21:52:07Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![LiberalArtist](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/liberalartist/32/151_2.png) [@LiberalArtist](https://racket.discourse.group/u/LiberalArtist)\
**Post date:** [March 30, 2024, 3:35am UTC](https://racket.discourse.group/t/how-to-hilight-non-racket-code-with-scribble/2832/4 "2024-03-30T03:35:34Z")

</div>

One approach would be to make a stub `#lang idris2-for-scribble`, give it a [color lexer](https://docs.racket-lang.org/tools/lang-languages-customization.html#%28part._.Syntax_.Coloring%29) that calls Katla, and then use it from Scribble via something like:

```scheme
(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:

> [@Color lexer backup distances and \`dont-stop\`](https://racket.discourse.group/t/color-lexer-backup-distances-and-dont-stop/2170/3):
>
> I think @greghendershott 's advice is good, tho. Processing an entire line at once and putting the processing result into the mode and then returning a sequence of tokens via `dont-stop` until the end of the line seems like a (relatively?) easy way to get something going.

_Beautiful Racket_ has a good introduction to color lexers: [Beautiful Racket: Level up: jsonic revisited](https://beautifulracket.com/jsonic-2/syntax-coloring.html).

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](https://github.com/racket/zuo/tree/main/zuo-doc) (rendered at [Zuo: A Tiny Racket for Scripting](https://docs.racket-lang.org/zuo/)).

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.

---

_[View the full topic](https://racket.discourse.group/t/how-to-hilight-non-racket-code-with-scribble/2832)._
