|
|
|
@ -20,21 +20,33 @@ Naming guidelines
|
|
|
|
|
(define (parse-points x [round? #f])
|
|
|
|
|
(define val
|
|
|
|
|
(match x
|
|
|
|
|
[(? number?) x]
|
|
|
|
|
[(? string? x)
|
|
|
|
|
(match (cdr (regexp-match #rx"^(-?[0-9\\.]+)([a-z]+)$" (string-downcase x)))
|
|
|
|
|
[(list num-string unit)
|
|
|
|
|
((match unit
|
|
|
|
|
[(regexp #rx"in(ch)?") in->pts]
|
|
|
|
|
[(regexp #rx"cm") (compose1 in->pts cm->in)]
|
|
|
|
|
[(regexp #rx"mm") (compose1 in->pts cm->in mm->cm)]) (string->number num-string))])]))
|
|
|
|
|
[(? number?) x]
|
|
|
|
|
[(? string? x)
|
|
|
|
|
(match (cdr (regexp-match #rx"^(-?[0-9\\.]+)([a-z]+)$" (string-downcase x)))
|
|
|
|
|
[(list num-string unit)
|
|
|
|
|
((match unit
|
|
|
|
|
[(regexp #rx"in(ch)?") in->pts]
|
|
|
|
|
[(regexp #rx"cm") (compose1 in->pts cm->in)]
|
|
|
|
|
[(regexp #rx"mm") (compose1 in->pts cm->in mm->cm)]) (string->number num-string))])]))
|
|
|
|
|
(if round? (inexact->exact (floor val)) val))
|
|
|
|
|
|
|
|
|
|
(define block-attrs '(display
|
|
|
|
|
;; inset values increase the layout size of the quad.
|
|
|
|
|
;; they are relative to the natural layout box.
|
|
|
|
|
inset-top
|
|
|
|
|
inset-bottom
|
|
|
|
|
inset-left
|
|
|
|
|
inset-right
|
|
|
|
|
;; border-inset values do not increase the layout size of the quad.
|
|
|
|
|
;; they are relative to the layout size of the quad, with inset values included.
|
|
|
|
|
;; this is different from CSS, where margin + padding increase the size of the layout.
|
|
|
|
|
;; one has to be dependent on the other, so a choice must be made.
|
|
|
|
|
;; I find this approach more sensible because
|
|
|
|
|
;; borders are a styling element, not a layout element.
|
|
|
|
|
;; this means that changing the inset values will change the position of the border.
|
|
|
|
|
;; but this is preferable to the CSS model, where moving the border changes the layout.
|
|
|
|
|
;; principle: minimize the number of values that affect the layout,
|
|
|
|
|
;; so it's easier to reason about programmatically.
|
|
|
|
|
border-inset-top
|
|
|
|
|
border-inset-bottom
|
|
|
|
|
border-inset-left
|
|
|
|
|