commit 0e875d96bbc04dac79cbb8da25ed9391fed1c0c5
parent 8bfe8dddfa5eff5753409d4bad1b2beec750fc48
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Tue, 3 Aug 2010 12:48:03 -0600
add optional `#:key' argument to `tech' and `techlink'
to specify the defined technical term separate from the link content
original commit: 656321dbcb6dd1032fff5dc2ba49ef65ec4a0bfb
Diffstat:
2 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/collects/scribble/private/manual-tech.rkt b/collects/scribble/private/manual-tech.rkt
@@ -8,12 +8,18 @@
(provide/contract
[deftech (() (#:style? boolean?) #:rest (listof pre-content?) . ->* . element?)]
- [tech (() (#:doc (or/c module-path? false/c) #:tag-prefixes (or/c (listof string?) false/c)) #:rest (listof pre-content?) . ->* . element?)]
- [techlink (() (#:doc (or/c module-path? false/c) #:tag-prefixes (or/c (listof string?) false/c)) #:rest (listof pre-content?) . ->* . element?)])
+ [tech (()
+ (#:doc (or/c module-path? false/c) #:tag-prefixes (or/c (listof string?) false/c) #:key (or/c string? #f))
+ #:rest (listof pre-content?)
+ . ->* . element?)]
+ [techlink (()
+ (#:doc (or/c module-path? false/c) #:tag-prefixes (or/c (listof string?) false/c) #:key (or/c string? #f))
+ #:rest (listof pre-content?)
+ . ->* . element?)])
-(define (*tech make-elem style doc prefix s)
+(define (*tech make-elem style doc prefix s key)
(let* ([c (decode-content s)]
- [s (string-foldcase (content->string c))]
+ [s (string-foldcase (or key (content->string c)))]
[s (regexp-replace #rx"ies$" s "y")]
[s (regexp-replace #rx"s$" s "")]
[s (regexp-replace* #px"[-\\s]+" s " ")])
@@ -23,7 +29,7 @@
(let* ([e (if style?
(apply defterm s)
(make-element #f (decode-content s)))]
- [t (*tech make-target-element #f #f #f (list e))])
+ [t (*tech make-target-element #f #f #f (list e) #f)])
(make-index-element #f
(list t)
(target-element-tag t)
@@ -31,14 +37,14 @@
(list e)
'tech)))
-(define (tech #:doc [doc #f] #:tag-prefixes [prefix #f] . s)
+(define (tech #:doc [doc #f] #:tag-prefixes [prefix #f] #:key [key #f] . s)
(*tech (lambda (style c tag)
(make-link-element
style
(list (make-element "techinside" c))
tag))
"techoutside"
- doc prefix s))
+ doc prefix s key))
-(define (techlink #:doc [doc #f] #:tag-prefixes [prefix #f] . s)
- (*tech make-link-element #f doc prefix s))
+(define (techlink #:doc [doc #f] #:tag-prefixes [prefix #f] #:key [key #f] . s)
+ (*tech make-link-element #f doc prefix s key))
diff --git a/collects/scribblings/scribble/manual.scrbl b/collects/scribblings/scribble/manual.scrbl
@@ -1022,16 +1022,19 @@ If @racket[style?] is true, then @racket[defterm] is used on
@racket[pre-content].}
@defproc[(tech [pre-content pre-content?] ...
- [#:doc module-path (or/c module-path? false/c) #f]
- [#:tag-prefixes prefixes (or/c (listof string?) false/c) #f])
+ [#:key key (or/c string? #f) #f]
+ [#:doc module-path (or/c module-path? #f) #f]
+ [#:tag-prefixes prefixes (or/c (listof string?) #f) #f])
element?]{
Produces an element for the @tech{decode}d @racket[pre-content], and
-hyperlinks it to the definition of the content as established by
-@racket[deftech]. The content's string form is normalized in the same
-way as for @racket[deftech]. The @racket[#:doc] and
-@racket[#:tag-prefixes] arguments support cross-document and
-section-specific references, like in @racket[secref].
+hyperlinks it to the definition of the key as established by
+@racket[deftech]. If @racket[key] is false, the decoded content is
+converted to a string (using @racket[content->string]) to use as a
+key; in either case, the key is normalized in the same way as for
+@racket[deftech]. The @racket[#:doc] and @racket[#:tag-prefixes]
+arguments support cross-document and section-specific references, like
+in @racket[secref].
With the default style files, the hyperlink created by @racket[tech]
is somewhat quieter than most hyperlinks: the underline in HTML output
@@ -1045,11 +1048,12 @@ defined, but a sentence uses the term ``binding,'' the latter can be
linked to the former using @racketfont["@tech{bind}ing"].}
@defproc[(techlink [pre-content pre-content?] ...
- [#:doc module-path (or/c module-path? false/c) #f]
- [#:tag-prefixes prefixes (or/c (listof string?) false/c) #f])
+ [#:key key (or/c string? #f) #f]
+ [#:doc module-path (or/c module-path? #f) #f]
+ [#:tag-prefixes prefixes (or/c (listof string?) #f) #f])
element?]{
-Like @racket[tech], but the link is not a quiet. For example, in HTML
+Like @racket[tech], but the link is not quiet. For example, in HTML
output, a hyperlink underline appears even when the mouse is not over
the link.}
@@ -1122,12 +1126,12 @@ which is created with @racket[bib-entry]. The entries are typeset in
order as given.}
@defproc[(bib-entry [#:key key string?]
- [#:title title (or/c false/c pre-content?)]
+ [#:title title (or/c #f pre-content?)]
[#:is-book? is-book? boolean? #f]
- [#:author author (or/c false/c pre-content?) #f]
- [#:location location (or/c false/c pre-content?) #f]
- [#:date date (or/c false/c pre-content?) #f]
- [#:url url (or/c false/c pre-content?) #f])
+ [#:author author (or/c #f pre-content?) #f]
+ [#:location location (or/c #f pre-content?) #f]
+ [#:date date (or/c #f pre-content?) #f]
+ [#:url url (or/c #f pre-content?) #f])
bib-entry?]{
Creates a bibliography entry. The @racket[key] is used to refer to the