bkyk8rc3zvpnsf5inmcqq4n3k98cv6hj-my-site-hyper-literate-git.test.suzanne.soy-0.0.1

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit cda63b21deb39cf7d87a696773ccb0d0e9be490c
parent fd7e8c5bc36c9a4d16fb1ed8ed06a6540a602b87
Author: Matthew Flatt <mflatt@racket-lang.org>
Date:   Thu, 27 Jul 2017 07:33:26 -0600

adjust section counting when 'grouper and 'unnumbered are mixed

I'm not certain that mixing 'grouper and non-'grouper parts at a given
level makes sense. Still, this adjustment brings Scribble section
counting more in line with Latex, so that section links are less
likely to have the wrong number label.

Diffstat:
Mscribble-lib/scribble/base-render.rkt | 23+++++++++++++++++------
Ascribble-test/tests/scribble/docs/grouper2.scrbl | 29+++++++++++++++++++++++++++++
Ascribble-test/tests/scribble/docs/grouper2.txt | 28++++++++++++++++++++++++++++
3 files changed, 74 insertions(+), 6 deletions(-)

diff --git a/scribble-lib/scribble/base-render.rkt b/scribble-lib/scribble/base-render.rkt @@ -606,17 +606,28 @@ number)) sub-pos sub-numberers)) + (define unnumbered-and-unnumbered-subsections? + (and (not sub-grouper?) + ;; If this section wasn't marked with + ;; 'grouper but is unnumbered and doesn't + ;; have numbered subsections, then didn't + ;; reset counters, so propagate the old + ;; position + (and unnumbered? + (= next-sub-pos sub-pos)))) (loop (cdr parts) (if (or unnumbered? numberer) pos (add1 pos)) next-numberers - (if sub-grouper? - next-sub-pos - 1) - (if sub-grouper? - next-sub-numberers - #hash()))))))) + (cond + [sub-grouper? next-sub-pos] + [unnumbered-and-unnumbered-subsections? sub-pos] + [else 1]) + (cond + [sub-grouper? next-sub-numberers] + [unnumbered-and-unnumbered-subsections? sub-numberers] + [else #hash()]))))))) (let ([prefix (part-tag-prefix d)]) (for ([(k v) (collect-info-ht p-ci)]) (when (cadr k) diff --git a/scribble-test/tests/scribble/docs/grouper2.scrbl b/scribble-test/tests/scribble/docs/grouper2.scrbl @@ -0,0 +1,29 @@ +#lang scribble/base + +@title{Example} + +@table-of-contents[] + +@; ---------------------------------------- + +@section[#:style 'grouper]{Arbitrarily Small Data} + +@subsection[#:tag "A"]{A} + +See @secref["A"] and @secref["B"]. + +@; ---------------------------------------- + +@section[#:style '(unnumbered)]{Intermezzo} + +@subsection[#:style '(unnumbered)]{More} + +Nothing here. + +@; ---------------------------------------- + +@section[#:style 'grouper]{Arbitrarily Large Data} + +@subsection[#:tag "B"]{B} + +See @secref["A"] and @secref["B"]. diff --git a/scribble-test/tests/scribble/docs/grouper2.txt b/scribble-test/tests/scribble/docs/grouper2.txt @@ -0,0 +1,28 @@ +Example + +    I Arbitrarily Small Data +      1 A + +    Intermezzo +      More + +    II Arbitrarily Large Data +      2 B + +I. Arbitrarily Small Data + +1. A + +See A and B. + +Intermezzo + +More + +Nothing here. + +II. Arbitrarily Large Data + +2. B + +See A and B.