Scribble for interaction

Suppose I want to use scribble in a non-book context.
For example, for writing messages to be written out during an interactive session with a user.
Its tools for generating and formatting text and for embedding the output of arbitrary Racket expressions could be valuable for this.
I'd be delighted to have it produce a HTML or X-expressions and be able to write that out to an output stream or to a web browser using other means.
But Scribble seems to be set up to produce an entire book as a single file or entire directory of interlinked files -- a rather different scale of operation.

How to do this piecemeal? Is it even conceptually possible with the present structure of Scribble?

You could have a look at the low-level Scribble API (https://docs.racket-lang.org/scribble/internals.html), the pre-processor languages (https://docs.racket-lang.org/scribble-pp/index.html), and the way include-template is built (https://docs.racket-lang.org/web-server/templates.html#%28form._%28%28lib._web-server%2Ftemplates..rkt%29._include-template%29%29) ?

Building on @benknoble's suggestions, I'd particularly suggest you look at the section “Parts, Flows, Blocks, and Paragraphs”, which presents the structures of Scribble's document model, and the introduction to the “Structures and Processing” section, which introduces the traverse, collect, resolve, and render passes for managing cross-reference information.

While it's almost certainly possible to express your interactive messages in terms of those constructs, I don't think they'd be an especially good match for that sort of problem.

Instead, you may want to borrow the parts of Scribble (and ideas from Scribble) that are useful, especially @-expressions, but not “use Scribble” in the sense of the #lang and API that we often use for writing documentation.

You might also be interested in the Simple Tree Text Markup or raart libraries, though neither target HTML out of the box.