[racket] scribble: @verbatim inside macro

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Nov 24 08:15:22 EST 2011

A [email protected]{ ... @verbatim[]}' doesn't work because `verbatim' generates a
block, which is at the same level as a paragraph and cannot appear
within a paragraph.

Using `begin' works at the top level, since it splices the two blocks
into the top-level flow. Using `list' would work more generally, such
as using `my-example' within a nested flow, since lists are always
spliced.

More likely, though, you want to create a compound paragraph. Whether
there's a visible difference between a "compound paragraph" and a flow
depends on the document style. If the document style uses indenting to
show the start of a new paragraph, then a "compound paragraph" is
indented only at the beginning. (The terminology is unfortunate, and it
probably have been better to use a different name for Scribble's
"paragraph".)

At Wed, 23 Nov 2011 12:46:05 -0700, Jon Rafkind wrote:
> This hack works for now:
> 
> @(define-syntax-rule (my-example stuff)
>    (begin
>      @para{An example}
>      (verbatim stuff)))
> 
> On 11/23/2011 12:26 PM, Jon Rafkind wrote:
> > I want to write a macro in scribble that will output a `verbatim' but I keep 
> getting an error about 'expected pre-content? got #<table>'. What should I do 
> in the macro so that I can output verbatim? I tried various things other than 
> `para' but none seem to work.
> >
> > @(define-syntax-rule (my-example stuff)
> >   @para{An example: @(verbatim stuff)})
> >
> > @my-example{some stuff}
> >
> >
> > $ scribble --pdf main.scrbl
> > para: contract violation, expected: pre-content?, given: #<table>
> >   contract from: <collects>/scribble/base.rkt, blaming:
> >     main.scrbl
> >   contract:
> >     (->*
> >      ()
> >      (#:style (or/c style? string? symbol? #f))
> >      #:rest
> >      (listof pre-content?)
> >      paragraph?)
> >   at: <collects>/scribble/base.rkt:387.2
> >
> > _________________________________________________
> >  For list-related administrative tasks:
> >  http://lists.racket-lang.org/listinfo/users
> 
> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/users


Posted on the users mailing list.