# Interaction with a reader in scribble

**URL:** <https://racket.discourse.group/t/interaction-with-a-reader-in-scribble/4014>\
**Category:** General\
**Created:** [November 19, 2025, 5:56am UTC](https://racket.discourse.group/t/interaction-with-a-reader-in-scribble/4014 "2025-11-19T05:56:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [November 19, 2025, 5:56am UTC](https://racket.discourse.group/t/interaction-with-a-reader-in-scribble/4014/1 "2025-11-19T05:56:52Z")

</div>

Hi,

is it possible to use interaction in scribble with a reader?, example of what i mean:

```scheme
#lang scribble/manual
@(require scribble/core)
@(require scribble/eval)

@interaction[
#lang reader SRFI-105
(require Scheme+)
{3 · 5 + 2 ³}
]

```

the above example will not parse and use `#lang reader SRFI-105` correctly and will fail compiling the document.

---

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [November 19, 2025, 9:23pm UTC](https://racket.discourse.group/t/interaction-with-a-reader-in-scribble/4014/2 "2025-11-19T21:23:36Z")

</div>

Does the `examples` form from [scribble/example`](https://docs.racket-lang.org/scribble/eval.html#%28form._%28%28lib._scribble%2Fexample..rkt%29._examples%29%29) work?

I honestly don’t know this at all - I just noticed that the docs suggest the scribble/example library should be used instead of scribble/eval.

Regards  
Stephen

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [November 19, 2025, 9:47pm UTC](https://racket.discourse.group/t/interaction-with-a-reader-in-scribble/4014/3 "2025-11-19T21:47:57Z")

</div>

thank for your help Stephen, i tested the sole example of the doc and it does not seems to accept a reader,only a module as racket/base.

This is a bit the problem of Racket, i often encounter, the #lang language or #lang reader program that is so far from sexpr that it could not be used in any context. In fact #lang language could be replaced by (module program-name language... but there is no equivalent for #lang reader a-reader or `#reader a-reader` could not be represented as a sexpr module.

I can not find a solution and i do not think it is possible in Racket.

Damien

---

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [November 20, 2025, 3:28am UTC](https://racket.discourse.group/t/interaction-with-a-reader-in-scribble/4014/4 "2025-11-20T03:28:34Z")

</div>

I don't have all the answers but I have some leads you might want to follow.

It looks like you're not supplying an evaluator to `interaction` (using its `#:eval` argument).

The docs say `interaction` works the same as `examples` (from `scribble/example`) with a few minor changes, so check the docs for `examples`.

The docs for `examples` say you can supply your own evaluator, defined using `make-evaluator`.

I recommend reading [the docs for `make-evaluator`](https://docs.racket-lang.org/reference/Sandboxed_Evaluation.html#%28def._%28%28lib._racket%2Fsandbox..rkt%29._make-evaluator%29%29) carefully. Yes they are complicated at first glance but if you want to be doing advanced things with eval'd code this is where the advanced functionality is described in detail.

In particular those docs say that if you supply code to the evaluator as a string or an input port, the code will be read using the function currently stored in [the `sandbox-reader` parameter](https://docs.racket-lang.org/reference/Sandboxed_Evaluation.html#%28def._%28%28lib._racket%2Fsandbox..rkt%29._sandbox-reader%29%29). If you can access the binding for whatever the equivalent of `syntax-read` is for your #lang, you can probably use it with this parameter.

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [November 20, 2025, 7:05am UTC](https://racket.discourse.group/t/interaction-with-a-reader-in-scribble/4014/5 "2025-11-20T07:05:09Z")

</div>

yes i will take a look at that. I have sort of syntax-read of course in the code of SRFI-105, if i find a way to import that in a scribble document,why not?  
for now i just use `codeblock` directives , in my scribble.  
It is amazing i got the idea when i see that when compiling scribble pages to html the system was evauating some expression in codeblock as if the scribble document was code...

i will get back on these possibility later  
thank

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [November 20, 2025, 11:17am UTC](https://racket.discourse.group/t/interaction-with-a-reader-in-scribble/4014/6 "2025-11-20T11:17:36Z")

</div>

i can not find where to use (sandbox-reader proc)  
i read all the doc but it lacks examples.

---

<div class="post-metadata">

**Author:** ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)\
**Post date:** [November 20, 2025, 4:11pm UTC](https://racket.discourse.group/t/interaction-with-a-reader-in-scribble/4014/7 "2025-11-20T16:11:32Z")

</div>

The docs don't always have examples of everything one might want to attempt. In such cases there's no choice but to buckle down and not scan for code to use but thoroughly understand the concepts involved. In this case I was able to cobble this together just by squinting at the docs and trying stuff in DrRacket. I already have an understanding of how to use [parameters](https://docs.racket-lang.org/guide/parameterize.html), which helped quite a bit.

```scheme
#lang scribble/manual

@(require racket/sandbox
         scribble/reader
         scribble/eval)

@(define r (make-at-reader #:inside? #t))
@(define (my-syntax-read in) (syntax-e (r in)))

@(define my-evaluator
  (parameterize ([sandbox-reader my-syntax-read])
    (make-base-eval)))
@(my-evaluator "@require[racket/format]")
@(my-evaluator "@define[(foo v)]{@~a{here's @v !}}")

@interaction[#:eval my-evaluator]{
 @foo{Johnny}
}

```

Note that even though the code I give to `interaction` is in a non-s-expression syntax, `interaction` will always typeset it as an S-expression. Which makes sense because the REPL is always using S-expressions anyway. Here's the HTML rendered result of the above program:

 ![HTML output of above Scribble doc](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/5/5e266b3e0c90cdf459b7981942cfc4adbcf5de0c.png)

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [November 20, 2025, 5:28pm UTC](https://racket.discourse.group/t/interaction-with-a-reader-in-scribble/4014/8 "2025-11-20T17:28:49Z")

</div>

Thank you for your help Joel.

The thing is not easy.

I find a racket discourse post with the same problem that was talking of a solution using a third party library, i suppose this library exists because things are hard. I used [scribble-code-example](https://docs.racket-lang.org/scribble-code-examples/index.html) library.

and inserted in my doc this :

```scheme
@(require scribble-code-examples)

@code-examples[#:lang "reader SRFI-105" #:context #'here]|{
{11 + 2}
}|

```

this times , the library accepts the `#lang reader SRFI-105" and the result is:

![Capture d’écran_2025-11-20_18-00-31](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/2/2245a2c314cdc6fcecf1961aad2ffef74675fe9e.png)

about your solution, i still have dificulties, some hard points are you seem to use make-base-eval but i must write a special evaluator for infix, also i can not rely on the REPL using only sexpr because in my case i use curly infix expressions starting with { }.

Perheaps you can find a solution with your knowledge if i give you the things special to my case but otherwise i will use the third party lib:

in my case there a few points to specialize:

- somewhere there should be `#lang reader SRFI-105` or `#reader SRFI-105` as Racket accept both forms
- in the use by scribble of my SRFI-105 reader the `sandbox-reader` i suppose must be set to the one defined in my reader , which by convention for racket REPL is `read-syntax` but if it is a convention why should we specified it? here is my module definition of SRFI-105:

```scheme
 (module SRFI-105 racket
	

      (provide (rename-out [literal-read read]
                           [literal-read-syntax read-syntax]))

```

`litteral-read-syntax` are defined using `curly-infix-read` one does not have to know this internal definition.  
As it is a convention i suppose that there is no need to specify it in code-examples, or perheaps the library sends the tokens to the reader and just get the result,i do not know.

Unless you have a solution according with this few specifications , i will use code-examples one as it is the only one that works for now.

Again, Joel, thank you for your help.  
Sincere thanks  
Damien
