Skip to content

Commit 37ba86f

Browse files
committed
add 'bare-anchors style property
1 parent 7577bed commit 37ba86f

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

scribble-doc/scribblings/scribble/core.scrbl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ The recognized @tech{style properties} are as follows:
488488
to skip the generation of an entry for the part's title in the
489489
document index.}
490490

491+
@item{@racket['bare-anchors] --- For HTML, omits the ``Link to here''
492+
hidden hover link on title and section headers.}
493+
491494
@item{@racket[document-version] structure --- A version number for
492495
this part and its sub-parts (except as overridden). When it is
493496
not @racket[""] may be used when rendering a document; at a

scribble-lib/scribble/html-render.rkt

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
(define current-version (make-parameter (version)))
113113
(define current-part-files (make-parameter #f))
114114
(define current-render-convertible-requests (make-parameter '(png@2x-bytes png-bytes svg-bytes gif-bytes)))
115+
(define bare-anchors? (make-parameter #f)) ;; don't decorate anchors with "link-to-here" hovers
115116

116117
(define (url->string* u)
117118
(parameterize ([current-url-encode-mode 'unreserved])
@@ -820,7 +821,8 @@
820821
0)
821822

822823
(define/public (render-one-part d ri fn number)
823-
(parameterize ([current-output-file fn])
824+
(parameterize ([current-output-file fn]
825+
[bare-anchors? (part-style? d 'bare-anchors)])
824826
(let* ([defaults (let loop ([d d])
825827
(or (ormap (lambda (v) (and (html-defaults? v) v))
826828
(style-properties (part-style d)))
@@ -1188,23 +1190,27 @@
11881190
,@(if (part-title-content d)
11891191
(render-content (part-title-content d) d ri)
11901192
null)
1191-
(span ([class "button-group"])
1192-
,@(match (part-tags d)
1193-
['() '()]
1194-
[(cons t _)
1195-
(list `(a ([href ,(format "#~a" (anchor-name
1196-
(add-current-tag-prefix
1197-
(tag-key t ri))))]
1198-
[class "heading-anchor"]
1199-
[title "Link to here"])
1200-
"🔗"))])
1201-
,@(if (and src taglet)
1202-
(list '(a ([class "heading-source"]
1203-
[title "Internal Scribble link and Scribble source"]) ""))
1204-
'())
1205-
;; this is a dummy node so that the line height of heading-anchor
1206-
;; and heading-source are correct (even when their font size is not 100%)
1207-
(span ([style "visibility: hidden"]) " "))))])
1193+
,@(if (bare-anchors?)
1194+
null
1195+
`((span ([class "button-group"])
1196+
,@(match (part-tags d)
1197+
['() '()]
1198+
[(cons t _)
1199+
(list `(a ([href ,(format "#~a" (anchor-name
1200+
(add-current-tag-prefix
1201+
(tag-key t ri))))]
1202+
[class "heading-anchor"]
1203+
[title "Link to here"])
1204+
"🔗"))])
1205+
,@(if (and src taglet)
1206+
(list '(a ([class "heading-source"]
1207+
[title "Internal Scribble link and Scribble source"]) ""))
1208+
'())
1209+
;; this is a dummy node so that the line height of heading-anchor
1210+
;; and heading-source are correct (even when their font size is not 100%)
1211+
(span ([style "visibility: hidden"]) " ")))
1212+
)
1213+
))])
12081214
,@(let ([auths (extract-authors d)])
12091215
(if (null? auths)
12101216
null

0 commit comments

Comments
 (0)