From 9e005433b01897801c9324a12c82c13ecbba5bdd Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 12 May 2022 14:31:02 -0700 Subject: [PATCH] cleaner --- quad2/page.rkt | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/quad2/page.rkt b/quad2/page.rkt index 5f64dcaf..4f108bb3 100644 --- a/quad2/page.rkt +++ b/quad2/page.rkt @@ -18,21 +18,16 @@ (not (quad-has-key? x :page-orientation)))) (define (parse-page-size attrs) - ;; if set, debug-page-width and debug-page-height override the requested width & height - (define width (or (debug-page-width) (hash-ref attrs :page-width #false))) - (define height (or (debug-page-height) (hash-ref attrs :page-height #false))) - (define size (hash-ref attrs :page-size default-page-size)) - (define orientation (hash-ref attrs :page-orientation default-page-orientation)) - ;; parsed-width and parsed-height are derived from named size & orientation (match-define (list parsed-width parsed-height) (sort - (page-sizes-ref size default-page-size) + (page-sizes-ref (hash-ref attrs :page-size default-page-size)) ;; for portrait, shorter edge is width - (if (member orientation '("portrait" "tall")) < >))) + (if (member (hash-ref attrs :page-orientation default-page-orientation) '("portrait" "tall")) < >))) - (hash-set! attrs :page-width (or width parsed-width)) - (hash-set! attrs :page-height (or height parsed-height)) + ;; if set, debug-page-width and debug-page-height override the requested width & height + (hash-set! attrs :page-width (or (debug-page-width) (hash-ref attrs :page-width #false) parsed-width)) + (hash-set! attrs :page-height (or (debug-page-height) (hash-ref attrs :page-height #false) parsed-height)) (hash-remove! attrs :page-size) (hash-remove! attrs :page-orientation) attrs)