diff --git a/quad2/linearize.rkt b/quad2/linearize.rkt index 5379cc95..e5922f1a 100644 --- a/quad2/linearize.rkt +++ b/quad2/linearize.rkt @@ -13,11 +13,11 @@ #:post (list-of simple-quad?) (append* (for/list ([q (in-list qs)]) - (match q - [(quad _ _ (list (? string? str)) _) - (for/list ([c (in-string str)]) - (struct-copy quad q [elems (list (string c))]))] - [_ (list q)])))) + (match q + [(quad _ _ (list (? string? str)) _) + (for/list ([c (in-string str)]) + (struct-copy quad q [elems (list (string c))]))] + [_ (list q)])))) (define-pass (linearize qs) ;; convert a single quad into a list of quads, with the attributes propagated downward @@ -101,4 +101,13 @@ qs) (module+ test - (mark-text-runs smlqs)) \ No newline at end of file + (mark-text-runs smlqs)) + +(define-pass (append-boq-and-eoq qs) + #:pre (list-of simple-quad?) + #:post (λ (qs) (match qs + [(list (? boq-quad?) (? simple-quad?) ... (? eoq-quad?)) #true] + [_ #false])) + (set-quad-attrs! boq (quad-attrs (first qs))) + (set-quad-attrs! eoq (quad-attrs (last qs))) + (append (list boq) qs (list eoq))) \ No newline at end of file diff --git a/quad2/main.rkt b/quad2/main.rkt index f9718755..1555d3f5 100644 --- a/quad2/main.rkt +++ b/quad2/main.rkt @@ -38,6 +38,8 @@ resolve-font-sizes resolve-font-features parse-page-sizes + resolve-font-paths + complete-attr-paths ;; linearization ============= ;; we postpone this step until we're certain any @@ -45,11 +47,10 @@ ;; has been absorbed into the attrs ;; (e.g., cascading font sizes) ;; because once we linearize, that information is gone. - (print-pass linearize) + linearize + (print-pass append-boq-and-eoq) ;; post-linearization resolutions & parsings ============= - resolve-font-paths - complete-attr-paths mark-text-runs merge-adjacent-strings @@ -59,7 +60,7 @@ remove-font-without-char insert-fallback-font layout - make-drawing-insts + (print-pass make-drawing-insts) stackify)) (module+ main diff --git a/quad2/quad.rkt b/quad2/quad.rkt index fee8b408..9db14475 100644 --- a/quad2/quad.rkt +++ b/quad2/quad.rkt @@ -25,7 +25,7 @@ (? quad-attrs?) (? quad-elems?)) #true] [_ #false]) - (error 'no-dice)) + (raise-user-error 'quad-constructor (format "failed: ~v" (list tag attrs elems posn)))) (values tag attrs elems posn))) (define (quad-tag? x) (match x @@ -108,4 +108,11 @@ [(? string? str) (loop (make-quad #:elems (list str)))]))) (module+ test - (define q (make-quad #:tag 'div #:attrs (make-hasheq '((hello . "world"))) #:elems (list "fine")))) \ No newline at end of file + (define q (make-quad #:tag 'div #:attrs (make-hasheq '((hello . "world"))) #:elems (list "fine")))) + + + +(struct boq-quad quad ()) +(define boq (boq-quad #f (make-hasheq) null #f)) +(struct eoq-quad quad ()) +(define eoq (eoq-quad #f (make-hasheq) null #f)) \ No newline at end of file