reformat using #lang

svn: r14103

original commit: eb62b52d3af646a32eb842087c91743bdb815f94
This commit is contained in:
Eli Barzilay 2009-03-15 01:06:57 +00:00
parent 7d488fa96b
commit 208edf6016

View File

@ -1,22 +1,20 @@
#lang scheme/base
(module utils scheme/base (require scribble/struct
(require scribble/struct
scribble/manual scribble/manual
(prefix-in scheme: scribble/scheme) (prefix-in scheme: scribble/scheme)
(prefix-in scribble: scribble/reader)) (prefix-in scribble: scribble/reader))
(define-syntax bounce-for-label (define-syntax bounce-for-label
(syntax-rules (all-except) (syntax-rules (all-except)
[(_ (all-except mod (id ...) (id2 ...))) [(_ (all-except mod (id ...) (id2 ...)))
(begin (begin (require (for-label (except-in mod id ...)))
(require (for-label (except-in mod id ...)))
(provide (for-label (except-out (all-from-out mod) id2 ...))))] (provide (for-label (except-out (all-from-out mod) id2 ...))))]
[(_ mod) (begin [(_ mod) (begin (require (for-label mod))
(require (for-label mod))
(provide (for-label (all-from-out mod))))] (provide (for-label (all-from-out mod))))]
[(_ mod ...) (begin (bounce-for-label mod) ...)])) [(_ mod ...) (begin (bounce-for-label mod) ...)]))
(bounce-for-label (all-except scheme (link) ()) (bounce-for-label (all-except scheme (link) ())
scribble/struct scribble/struct
scribble/base-render scribble/base-render
scribble/decode scribble/decode
@ -25,49 +23,39 @@
scribble/eval scribble/eval
scribble/bnf) scribble/bnf)
(provide scribble-examples litchar/lines) (provide scribble-examples litchar/lines)
(define (litchar/lines . strs) (define (litchar/lines . strs)
(let ([strs (regexp-split #rx"\n" (apply string-append strs))]) (let ([strs (regexp-split #rx"\n" (apply string-append strs))])
(if (= 1 (length strs)) (if (= 1 (length strs))
(litchar (car strs)) (litchar (car strs))
(make-table (make-table
#f #f
(map (lambda (s) (map (lambda (s)
(list (make-flow (list (make-paragraph (let ([line (if (string=? s "")
(if (string=? s "")
'(nbsp) ; needed for IE '(nbsp) ; needed for IE
(list (litchar s)))))))) (list (litchar s)))])
(list (make-flow (list (make-paragraph line))))))
strs))))) strs)))))
(define (as-flow e) (define (as-flow e)
(make-flow (list (if (block? e) (make-flow (list (if (block? e) e (make-paragraph (list e))))))
e
(make-paragraph (list e))))))
(define spacer (hspace 2)) (define spacer (hspace 2))
(define ((norm-spacing base) p) (define ((norm-spacing base) p)
(cond (cond [(and (syntax->list p) (not (null? (syntax-e p))))
[(and (syntax->list p)
(not (null? (syntax-e p))))
(let loop ([e (syntax->list p)] (let loop ([e (syntax->list p)]
[line (syntax-line (car (syntax-e p)))] [line (syntax-line (car (syntax-e p)))]
[pos base] [pos base]
[second #f] [second #f]
[accum null]) [accum null])
(cond (if (null? e)
[(null? e)
(datum->syntax (datum->syntax
p p (reverse accum)
(reverse accum) (list (syntax-source p) (syntax-line p) base (add1 base)
(list (syntax-source p)
(syntax-line p)
base
(add1 base)
(- pos base)) (- pos base))
p)] p)
[else
(let* ([v ((norm-spacing (if (= line (syntax-line (car e))) (let* ([v ((norm-spacing (if (= line (syntax-line (car e)))
pos pos
(or second pos))) (or second pos)))
@ -77,19 +65,13 @@
(syntax-line v) (syntax-line v)
next-pos next-pos
(or second next-pos) (or second next-pos)
(cons v accum)))]))] (cons v accum)))))]
[else [else (datum->syntax
(datum->syntax p (syntax-e p)
p (list (syntax-source p) (syntax-line p) base (add1 base) 1)
(syntax-e p)
(list (syntax-source p)
(syntax-line p)
base
(add1 base)
1)
p)])) p)]))
(define (scribble-examples . lines) (define (scribble-examples . lines)
(define reads-as (make-paragraph (list spacer "reads as" spacer))) (define reads-as (make-paragraph (list spacer "reads as" spacer)))
(let* ([lines (apply string-append lines)] (let* ([lines (apply string-append lines)]
[p (open-input-string lines)]) [p (open-input-string lines)])
@ -117,4 +99,4 @@
"")] "")]
[reads-as (if x reads-as "")]) [reads-as (if x reads-as "")])
(map as-flow (list spacer @expr reads-as sexpr)))) (map as-flow (list spacer @expr reads-as sexpr))))
r))))))))) r))))))))