|
|
@ -1,7 +1,7 @@
|
|
|
|
#lang racket/base
|
|
|
|
#lang racket/base
|
|
|
|
(require "core.rkt" racket/match)
|
|
|
|
(require "core.rkt" racket/match sugar/define/contract sugar/container sugar/coercion/values racket/string racket/list)
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (css-unit? x)
|
|
|
|
(define+provide/contract (css-unit? x)
|
|
|
|
(any/c . -> . boolean?)
|
|
|
|
(any/c . -> . boolean?)
|
|
|
|
(x . in? . '("%" "in" "cm" "mm" "em" "ex" "pt" "pc" "px" "rem")))
|
|
|
|
(x . in? . '("%" "in" "cm" "mm" "em" "ex" "pt" "pc" "px" "rem")))
|
|
|
|
|
|
|
|
|
|
|
@ -10,17 +10,17 @@
|
|
|
|
[(define write-proc
|
|
|
|
[(define write-proc
|
|
|
|
(λ(x port mode) (display (format "~a~a" (cssq-num x) (cssq-unit x)) port)))])
|
|
|
|
(λ(x port mode) (display (format "~a~a" (cssq-num x) (cssq-unit x)) port)))])
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (cssqish? x)
|
|
|
|
(define+provide/contract (cssqish? x)
|
|
|
|
(any/c . -> . boolean?)
|
|
|
|
(any/c . -> . boolean?)
|
|
|
|
(->boolean (or (cssq? x) (string? x))))
|
|
|
|
(->boolean (or (cssq? x) (string? x))))
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (string->unit x)
|
|
|
|
(define+provide/contract (string->unit x)
|
|
|
|
(string? . -> . css-unit?)
|
|
|
|
(string? . -> . css-unit?)
|
|
|
|
(if (css-unit? x)
|
|
|
|
(if (css-unit? x)
|
|
|
|
x
|
|
|
|
x
|
|
|
|
(error 'string->unit "'~a' not a valid css unit" x)))
|
|
|
|
(error 'string->unit "'~a' not a valid css unit" x)))
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (cssqish->cssq x)
|
|
|
|
(define+provide/contract (cssqish->cssq x)
|
|
|
|
(cssqish? . -> . cssq?)
|
|
|
|
(cssqish? . -> . cssq?)
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
[(cssq? x) x]
|
|
|
|
[(cssq? x) x]
|
|
|
@ -34,7 +34,7 @@
|
|
|
|
(list (string->number (first pieces))
|
|
|
|
(list (string->number (first pieces))
|
|
|
|
(string->unit (second pieces))))))]))
|
|
|
|
(string->unit (second pieces))))))]))
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (css-math-op op left right)
|
|
|
|
(define+provide/contract (css-math-op op left right)
|
|
|
|
(procedure? cssqish? cssqish? . -> . cssq?)
|
|
|
|
(procedure? cssqish? cssqish? . -> . cssq?)
|
|
|
|
(let ([left (cssqish->cssq left)]
|
|
|
|
(let ([left (cssqish->cssq left)]
|
|
|
|
[right (cssqish->cssq right)])
|
|
|
|
[right (cssqish->cssq right)])
|
|
|
|