{"size": 2811, "ext": "scrbl", "max_stars_repo_path": "scribble-doc/scriblib/scribblings/render-cond.scrbl", "max_stars_repo_name": "cwebber/scribble", "max_stars_repo_stars_event_min_datetime": "2015-01-11T18:19:42.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T08:45:52.000Z", "max_issues_repo_path": "scribble-doc/scriblib/scribblings/render-cond.scrbl", "max_issues_repo_name": "cwebber/scribble", "max_issues_repo_issues_event_min_datetime": "2015-03-24T20:53:21.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-20T22:51:57.000Z", "max_forks_repo_path": "scribble-doc/scriblib/scribblings/render-cond.scrbl", "max_forks_repo_name": "cwebber/scribble", "max_forks_repo_forks_event_min_datetime": "2015-03-09T12:23:06.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-07T15:00:13.000Z"}
{"max_stars_count": 161, "max_issues_count": 260, "max_forks_count": 103, "avg_line_length": 43.921875, "max_line_length": 80, "alphanum_fraction": 0.7086446105}
#lang scribble/manual
@(require (for-label scribble/core
                     racket/base
                     scriblib/render-cond))

@(define scribble-doc '(lib "scribblings/scribble/scribble.scrbl"))

@title[#:tag "render-cond"]{Conditional Content}

@defmodule[scriblib/render-cond]

As much as possible, Scribble documents should be independent of the
target format for rendering the document. To customize generated
output, use styles plus ``back end'' configurations for each target
format (see @secref[#:doc scribble-doc "config"] in
@other-manual[scribble-doc]).

As a last resort, the @racket[cond-element] and @racket[cond-block]
forms support varying the document content depending on the target
format. More precisely, they generate parts of a document where
content is delayed until the @tech[#:doc scribble-doc]{traverse pass}
of document rendering. Format detection relies on the
@racket['scribble:current-render-mode] registration that is accessible
through a @racket[traverse-element] or @racket[traverse-block].

The syntax of @racket[cond-element] and @racket[cond-block] is based
on SRFI-0.

@defform*/subs[#:literals (and or not else)
               [(cond-element [feature-requirement body ...+])
                (cond-element [feature-requirement body ...+] [else body ...+])]
               ([feature-requirement identifier
                                     (not feature-requirement)
                                     (and feature-requirement ...)
                                     (or feature-requirement ...)])]{

Generates a @racket[traverse-element] whose replacement content is
produced by the @racket[body] of one of the first matching
@racket[cond-element] clause.

A @racket[feature-requirement] can be any identifier; a useful
identifier is one whose symbol form can appear in a
@racket['scribble:current-render-mode] list. The identifier matches
when its symbol form is in the @racket['scribble:current-render-mode]
list.  Typically, the identifier is @racket[html], @racket[latex], or
@racket[text] to indicate the corresponding rendering target.

A @racket[(not feature-requirement)] test matches when
@racket[feature-requirement] does not match, and so on. An
@racket[else] clause always matches. If no @racket[else] clause is
present and no clause matches, then the @racket[exn:fail:contract]
exception is raised. Similarly, if the result of the selected
@racket[body] is not content according to @racket[content?], then the
@racket[exn:fail:contract] exception is raised.}

@defform*[[(cond-block [feature-requirement body ...+])
           (cond-block [feature-requirement body ...+] [else body ...+])]]{

Like @racket[cond-element], but generates a @racket[traverse-block]
where the selected @racket[body] must produce a block according to
@racket[block?].}


