Skip to content

Commit cd77755

Browse files
committed
allow more general content for make-id-element
Adjust the `make-id-element` function from `scribble/racket` (which is not currently documented, but probably it should be) to accept s style to use for a link and general content (instead of just a string) for the link.
1 parent 993f7f6 commit cd77755

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

scribble-lib/scribble/racket.rkt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@
112112
;; create a line break after the hyphen. For interior hyphens,
113113
;; line breaking is usually fine.
114114
(define (nonbreak-leading-hyphens s)
115-
(define m (regexp-match-positions #rx"^-+" s))
115+
(define m (and (string? s)
116+
(regexp-match-positions #rx"^-+" s)))
116117
(if m
117118
(cond
118119
[(= (cdar m) (string-length s)) (make-element 'no-break s)]
@@ -172,6 +173,7 @@
172173
(define (make-id-element c s defn?
173174
#:space [space #f]
174175
#:suffix [suffix space]
176+
#:link-style [link-style #f]
175177
#:unlinked-ok? [unlinked-ok? #f])
176178
(define b (identifier-label-binding c))
177179
(unless b (error 'make-id-element "no for-label binding for identifier: ~s" c))
@@ -197,23 +199,25 @@
197199
(list
198200
(case (car tag)
199201
[(form)
200-
(make-link-element (if defn?
201-
syntax-def-color
202-
syntax-link-color)
202+
(make-link-element (or link-style
203+
(if defn?
204+
syntax-def-color
205+
syntax-link-color))
203206
(nonbreak-leading-hyphens s)
204207
tag)]
205208
[else
206-
(make-link-element (if defn?
207-
value-def-color
208-
value-link-color)
209+
(make-link-element (or link-style
210+
(if defn?
211+
value-def-color
212+
value-link-color))
209213
(nonbreak-leading-hyphens s)
210214
tag)])))]
211215
[unlinked-ok?
212-
(list (make-element (if defn? syntax-def-color symbol-color) s))]
216+
(list (make-element (or link-style (if defn? syntax-def-color symbol-color)) s))]
213217
[else
214218
(list
215219
(make-element "badlink"
216-
(make-element value-link-color s)))]))
220+
(make-element (or link-style value-link-color) s)))]))
217221
(lambda () s)
218222
(lambda () s)
219223
(intern-taglet key)))

0 commit comments

Comments
 (0)