From 6a20d8c2fa286d9a08425217140c102aba254ba7 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 18 Apr 2008 18:49:23 +0000 Subject: [PATCH] sgl docs svn: r9362 original commit: 82c212625b41758f99920900d0477d37b4414504 --- collects/scribble/base-render.ss | 82 ++++++++++++++++--------------- collects/scribble/basic.ss | 10 ++-- collects/scribble/decode.ss | 2 +- collects/scribble/html-render.ss | 2 +- collects/scribble/latex-render.ss | 2 +- 5 files changed, 51 insertions(+), 47 deletions(-) diff --git a/collects/scribble/base-render.ss b/collects/scribble/base-render.ss index 3ade2a64..f4707b88 100644 --- a/collects/scribble/base-render.ss +++ b/collects/scribble/base-render.ss @@ -407,61 +407,65 @@ ;; ---------------------------------------- - (define/private (do-table-of-contents part ri delta quiet) + (define/private (do-table-of-contents part ri delta quiet depth) (make-table #f (generate-toc part ri (+ delta (length (collected-info-number (part-collected-info part ri)))) #t - quiet))) + quiet + depth))) (define/public (table-of-contents part ri) - (do-table-of-contents part ri -1 not)) + (do-table-of-contents part ri -1 not +inf.0)) - (define/public (local-table-of-contents part ri) - (table-of-contents part ri)) + (define/public (local-table-of-contents part ri style) + (do-table-of-contents part ri -1 not (if (eq? style 'immediate-only) + 1 + +inf.0))) (define/public (quiet-table-of-contents part ri) - (do-table-of-contents part ri 1 (lambda (x) #t))) + (do-table-of-contents part ri 1 (lambda (x) #t) +inf.0)) - (define/private (generate-toc part ri base-len skip? quiet) + (define/private (generate-toc part ri base-len skip? quiet depth) (let* ([number (collected-info-number (part-collected-info part ri))] [subs - (if (quiet (and (part-style? part 'quiet) - (not (= base-len (sub1 (length number)))))) - (apply append (map (lambda (p) - (generate-toc p ri base-len #f quiet)) - (part-parts part))) - null)]) + (if (and (quiet (and (part-style? part 'quiet) + (not (= base-len (sub1 (length number)))))) + (positive? depth)) + (apply append (map (lambda (p) + (generate-toc p ri base-len #f quiet (sub1 depth))) + (part-parts part))) + null)]) (if skip? - subs - (let ([l (cons - (list (make-flow - (list - (make-paragraph + subs + (let ([l (cons + (list (make-flow (list - (make-element - 'hspace - (list (make-string (* 2 (- (length number) - base-len)) - #\space))) - (make-link-element - (if (= 1 (length number)) "toptoclink" "toclink") - (append - (format-number - number - (list (make-element 'hspace '(" ")))) - (or (part-title-content part) '("???"))) - (car (part-tags part)))))))) - subs)]) - (if (and (= 1 (length number)) - (or (not (car number)) ((car number) . > . 1))) - (cons (list (make-flow - (list (make-paragraph - (list (make-element 'hspace (list ""))))))) - l) - l))))) + (make-paragraph + (list + (make-element + 'hspace + (list (make-string (* 2 (- (length number) + base-len)) + #\space))) + (make-link-element + (if (= 1 (length number)) "toptoclink" "toclink") + (append + (format-number + number + (list (make-element 'hspace '(" ")))) + (or (part-title-content part) '("???"))) + (car (part-tags part)))))))) + subs)]) + (if (and (= 1 (length number)) + (or (not (car number)) ((car number) . > . 1))) + (cons (list (make-flow + (list (make-paragraph + (list (make-element 'hspace (list ""))))))) + l) + l))))) ;; ---------------------------------------- diff --git a/collects/scribble/basic.ss b/collects/scribble/basic.ss index bc5e6ed5..33e24c4f 100644 --- a/collects/scribble/basic.ss +++ b/collects/scribble/basic.ss @@ -170,13 +170,13 @@ (define (clean-up s) ;; Remove leading spaces, which might appear there due to images or something ;; else that gets dropped in string form. - (regexp-replace* #rx"^ +" s "")) + (regexp-replace #rx"^ +" s "")) (define (record-index word-seq element-seq tag content) (make-index-element #f (list (make-target-element #f content `(idx ,tag))) `(idx ,tag) - (map clean-up word-seq) + word-seq element-seq #f)) @@ -191,7 +191,7 @@ (define (as-index . s) (let ([key (make-generated-tag)] [content (decode-content s)]) - (record-index (list (content->string content)) + (record-index (list (clean-up (content->string content))) (if (= 1 (length content)) content (list (make-element #f content))) @@ -294,7 +294,7 @@ (lambda (renderer part ri) (send renderer table-of-contents part ri)))) -(define (local-table-of-contents) +(define (local-table-of-contents #:style [style #f]) (make-delayed-block (lambda (renderer part ri) - (send renderer local-table-of-contents part ri)))) + (send renderer local-table-of-contents part ri style)))) diff --git a/collects/scribble/decode.ss b/collects/scribble/decode.ss index 6388f6b0..68ea5103 100644 --- a/collects/scribble/decode.ss +++ b/collects/scribble/decode.ss @@ -89,7 +89,7 @@ (cons (make-index-element #f null (car tags) (list (regexp-replace - #px"^(?:A|An|The)\\s" (content->string title) "")) + #px"^\\s+(?:(?:A|An|The)\\s)?" (content->string title) "")) (list (make-element #f title)) (make-part-index-desc)) l) diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index 85d981ea..de3fe3e6 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -889,7 +889,7 @@ (cond [(string? i) (let ([m (and (extra-breaking?) - (regexp-match-positions #rx"[-:/+]" i))]) + (regexp-match-positions #rx"[-:/+_]|[a-z](?=[A-Z])" i))]) (if m (list* (substring i 0 (cdar m)) ;; Most browsers wrap after a hyphen. The diff --git a/collects/scribble/latex-render.ss b/collects/scribble/latex-render.ss index 3eaf7b86..dcfd4cc2 100644 --- a/collects/scribble/latex-render.ss +++ b/collects/scribble/latex-render.ss @@ -382,7 +382,7 @@ ;; FIXME: isn't local to the section (make-toc-paragraph null)) - (define/override (local-table-of-contents part ri) + (define/override (local-table-of-contents part ri style) (make-paragraph null)) ;; ----------------------------------------