commit 9650c4767bf27299c06085c46f7d810f4b10d414
parent e48b814b17346e702aecf6960262f29c13467a8d
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Fri, 6 Jul 2012 12:35:07 -0600
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
Diffstat:
5 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/collects/scribble/base-render.rkt b/collects/scribble/base-render.rkt
@@ -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))])
diff --git a/collects/scribble/html-properties.rkt b/collects/scribble/html-properties.rkt
@@ -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?))))])]
diff --git a/collects/scribble/latex-properties.rkt b/collects/scribble/latex-properties.rkt
@@ -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?))))])])
diff --git a/collects/scribble/latex-render.rkt b/collects/scribble/latex-render.rkt
@@ -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)
diff --git a/collects/scribblings/scribble/core.scrbl b/collects/scribblings/scribble/core.scrbl
@@ -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?)))])]{
-
-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.
+ (cons/c 'collects (listof bytes?))
+ bytes?)])]{
+
+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].}