fix references lifted to table of contents

Certain lifted reference forms carried the prefix of the original
section, but in general the section needs to be similarly carried for
rendering elements that may contain references.

Also, fix the contract on `elemref` and `elemtag` to use
`taglet?` instead of `tag?`.

Thanks to Dupéron Georges.
This commit is contained in:
Matthew Flatt 2016-10-01 10:51:18 -06:00
parent a69f6c6982
commit 30ae71202d
3 changed files with 12 additions and 11 deletions

View File

@ -691,13 +691,13 @@ renders as a hyperlink with the text:
}|} }|}
@defproc[(elemtag [t (or/c tag? string?)] [pre-content pre-content?] ...) element?]{ @defproc[(elemtag [t (or/c taglet? generated-tag?)] [pre-content pre-content?] ...) element?]{
The tag @racket[t] refers to the content form of The tag @racket[t] refers to the content form of
@racket[pre-content].} @racket[pre-content].}
@defproc[(elemref [t (or/c tag? string?)] [pre-content pre-content?] ... @defproc[(elemref [t (or/c taglet? generated-tag?)] [pre-content pre-content?] ...
[#:underline? underline? any/c #t]) element?]{ [#:underline? underline? any/c #t]) element?]{
The @tech{decode}d @racket[pre-content] is hyperlinked to @racket[t], The @tech{decode}d @racket[pre-content] is hyperlinked to @racket[t],

View File

@ -572,11 +572,11 @@
;; ---------------------------------------- ;; ----------------------------------------
(provide/contract (provide/contract
[elemtag (->* ((or/c tag? string?)) [elemtag (->* ((or/c taglet? generated-tag?))
() ()
#:rest (listof pre-content?) #:rest (listof pre-content?)
element?)] element?)]
[elemref (->* ((or/c tag? string?)) [elemref (->* ((or/c taglet? generated-tag?))
(#:underline? any/c) (#:underline? any/c)
#:rest (listof pre-content?) #:rest (listof pre-content?)
element?)] element?)]

View File

@ -731,24 +731,25 @@
(if (or (nearly-top? d) (if (or (nearly-top? d)
(part-style? d 'toc-hidden)) (part-style? d 'toc-hidden))
null null
(list (cons d prefixes))) (list (vector d prefixes d)))
;; get internal targets: ;; get internal targets:
(map (lambda (v) (cons v prefixes)) (append-map block-targets (part-blocks d))) (map (lambda (v) (vector v prefixes d)) (append-map block-targets (part-blocks d)))
(map (lambda (p) (if (or (part-whole-page? p ri) (map (lambda (p) (if (or (part-whole-page? p ri)
(and (part-style? p 'toc-hidden) (and (part-style? p 'toc-hidden)
(all-toc-hidden? p))) (all-toc-hidden? p)))
null null
(flatten p prefixes #f))) (flatten p prefixes #f)))
(part-parts d))))))) (part-parts d)))))))
(define any-parts? (ormap (compose part? car) ps)) (define any-parts? (ormap (compose part? (lambda (p) (vector-ref p 0))) ps))
(if (null? ps) (if (null? ps)
null null
`((div ([class ,box-class]) `((div ([class ,box-class])
,@(get-onthispage-label) ,@(get-onthispage-label)
(table ([class "tocsublist"] [cellspacing "0"]) (table ([class "tocsublist"] [cellspacing "0"])
,@(map (lambda (p) ,@(map (lambda (p)
(let ([p (car p)] (let ([p (vector-ref p 0)]
[prefixes (cdr p)] [prefixes (vector-ref p 1)]
[from-d (vector-ref p 2)]
[add-tag-prefixes [add-tag-prefixes
(lambda (t prefixes) (lambda (t prefixes)
(if (null? prefixes) (if (null? prefixes)
@ -765,7 +766,7 @@
'("")) '(""))
,@(if (toc-element? p) ,@(if (toc-element? p)
(render-content (toc-element-toc-content p) (render-content (toc-element-toc-content p)
d ri) from-d ri)
(parameterize ([current-no-links #t] (parameterize ([current-no-links #t]
[extra-breaking? #t]) [extra-breaking? #t])
`((a ([href `((a ([href
@ -793,7 +794,7 @@
(if (toc-target2-element? p) (if (toc-target2-element? p)
(toc-target2-element-toc-content p) (toc-target2-element-toc-content p)
(element-content p))) (element-content p)))
d ri))))))))) from-d ri)))))))))
ps))))))) ps)))))))
(define/private (extract-inherited d ri pred extract) (define/private (extract-inherited d ri pred extract)