Skip to content

add 'bare-anchors style property #508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scribble-doc/scribblings/scribble/core.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ The recognized @tech{style properties} are as follows:
to skip the generation of an entry for the part's title in the
document index.}

@item{@racket['bare-anchors] --- For HTML, omits the ``Link to here''
hidden hover link on title and section headers.}

@item{@racket[document-version] structure --- A version number for
this part and its sub-parts (except as overridden). When it is
not @racket[""] may be used when rendering a document; at a
Expand Down
42 changes: 24 additions & 18 deletions scribble-lib/scribble/html-render.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
(define current-version (make-parameter (version)))
(define current-part-files (make-parameter #f))
(define current-render-convertible-requests (make-parameter '(png@2x-bytes png-bytes svg-bytes gif-bytes)))
(define bare-anchors? (make-parameter #f)) ;; don't decorate anchors with "link-to-here" hovers

(define (url->string* u)
(parameterize ([current-url-encode-mode 'unreserved])
Expand Down Expand Up @@ -820,7 +821,8 @@
0)

(define/public (render-one-part d ri fn number)
(parameterize ([current-output-file fn])
(parameterize ([current-output-file fn]
[bare-anchors? (part-style? d 'bare-anchors)])
(let* ([defaults (let loop ([d d])
(or (ormap (lambda (v) (and (html-defaults? v) v))
(style-properties (part-style d)))
Expand Down Expand Up @@ -1180,23 +1182,27 @@
,@(if (part-title-content d)
(render-content (part-title-content d) d ri)
null)
(span ([class "button-group"])
,@(match (part-tags d)
['() '()]
[(cons t _)
(list `(a ([href ,(format "#~a" (anchor-name
(add-current-tag-prefix
(tag-key t ri))))]
[class "heading-anchor"]
[title "Link to here"])
"🔗"))])
,@(if (and src taglet)
(list '(a ([class "heading-source"]
[title "Internal Scribble link and Scribble source"]) "ℹ"))
'())
;; this is a dummy node so that the line height of heading-anchor
;; and heading-source are correct (even when their font size is not 100%)
(span ([style "visibility: hidden"]) " "))))])
,@(if (bare-anchors?)
null
`((span ([class "button-group"])
,@(match (part-tags d)
['() '()]
[(cons t _)
(list `(a ([href ,(format "#~a" (anchor-name
(add-current-tag-prefix
(tag-key t ri))))]
[class "heading-anchor"]
[title "Link to here"])
"🔗"))])
,@(if (and src taglet)
(list '(a ([class "heading-source"]
[title "Internal Scribble link and Scribble source"]) "ℹ"))
'())
;; this is a dummy node so that the line height of heading-anchor
;; and heading-source are correct (even when their font size is not 100%)
(span ([style "visibility: hidden"]) " ")))
)
))])
,@(let ([auths (extract-authors d)])
(if (null? auths)
null
Expand Down