From 49eac8975b0dbca9bd9a93c2fc9724a2f5beed41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Axel=20S=C3=B8gaard?= Date: Mon, 14 Oct 2013 16:41:42 +0200 Subject: [PATCH] Added pict to svg conversion. Added parameter to Scribble's html renderer to control choice between png and svg. original commit: 5ed686d9911b9f0d1cb1d5cb58d6950e33b9d17c --- pkgs/scribble-pkgs/scribble-lib/scribble/base.rkt | 3 ++- .../scribble-lib/scribble/html-render.rkt | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pkgs/scribble-pkgs/scribble-lib/scribble/base.rkt b/pkgs/scribble-pkgs/scribble-lib/scribble/base.rkt index ab8da3cc..5f0757a8 100644 --- a/pkgs/scribble-pkgs/scribble-lib/scribble/base.rkt +++ b/pkgs/scribble-pkgs/scribble-lib/scribble/base.rkt @@ -6,13 +6,14 @@ "decode-struct.rkt" "html-properties.rkt" "tag.rkt" + "parameters.rkt" scheme/list scheme/class racket/contract/base racket/contract/combinator (for-syntax scheme/base)) -(provide (all-from-out "tag.rkt")) +(provide (all-from-out "tag.rkt" "parameters.rkt")) ;; ---------------------------------------- diff --git a/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt b/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt index 3e6b6ee3..b440664e 100644 --- a/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt +++ b/pkgs/scribble-pkgs/scribble-lib/scribble/html-render.rkt @@ -1,5 +1,4 @@ #lang scheme/base - (require "core.rkt" "private/render-utils.rkt" "html-properties.rkt" @@ -1092,7 +1091,8 @@ (cond [(string? e) (super render-content e part ri)] ; short-cut for common case [(list? e) (super render-content e part ri)] ; also a short-cut - [(and (convertible? e) + [(and (equal? (current-html-render-pict-as) 'png) + (convertible? e) (convert e 'png-bytes)) => (lambda (bstr) (let ([w (integer-bytes->integer (subbytes bstr 16 20) #f #t)] @@ -1101,6 +1101,13 @@ [alt "image"] [width ,(number->string w)] [height ,(number->string h)])))))] + [(and (equal? (current-html-render-pict-as) 'svg) + (convertible? e) + (convert e 'svg-bytes)) + => (lambda (bstr) + `((object + ([data ,(install-file "pict.svg" bstr)] + [type "image/svg+xml"]))))] [(image-element? e) (let* ([src (collects-relative->path (image-element-path e))] [suffixes (image-element-suffixes e)]