Use `for-syntax` to import into the transformer environment:

 #lang scribble/base
 @(require (for-syntax racket/base
                       (only-in scribble/reader
                                make-at-reader)))
 @(require racket/include)
 foo
 @(include/reader "si1.inc" (make-at-reader))
 bar


The result of `make-at-reader` starts in S-expression mode where `@`
switches to text mode. You may want "si1.inc" to start out in text
mode, more like `#lang scribble/base`. That's almost as easy as
`(make-at-reader #:inside? #t)`, except that the reader in "inside"
mode returns an empty list for an empty input stream, which doesn't
work quite the right way for `include/reader`. Here's one way to adapt
it:

 @(include/reader "si1.inc"
                  (lambda (src in)
                    (cond
                      [(eof-object? (peek-byte in))
                       eof]
                      [else
                       (cons #'begin
                             ((make-at-reader #:inside? #t) src in))])))


At Mon, 6 Apr 2020 18:27:22 -0400, Hendrik Boom wrote:
> Once again I'm trying to get @(include ...) working in scribble.
> 
> The trouble with just using @(include filepath) in scribble is that
> the included file is read as racket input instead of syntax and 
> semantics instead of wih scribble's syntax.
> 
> So I thought to try include/reader instead; it has an extra parameter
> that can specify how the other file is to be read.
> 
> #lang scribble/base
> @(require scribble/reader)
> @(require racket/include)
> foo
> @(include/reader "si1.inc" (make-at-reader))
> bar
> 
> But this gives me a completely unexpected problem.  It claims 
> make-at-reader is an unbound identifier.
> 
> If I Use it outside the call to include/reader it's *not* unbound.
> 
> The Racket documentation tells me:
> 
>    The reader-expr is evaluated at expansion time in the transformer 
>    environment.
> 
> Is there some way of making this work?
> 
> -- hendrik
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/20200406222722.2dvly3zgoi46iack%
> 40topoi.pooq.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/5e8c6c1f.1c69fb81.6952e.3b87SMTPIN_ADDED_MISSING%40gmr-mx.google.com.

Reply via email to