diff --git a/collects/scribble/base-render.rkt b/collects/scribble/base-render.rkt index f0241ffe..ed76353a 100644 --- a/collects/scribble/base-render.rkt +++ b/collects/scribble/base-render.rkt @@ -72,7 +72,8 @@ (define/public (format-number number sep) (if (or (null? number) - (andmap not number) + (andmap (lambda (x) (or (not x) (equal? x ""))) + number) (and (not (car number)) (not (ormap number? number)))) null @@ -81,7 +82,10 @@ string-append (map (lambda (n) (if (number? n) (format "~a." n) "")) (reverse (cdr number)))) - (if (car number) (format "~a." (car number)) ""))]) + (if (and (car number) + (not (equal? "" (car number)))) + (format "~a." (car number)) + ""))]) (substring s 0 (sub1 (string-length s)))) sep))) @@ -520,7 +524,9 @@ (define next-sub-pos (collect-part s d p-ci (cons (if hidden-number? - #f + (if sub-grouper? + "" + #f) (if sub-grouper? (number->roman pos) pos)) @@ -972,9 +978,8 @@ (not (= base-len (sub1 (length number)))))) (positive? depth)) (apply append (map (lambda (p) - (if (part-style? p 'toc-hidden) - null - (generate-toc p ri base-len #f quiet (sub1 depth) prefixes))) + (generate-toc p ri base-len (part-style? p 'toc-hidden) + quiet (sub1 depth) prefixes)) (part-parts part))) null)]) (if skip? diff --git a/collects/scribble/html-render.rkt b/collects/scribble/html-render.rkt index 3976cd66..6d89789c 100644 --- a/collects/scribble/html-render.rkt +++ b/collects/scribble/html-render.rkt @@ -517,10 +517,22 @@ (define/public (nearly-top? d ri top) #f) + (define hidden-memo (make-weak-hasheq)) + (define/public (all-toc-hidden? p) + (hash-ref hidden-memo + p + (lambda () + (define h? (and (part-style? p 'toc-hidden) + (andmap (lambda (s) (all-toc-hidden? s)) + (part-parts p)))) + (hash-set! hidden-memo p h?) + h?))) + (define/private (render-onthispage-contents d ri top box-class sections-in-toc?) - (if (ormap (lambda (p) (or (part-whole-page? p ri) - (part-style? p 'toc-hidden))) - (part-parts d)) + (if (andmap (lambda (p) (or (part-whole-page? p ri) + (and (part-style? p 'toc-hidden) + (all-toc-hidden? p)))) + (part-parts d)) null (let ([nearly-top? (lambda (d) ;; If ToC would be collapsed, then @@ -560,18 +572,22 @@ (table-blockss table))) (define ps ((if (nearly-top? d) values cdr) - (let flatten ([d d][prefixes null][top? #t]) + (let flatten ([d d] [prefixes null] [top? #t]) (let ([prefixes (if (and (not top?) (part-tag-prefix d)) (cons (part-tag-prefix d) prefixes) prefixes)]) (append* ;; don't include the section if it's in the TOC - (if (nearly-top? d) null (list (cons d prefixes))) + (if (or (nearly-top? d) + (part-style? d 'toc-hidden)) + null + (list (cons d prefixes))) ;; get internal targets: (map (lambda (v) (cons v prefixes)) (append-map block-targets (part-blocks d))) (map (lambda (p) (if (or (part-whole-page? p ri) - (part-style? p 'toc-hidden)) - null + (and (part-style? p 'toc-hidden) + (all-toc-hidden? p))) + null (flatten p prefixes #f))) (part-parts d))))))) (define any-parts? (ormap (compose part? car) ps)) @@ -1464,7 +1480,8 @@ part-whole-page? format-number install-extra-files - report-output?) + report-output? + all-toc-hidden?) (define/override (get-suffix) #"") diff --git a/collects/scribble/latex-render.rkt b/collects/scribble/latex-render.rkt index 4c39f9bd..196946e0 100644 --- a/collects/scribble/latex-render.rkt +++ b/collects/scribble/latex-render.rkt @@ -166,6 +166,7 @@ [else (define no-number? (and (pair? number) (or (not (car number)) + (equal? "" (car number)) ((length number) . > . 3)))) (define no-toc? (part-style? d 'toc-hidden)) (define (show-number) diff --git a/collects/scribblings/scribble/core.scrbl b/collects/scribblings/scribble/core.scrbl index 0594cdf6..09e7f8d4 100644 --- a/collects/scribblings/scribble/core.scrbl +++ b/collects/scribblings/scribble/core.scrbl @@ -1016,9 +1016,10 @@ Computed for each part by the @techlink{collect pass}. The length of the @racket[number] list indicates the section's nesting depth. Numbers in @racket[number] correspond to the section's number, -it's parent's number, etc. A string is used for a @racket['grouping] -section, and @racket[#f] is used in place of all numbers for an -unnumbered section.} +it's parent's number, etc. A non-empty string is used for a +@racket['grouping] section. For an unnumbered section, @racket[#f] is +used in place of all numbers and @racket[""] in place of all non-empty +strings.} @defstruct[target-url ([addr path-string?])]{