From 4c40ffdd26203323f0054f6ba359d518667aee9c Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 25 Jun 2007 06:37:25 +0000 Subject: [PATCH] doc work (start on module guide) svn: r6730 original commit: f7bf029234e0d3ce26e4200094b1986f5f538689 --- collects/scribble/html-render.ss | 2 +- collects/scribble/latex-render.ss | 2 ++ collects/scribble/manual.ss | 19 +++++++---- collects/scribble/scheme.ss | 54 ++++++++++++++++++------------- collects/scribble/scribble.css | 7 +++- 5 files changed, 52 insertions(+), 32 deletions(-) diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index ea2dcc25..102a6a69 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -326,7 +326,7 @@ fns))) (define/override (part-whole-page? d) - (= 2 (collecting-sub))) + ((collecting-sub) . <= . 2)) (define/private (toc-part? d) (and (styled-part? d) diff --git a/collects/scribble/latex-render.ss b/collects/scribble/latex-render.ss index a81dd751..983afad1 100644 --- a/collects/scribble/latex-render.ss +++ b/collects/scribble/latex-render.ss @@ -50,6 +50,7 @@ (define-color "schemeresult" "ResultColor") (define-color "schemestdout" "OutputColor") (define-color "schememeta" "IdentifierColor") + (define-color "schememod" "black") (define-color "schemevariablecol" "IdentifierColor") (printf "\\newcommand{\\schemevariable}[1]{{\\schemevariablecol{\\textsl{#1}}}}\n") (define-color "schemeerrorcol" "red") @@ -232,6 +233,7 @@ [(ldquo) "``"] [(rdquo) "''"] [(rsquo) "'"] + [(prime) "$'$"] [(rarr) "$\\rightarrow$"]))] [else (display-protected (format "~s" i))]) null) diff --git a/collects/scribble/manual.ss b/collects/scribble/manual.ss index b39e6a5c..2204a638 100644 --- a/collects/scribble/manual.ss +++ b/collects/scribble/manual.ss @@ -94,7 +94,7 @@ (provide onscreen menuitem defterm schemefont schemevalfont schemeresultfont schemeidfont - schemeparenfont schemekeywordfont schememetafont + schemeparenfont schemekeywordfont schememetafont schememodfont file exec link procedure idefterm) @@ -120,6 +120,8 @@ (make-element "schemeparen" (decode-content str))) (define (schememetafont . str) (make-element "schememeta" (decode-content str))) + (define (schememodfont . str) + (make-element "schememod" (decode-content str))) (define (schemekeywordfont . str) (make-element "schemekeyword" (decode-content str))) (define (file . str) @@ -808,12 +810,15 @@ (let loop ([i i]) (cond [(string? i) - (let ([m (regexp-match #rx"^(.*)([()])(.*)$" i)]) - (if m - (append (loop (cadr m)) - (list (caddr m)) - (loop (cadddr m))) - (list (make-element 'italic (list i)))))] + (cond + [(regexp-match #rx"^(.*)([()])(.*)$" i) + => (lambda (m) + (append (loop (cadr m)) + (list (caddr m)) + (loop (cadddr m))))] + [else + (list (make-element 'italic (list i)))])] + [(eq? i 'rsquo) (list 'prime)] [else (list i)]))) c))))) diff --git a/collects/scribble/scheme.ss b/collects/scribble/scheme.ss index d69d6b37..6b4066b4 100644 --- a/collects/scribble/scheme.ss +++ b/collects/scribble/scheme.ss @@ -49,6 +49,8 @@ (define-struct (sized-element element) (length)) + (define-struct spaces (pre cnt post)) + (define (typeset c multi-line? prefix1 prefix suffix color?) (let* ([c (syntax-ize c 0)] [content null] @@ -78,26 +80,35 @@ [(and (element? v) (= 1 (length (element-content v)))) (sz-loop (car (element-content v)))] + [(spaces? v) + (+ (sz-loop (spaces-pre v)) + (spaces-cnt v) + (sz-loop (spaces-post v)))] [else 1])))] [(v cls len) (unless (equal? v "") - (if (equal? v "\n") - (if multi-line? - (begin - (finish-line!) - (out prefix cls)) - (out " " cls)) - (begin - (set! content (cons ((if highlight? - (lambda (c) - (make-element "highlighted" (list c))) - values) - (if color? - (make-element cls (list v)) - (make-element #f (list v)))) - content)) - (set! dest-col (+ dest-col len)))))])) - (define advance + (cond + [(spaces? v) + (out (spaces-pre v) cls 0) + (out (make-element 'hspace (list (make-string (spaces-cnt v) #\space))) #f 0) + (out (spaces-post v) cls len)] + [(equal? v "\n") + (if multi-line? + (begin + (finish-line!) + (out prefix cls)) + (out " " cls))] + [else + (set! content (cons ((if highlight? + (lambda (c) + (make-element "highlighted" (list c))) + values) + (if color? + (make-element cls (list v)) + (make-element #f (list v)))) + content)) + (set! dest-col (+ dest-col len))]))])) + (define advance (case-lambda [(c init-line! delta) (let ([c (+ delta (syntax-column c))] @@ -168,12 +179,9 @@ (define (literalize-spaces i) (let ([m (regexp-match-positions #rx" +" i)]) (if m - (make-element - #f - (list (literalize-spaces (substring i 0 (caar m))) - (make-element 'hspace - (list (substring i (caar m) (cdar m)))) - (literalize-spaces (substring i (cdar m))))) + (make-spaces (literalize-spaces (substring i 0 (caar m))) + (- (cdar m) (caar m)) + (literalize-spaces (substring i (cdar m)))) i))) (define (loop init-line! quote-depth) (lambda (c) diff --git a/collects/scribble/scribble.css b/collects/scribble/scribble.css index 1ddbb269..58a00a9c 100644 --- a/collects/scribble/scribble.css +++ b/collects/scribble/scribble.css @@ -41,7 +41,7 @@ width: 10em; margin-right: 2em; text-align: left; - background-color: #ddffdd; + background-color: #F5F5DC; } .tocviewtitle { @@ -237,6 +237,11 @@ font-family: Courier; font-size: 80%; } + .schememod { + color: black; + font-family: Courier; font-size: 80%; + } + .schemeopt { color: black; }