racket / scribble

Other
197 stars 91 forks source link

add example of adding HTML tag to scribble output #241

Open spdegabrielle opened 4 years ago

spdegabrielle commented 4 years ago

I agree about the need for some kind of doc update. Outputting a specific HTML tag is a basic task and the answer is hard to find.

Maybe Scribble needs an FAQ, maybe we can get by with more indexing.

Originally posted by @bennn in https://github.com/racket/scribble/issues/233#issuecomment-636227679

tasks

Possible example (shows HTML tag nesting):

#lang scribble/base

@(require
   (only-in scribble/core make-style)
   (only-in scribble/html-properties alt-tag))

@(define details-style (make-style #f (list (alt-tag "details"))))
;summary
@(define summary-style (make-style #f (list (alt-tag "summary"))))

@(define (details summary . arg*)
   (apply elem (elem summary #:style summary-style) #:style details-style arg*))

@; -----------------------------------------------------------------------------

This is a Scribble document with a @tt{details} element.

@details["the details heading"]{
 The @tt{alt-tag} style property can change the HTML tag that
 Scribble creates for an @tt{element} or @tt{paragraph}.

@url{https://docs.racket-lang.org/scribble/core.html#(def._((lib._scribble%2Fhtml-properties..rkt)._alt-tag))}
}