scribble/*-properties: allow literal bytes in *-additions

For example, a `tex-addition' structure can have literal bytes
to include in the generated Latex, instead of a path to a file that
holds the content.

original commit: 2b9f57b01d55a39a70f0d0df22bc97b1874727ea
This commit is contained in:
Matthew Flatt 2012-07-06 12:35:07 -06:00
parent e48b814b17
commit 9650c4767b
5 changed files with 20 additions and 13 deletions

View File

@ -76,7 +76,7 @@
(unless (stop-at-part? p)
(loop p #f #f)))
(part-parts p)))))
(for/list ([k (in-hash-keys ht)]) (main-collects-relative->path k))))
(for/list ([k (in-hash-keys ht)]) (if (bytes? k) k (main-collects-relative->path k)))))
(define/private (extract-style-style-files s ht pred extract)
(for ([v (in-list (style-properties s))])

View File

@ -7,7 +7,7 @@
[hover-property ([text string?])]
[script-property ([type string?]
[script (or/c path-string? (listof string?))])]
[css-addition ([path (or/c path-string? (cons/c 'collects (listof bytes?)))])]
[css-addition ([path (or/c path-string? (cons/c 'collects (listof bytes?)) bytes?)])]
[html-defaults ([prefix-path (or/c bytes? path-string? (cons/c 'collects (listof bytes?)))]
[style-path (or/c bytes? path-string? (cons/c 'collects (listof bytes?)))]
[extra-files (listof (or/c path-string? (cons/c 'collects (listof bytes?))))])]

View File

@ -3,7 +3,7 @@
racket/contract/base)
(provide-structs
[tex-addition ([path (or/c path-string? (cons/c 'collects (listof bytes?)))])]
[tex-addition ([path (or/c path-string? (cons/c 'collects (listof bytes?)) bytes?)])]
[latex-defaults ([prefix (or/c bytes? path-string? (cons/c 'collects (listof bytes?)))]
[style (or/c bytes? path-string? (cons/c 'collects (listof bytes?)))]
[extra-files (listof (or/c path-string? (cons/c 'collects (listof bytes?))))])])

View File

@ -103,7 +103,9 @@
(lambda ()
(copy-port (current-input-port) (current-output-port))))))
(for ([style-file (in-list all-style-files)])
(install-file style-file)))
(if (bytes? style-file)
(display style-file)
(install-file style-file))))
(when whole-doc?
(printf "\\begin{document}\n\\preDoc\n")
(when (part-title-content d)

View File

@ -1383,11 +1383,14 @@ script alternative to the element content.}
@defstruct[css-addition ([path (or/c path-string?
(cons/c 'collects (listof bytes?)))])]{
(cons/c 'collects (listof bytes?))
bytes?)])]{
Used as a @tech{style property} to supply a CSS file to be referenced
in the generated HTML. This property can be attached to any style, and
all additions are collected to the top of the generated HTML page.
Used as a @tech{style property} to supply a CSS file (if @racket[path]
is a path, string, or list) or content (if @racket[path] is a byte
string) to be referenced or included in the generated HTML. This
property can be attached to any style, and all additions are collected
to the top of the generated HTML page.
The @racket[path] field can be a result of
@racket[path->main-collects-relative].}
@ -1421,12 +1424,14 @@ Like @racket[latex-defaults], but use for the
@defstruct[tex-addition ([path (or/c path-string?
(cons/c 'collects (listof bytes?)))])]{
(cons/c 'collects (listof bytes?))
bytes?)])]{
Used as a @tech{style property} to supply a @filepath{.tex} file to be
included in the generated Latex. This property can be attached to any
style, and all additions are collected to the top of the generated
Latex file.
Used as a @tech{style property} to supply a @filepath{.tex} file (if
@racket[path] is a path, string, or list) or content (if @racket[path]
is a byte string) to be included in the generated Latex. This property
can be attached to any style, and all additions are collected to the
top of the generated Latex file.
The @racket[path] field can be a result of
@racket[path->main-collects-relative].}