Convert GIF size to string.

Repairs a problem with #232.
Relevant to racket/racket#3300.
This commit is contained in:
Sam Tobin-Hochstadt 2020-07-19 21:09:31 -04:00
parent 51639146dd
commit 9415df28d5

View File

@ -27,6 +27,9 @@
(provide render-mixin (provide render-mixin
render-multi-mixin) render-multi-mixin)
(define (number->decimal-string s)
(number->string (if (integer? s) s (exact->inexact s))))
(define as-literal (define as-literal
(let ([loc (xml:make-location 0 0 0)]) (let ([loc (xml:make-location 0 0 0)])
(lambda strings (xml:make-cdata loc loc (string-append* strings))))) (lambda strings (xml:make-cdata loc loc (string-append* strings)))))
@ -1470,12 +1473,7 @@
(if (and (not (list? cvt)) (if (and (not (list? cvt))
(equal? request 'png@2x-bytes)) (equal? request 'png@2x-bytes))
(/ v 2.0) (/ v 2.0)
v))] v))])
[number->decimal-string (lambda (s)
(number->string
(if (integer? s)
s
(exact->inexact s))))])
(list (list
(add-padding (add-padding
cvt cvt
@ -1508,7 +1506,10 @@
(define height (+ (bytes-ref gif-bytes 8) (* (bytes-ref gif-bytes 9) 256))) (define height (+ (bytes-ref gif-bytes 8) (* (bytes-ref gif-bytes 9) 256)))
(define image-tag (define image-tag
`(img ([src ,gif-src] [type "image/gif"] [width ,width] [height ,height]))) `(img ([src ,gif-src]
[type "image/gif"]
[width ,(number->decimal-string width)]
[height ,(number->decimal-string height)])))
(list image-tag))] (list image-tag))]
[else #f]))) [else #f])))