[plt-scheme] export code (with syntax and stuff) to HTML

From: Noel Welsh (noelwelsh at gmail.com)
Date: Fri Dec 4 11:47:53 EST 2009

Below is some rather old code I wrote to include a file into a
Scribble schemeblock.

Example usage:


(Of course you could just call it from Scheme as normal. I.e.
(include-schemeblock "zero.ss"))

I have not tested it on a recent build.


(module util mzscheme

  (planet "port.ss" ("schematics" "port.plt" 1)))

  (only (lib "manual.ss" "scribble") schemeblock))

 (provide include-schemeblock)

 (define-syntax (include-schemeblock stx)
   (syntax-case stx ()
     [(include-schemeblock file-name)
      (let ([file-name (syntax-object->datum (syntax file-name))])
            ([(e0 e1 ...)
              (with-input-from-file file-name
                (lambda ()
                  (port-count-lines! (current-input-port))
                   (lambda (p) (read-syntax file-name p))
             (schemeblock e0 e1 ...)))))]))


On Thu, Dec 3, 2009 at 7:01 PM, Todd O'Bryan <toddobryan at gmail.com> wrote:
> Yeah. I think that only works within a Scribble document, though.
> Is it as simple as reading in a BeginnerStudent file, putting #lang
> scribble at the beginning, wrapping it in (scheme-block0 ...) and
> outputting the result to an HTML file? Of course, this would rely on
> the Scribble CSS and would add links for all the functions.
> I guess I just want something that would put everything in a
> pre-formatted block and attach divs to get the right syntax coloring.
> If such a thing doesn't exist, I don't mind trying to figure out how to do it.
> Todd

Posted on the users mailing list.