Rendering `6/3` in code example at prompt

With the help of scribble/example, I try to render this Scribble code:

@examples[
  (integer? 6/3)]

This renders as

> (integer? 2)
#t

presumably because 6/3 is evaluated before rendering, maybe even before Scribble sees it, but I would like to have the Scribble code rendered as

> (integer? 6/3)
#t

Is this possible with scribble/example? If not or if it's complicated, I'm also interested in other approaches.

1 Like

I see I can render

(integer? 6/3)

outside @examples with

@code{(integer? 6/3)}

Is there a way to "escape" to @code from the input datum in @examples?

I found #:escape in the documentation of @examples, but I haven't been able to figure out how to use it.

You'd use #:escape like this (untested):

@examples[#:escape unsyntax
(eval:alts (unsyntax (code "(integer? 6/3)")) (integer? 6/3))]
1 Like

This works indeed; thank you! :slight_smile:

@examples[
  #:escape unsyntax
  (eval:alts (unsyntax (code "6/3")) 6/3)
  (eval:alts (unsyntax (code "(integer? 6/3)")) (integer? 6/3))]

renders as

> 6/3
2
> (integer? 6/3)
#t

Technically, it seems possible to leave out the #:escape unsyntax because it's the default value, but maybe it's good to have it for extra clarity.

1 Like