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

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Fri Dec 4 12:15:47 EST 2009

The Web Server tutorial does that too:

http://svn.plt-scheme.org/plt/trunk//collects/web-server/scribblings/tutorial/tutorial-util.ss

On Fri, Dec 4, 2009 at 9:47 AM, Noel Welsh <noelwelsh at gmail.com> wrote:
> Below is some rather old code I wrote to include a file into a
> Scribble schemeblock.
>
> Example usage:
>
> @include-schemeblock["zero.ss"]
>
> (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.
>
> N.
>
> (module util mzscheme
>
>  (require-for-syntax
>  (planet "port.ss" ("schematics" "port.plt" 1)))
>
>  (require
>  (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))])
>        (with-syntax
>            ([(e0 e1 ...)
>              (with-input-from-file file-name
>                (lambda ()
>                  (port-count-lines! (current-input-port))
>                  (port->list
>                   (lambda (p) (read-syntax file-name p))
>                   (current-input-port))))])
>          (syntax
>           (begin
>             (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
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.