[racket] pretty-printing example output in Scribble manual?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Jan 23 21:31:16 EST 2011

At Sun, 23 Jan 2011 17:03:07 -0500, Richard Cobbe wrote:
> Is there a way to get Scribble's @example form to pretty-print its output?
> [...]
> I'm already using a custom evaluator for the examples, so I looked for a
> way to change that evaluator's printer, but I wasn't able to find anything
> like that in the docs.

The evaluator prints results using `current-print', so install the
pretty printer as `current-print' in the evaluator that you use with
`examples':

#lang scribble/base
@(require scribble/eval)

@(define pp-eval (make-base-eval))
@(interaction-eval
  #:eval pp-eval
  (begin
   (require racket/pretty)
   (current-print pretty-print-handler)
   (pretty-print-columns 20)))

@examples[
 #:eval pp-eval
 (make-vector 20 'x)
]



Posted on the users mailing list.