scribble/base: add #:style argument to image

original commit: c9f13248e33502b71d2ff95b8bc38e28ff680491
This commit is contained in:
Matthew Flatt 2014-05-14 06:06:01 -06:00
parent b5e473c5d9
commit 6b76b2df2a
3 changed files with 17 additions and 6 deletions

View File

@ -459,8 +459,9 @@ See also @racket[verbatim].}
@defproc[(image [path (or/c path-string? (cons/c 'collects (listof bytes?)))] @defproc[(image [path (or/c path-string? (cons/c 'collects (listof bytes?)))]
[#:scale scale real? 1.0] [#:scale scale real? 1.0]
[#:suffixes suffixes (listof #rx"^[.]") null] [#:suffixes suffixes (listof #rx"^[.]") null]
[#:style style (or/c style? string? symbol? #f) #f]
[pre-content pre-content?] ...) [pre-content pre-content?] ...)
element?]{ image-element?]{
Creates an image element from the given path. The @tech{decode}d Creates an image element from the given path. The @tech{decode}d
@racket[pre-content] serves as the alternate text for contexts where @racket[pre-content] serves as the alternate text for contexts where
@ -472,6 +473,13 @@ See also @racket[verbatim].}
the @racket[path] argument can be a result of the @racket[path] argument can be a result of
@racket[path->main-collects-relative]. @racket[path->main-collects-relative].
The @racket[scale] argument sets the images scale relative to its
default size as determined by the content of @racket[path]. For HTML
output, the resulting @racket[image-element] is rendered with an
@tt{img} or @tt{object} (for SVG) tag, and @racket[scale] adjusts the
@tt{width} and @tt{height} attributes; a class name or other
attributes in @racket[style] can effectively override that size.
The strings in @racket[suffixes] are filtered to those supported by The strings in @racket[suffixes] are filtered to those supported by
given renderer, and then the acceptable suffixes are tried in given renderer, and then the acceptable suffixes are tried in
order. The HTML renderer supports @racket[".png"], order. The HTML renderer supports @racket[".png"],
@ -480,9 +488,10 @@ See also @racket[verbatim].}
when converting Latex output to DVI, and @racket[".png"] and when converting Latex output to DVI, and @racket[".png"] and
@racket[".pdf"] work only for converting Latex output to PDF). @racket[".pdf"] work only for converting Latex output to PDF).
Note that when the @racket[suffixes] library is non-empty, then Note that when the @racket[suffixes] list is non-empty, then
the @racket[path] argument should not have a suffix. the @racket[path] argument should not have a suffix.
}
@history[#:changed "1.3" @elem{Added the @racket[#:style] argument.}]}
@; ------------------------------------------------------------------------ @; ------------------------------------------------------------------------
@section[#:tag "spacing"]{Spacing} @section[#:tag "spacing"]{Spacing}

View File

@ -22,4 +22,4 @@
(define pkg-authors '(mflatt eli)) (define pkg-authors '(mflatt eli))
(define version "1.2") (define version "1.3")

View File

@ -243,7 +243,8 @@
[image (->* ((or/c path-string? (cons/c 'collects (listof bytes?)))) [image (->* ((or/c path-string? (cons/c 'collects (listof bytes?))))
(#:scale real? (#:scale real?
#:suffixes (listof (and/c string? #rx"^[.]"))) #:suffixes (listof (and/c string? #rx"^[.]"))
#:style element-style?)
#:rest (listof content?) #:rest (listof content?)
image-element?)]) image-element?)])
@ -315,8 +316,9 @@
(define (image #:scale [scale 1.0] (define (image #:scale [scale 1.0]
filename-relative-to-source filename-relative-to-source
#:suffixes [suffixes null] #:suffixes [suffixes null]
#:style [style #f]
. alt) . alt)
(make-image-element #f (make-image-element style
(decode-content alt) (decode-content alt)
filename-relative-to-source filename-relative-to-source
suffixes suffixes