How to re-export #%module-begin etc from scribble/text?

103 Views Asked by At

I want a language like scribble/text but with some additional functions offered. This is what I've tried:

#lang racket/base

(require scribble/text)
(provide (all-from-out scribble/text)
  hello)

(define (hello name)
  (format "Hello ~a!" name))

When I try to run a module written in this language, I get a message saying that there is no #%module-begin binding in the module's language.

I assume that scribble/text has a binding for #%module-begin, else how does it work when I use it as a #lang?

Maybe scribble/text knows that I am importing it using 'require' rather than as a #lang, and so I don't automatically get the #% macros? If that's the case, then how would I get them and re-export them?

Or is something else happening here?

1

There are 1 best solutions below

2
Alex Knauth On BEST ANSWER

The language for #lang scribble/text and the library for (require scribble/text) are different modules. The library version doesn't provide #%module-begin or the other bindings from racket:

When scribble/text is used via require instead of #lang, then .... it does not include the bindings of racket/base ....

The module-language #lang scribble/text actually uses is scribble/text/lang. So you can fix your module-language like this:

#lang racket/base

(require scribble/text/lang)
(provide (all-from-out scribble/text/lang)
         hello)

(define (hello name)
  (format "Hello ~a!" name))

However, the module scribble/text/lang is undocumented, so use at your own risk.