Use html-render-pict-as to control whether html-render uses pngs or svgs
original commit: 2bc58b5663c7753b0ad9bdabe18acd637276ac96
This commit is contained in:
parent
49eac8975b
commit
8a5a9adfc5
|
@ -6,14 +6,13 @@
|
||||||
"decode-struct.rkt"
|
"decode-struct.rkt"
|
||||||
"html-properties.rkt"
|
"html-properties.rkt"
|
||||||
"tag.rkt"
|
"tag.rkt"
|
||||||
"parameters.rkt"
|
|
||||||
scheme/list
|
scheme/list
|
||||||
scheme/class
|
scheme/class
|
||||||
racket/contract/base
|
racket/contract/base
|
||||||
racket/contract/combinator
|
racket/contract/combinator
|
||||||
(for-syntax scheme/base))
|
(for-syntax scheme/base))
|
||||||
|
|
||||||
(provide (all-from-out "tag.rkt" "parameters.rkt"))
|
(provide (all-from-out "tag.rkt"))
|
||||||
|
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -24,4 +24,5 @@
|
||||||
[install-resource ([path path-string?])]
|
[install-resource ([path path-string?])]
|
||||||
[link-resource ([path path-string?])]
|
[link-resource ([path path-string?])]
|
||||||
|
|
||||||
[head-extra ([xexpr xexpr/c])])
|
[head-extra ([xexpr xexpr/c])]
|
||||||
|
[render-pict-as ([type symbol?])])
|
||||||
|
|
|
@ -94,6 +94,7 @@
|
||||||
(define extra-breaking? (make-parameter #f))
|
(define extra-breaking? (make-parameter #f))
|
||||||
(define current-version (make-parameter (version)))
|
(define current-version (make-parameter (version)))
|
||||||
(define current-part-files (make-parameter #f))
|
(define current-part-files (make-parameter #f))
|
||||||
|
(define current-render-pict-as (make-parameter 'png-images))
|
||||||
|
|
||||||
(define (url->string* u)
|
(define (url->string* u)
|
||||||
(parameterize ([current-url-encode-mode 'unreserved])
|
(parameterize ([current-url-encode-mode 'unreserved])
|
||||||
|
@ -975,7 +976,15 @@
|
||||||
d
|
d
|
||||||
ri))))))
|
ri))))))
|
||||||
|
|
||||||
|
(define/public (extract-render-pict-as d)
|
||||||
|
(or (ormap (lambda (v)
|
||||||
|
(and (render-pict-as? v)
|
||||||
|
(render-pict-as-type v)))
|
||||||
|
(style-properties (part-style d)))
|
||||||
|
""))
|
||||||
|
|
||||||
(define/override (render-part-content d ri)
|
(define/override (render-part-content d ri)
|
||||||
|
(parameterize ([current-render-pict-as (extract-render-pict-as d)])
|
||||||
(let ([number (collected-info-number (part-collected-info d ri))])
|
(let ([number (collected-info-number (part-collected-info d ri))])
|
||||||
`(,@(let ([pres (extract-pretitle d)])
|
`(,@(let ([pres (extract-pretitle d)])
|
||||||
(append-map (lambda (pre)
|
(append-map (lambda (pre)
|
||||||
|
@ -1022,7 +1031,7 @@
|
||||||
(if (null? secs)
|
(if (null? secs)
|
||||||
null
|
null
|
||||||
(append (render-part (car secs) ri)
|
(append (render-part (car secs) ri)
|
||||||
(loop (add1 pos) (cdr secs))))))))
|
(loop (add1 pos) (cdr secs)))))))))
|
||||||
|
|
||||||
(define/private (render-flow* p part ri starting-item? special-last?)
|
(define/private (render-flow* p part ri starting-item? special-last?)
|
||||||
;; Wrap each table with <p>, except for a trailing table
|
;; Wrap each table with <p>, except for a trailing table
|
||||||
|
@ -1091,7 +1100,7 @@
|
||||||
(cond
|
(cond
|
||||||
[(string? e) (super render-content e part ri)] ; short-cut for common case
|
[(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
|
[(list? e) (super render-content e part ri)] ; also a short-cut
|
||||||
[(and (equal? (current-html-render-pict-as) 'png)
|
[(and (equal? (current-render-pict-as) 'png-images)
|
||||||
(convertible? e)
|
(convertible? e)
|
||||||
(convert e 'png-bytes))
|
(convert e 'png-bytes))
|
||||||
=> (lambda (bstr)
|
=> (lambda (bstr)
|
||||||
|
@ -1101,7 +1110,7 @@
|
||||||
[alt "image"]
|
[alt "image"]
|
||||||
[width ,(number->string w)]
|
[width ,(number->string w)]
|
||||||
[height ,(number->string h)])))))]
|
[height ,(number->string h)])))))]
|
||||||
[(and (equal? (current-html-render-pict-as) 'svg)
|
[(and (equal? (current-render-pict-as) 'svg-images)
|
||||||
(convertible? e)
|
(convertible? e)
|
||||||
(convert e 'svg-bytes))
|
(convert e 'svg-bytes))
|
||||||
=> (lambda (bstr)
|
=> (lambda (bstr)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user