From 8343c077956cfc55becc72e57c59cbd6f9d61c6b Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 11 Apr 2008 00:16:05 +0000 Subject: [PATCH] Scribbled games docs svn: r9246 original commit: 18f408767332d345e194a8ba78a9199ee7a2887a --- collects/scribble/html-render.ss | 4 ++-- collects/scribble/latex-render.ss | 5 ++++- collects/scribble/struct.ss | 4 +++- collects/scribble/xref.ss | 23 +++++++++++++---------- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index ecb076f1..a9da9022 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -758,7 +758,7 @@ `((a ((name ,(url-anchor-name style))) ,@(super render-element e part ri)))] [(image-file? style) - (let* ([src (image-file-path style)] + (let* ([src (main-collects-relative->path (image-file-path style))] [scale (image-file-scale style)] [sz (if (= 1.0 scale) null @@ -776,7 +776,7 @@ `((width ,(to-num w)) (height ,(to-num h)))) null))))]) - `((img ((src ,(install-file src)) ,@sz))))] + `((img ((src ,(install-file src))) ,@sz)))] [else (super render-element e part ri)]))) (define/override (render-table t part ri need-inline?) diff --git a/collects/scribble/latex-render.ss b/collects/scribble/latex-render.ss index 719b811b..e0a22def 100644 --- a/collects/scribble/latex-render.ss +++ b/collects/scribble/latex-render.ss @@ -4,6 +4,7 @@ mzlib/class scheme/runtime-path scheme/port + setup/main-collects (for-syntax scheme/base)) (provide render-mixin) @@ -162,7 +163,9 @@ (/ (cadddr style) 255.0)))) #f)] [(image-file? style) - (let ([fn (install-file (image-file-path style))]) + (let ([fn (install-file + (main-collects-relative->path + (image-file-path style)))]) (printf "\\includegraphics[scale=~a]{~a}" (image-file-scale style) fn))] [else (super render-element e part ri)]))) (when part-label? diff --git a/collects/scribble/struct.ss b/collects/scribble/struct.ss index e6d740aa..f2ebedb9 100644 --- a/collects/scribble/struct.ss +++ b/collects/scribble/struct.ss @@ -174,7 +174,9 @@ [target-url ([addr (or/c string? path?)][style any/c])] [url-anchor ([name string?])] - [image-file ([path path-string?] + [image-file ([path (or/c path-string? + (cons/c (one-of/c 'collects) + (listof bytes?)))] [scale real?])]) ;; ---------------------------------------- diff --git a/collects/scribble/xref.ss b/collects/scribble/xref.ss index f2f803cf..954b25f9 100644 --- a/collects/scribble/xref.ss +++ b/collects/scribble/xref.ss @@ -64,16 +64,19 @@ ;; resulting html (define (xref-render xrefs doc dest-file #:render% [render% (html:render-mixin render%)]) - (let* ([dest-file (if (string? dest-file) (string->path dest-file) dest-file)] - [renderer (new render% [dest-dir (and dest-file (path-only dest-file))] - [css-path 'inline])] - [ci (send renderer collect (list doc) (list dest-file))] - [_ (send renderer transfer-info ci (resolve-info-ci (xrefs-ri xrefs)))] - [ri (send renderer resolve (list doc) (list dest-file) ci)] - [xs (send renderer render (list doc) (list dest-file) ri)]) - (if dest-file - (void) - (car xs)))) + ;; In case rendering writes a file (like an image file), which to the + ;; temp directory: + (parameterize ([current-directory (find-system-path 'temp-dir)]) + (let* ([dest-file (if (string? dest-file) (string->path dest-file) dest-file)] + [renderer (new render% [dest-dir (and dest-file (path-only dest-file))] + [css-path 'inline])] + [ci (send renderer collect (list doc) (list dest-file))] + [_ (send renderer transfer-info ci (resolve-info-ci (xrefs-ri xrefs)))] + [ri (send renderer resolve (list doc) (list dest-file) ci)] + [xs (send renderer render (list doc) (list dest-file) ri)]) + (if dest-file + (void) + (car xs))))) ;; Returns (values ) (define xref-binding-tag