hyper-literate/collects/scribble/docreader.ss
Matthew Flatt b134592f8f v3.99.0.2
svn: r7706

original commit: 39cedb62edf9258b051a22a29a90be9c6841956f
2007-11-13 12:40:00 +00:00

25 lines
744 B
Scheme

(module docreader scheme/base
(require (prefix-in scribble: "reader.ss"))
(provide (rename-out [*read read])
(rename-out [*read-syntax read-syntax]))
(define (*read [inp (current-input-port)])
(wrap inp (scribble:read-inside inp)))
(define (*read-syntax [src #f] [port (current-input-port)])
(wrap port (scribble:read-inside-syntax src port)))
(define (wrap port body)
(let* ([p-name (object-name port)]
[name (if (path? p-name)
(let-values ([(base name dir?) (split-path p-name)])
(string->symbol (path->string (path-replace-suffix name #""))))
'page)]
[id 'doc])
`(module ,name scribble/doclang
(#%module-begin
,id ()
. ,body)))))