Include non-Racket source in Scribble files

61 Views Asked by At

I'm writing documentation, and part of it includes small programs written in languages other than Racket. I can of course include them inline (using @verbatim), but I'd like to be able to at least minimally test/run them, so it'd be much more convenient to store them in separate files and just include the source.

What's the easiest way do that? i.e., I'd like to do something like:

@verbatim|{@include-file{path/to/file.ext}}| (though of course that doesn't quite work) and have the content included, literally. I thought that Ben Greenman's https://gitlab.com/bengreenman/scribble-include-text would do this, but it's behaving oddly, probably because there are character sequences in the file that are not playing well.

1

There are 1 best solutions below

0
On
% cat top.scrbl 
#lang scribble/manual
@(require racket/file)

@(begin
  (verbatim (file->string "side.txt"))
 )
% cat side.txt 
this file
has
newlines and
@something
that looks like racket
but
@(is not)
% scribble --html top.scrbl
 [Output to top.html]

Renders as

enter image description here