diff --git a/quad/quad/scribblings/quad.scrbl b/quad/quad/scribblings/quad.scrbl index b9441412..b85f5c71 100644 --- a/quad/quad/scribblings/quad.scrbl +++ b/quad/quad/scribblings/quad.scrbl @@ -504,6 +504,11 @@ Color of the border on each edge of the quad. Value is a @tech{hex color} string Color of the background of the quad. Value is a @tech{hex color} string or @tech{named color} string. } +@deftogether[(@defthing[#:kind "attribute" space-before symbol?] + @defthing[#:kind "attribute" space-after symbol?])]{ +Vertical space added around a block. Value is given as a @tech{dimension string}. +} + @deftogether[(@defthing[#:kind "attribute" keep-first-lines symbol?] @defthing[#:kind "attribute" keep-last-lines symbol?] @defthing[#:kind "attribute" keep-all-lines symbol?])]{ diff --git a/quad/quadwriter/attrs.rkt b/quad/quadwriter/attrs.rkt index 22a44b7a..43126985 100644 --- a/quad/quadwriter/attrs.rkt +++ b/quad/quadwriter/attrs.rkt @@ -115,6 +115,9 @@ Naming guidelines block-clip ; whether box boundary clips its contents + space-after ; space after a block, like a paragraph + space-before + column-count column-gap diff --git a/quad/quadwriter/layout.rkt b/quad/quadwriter/layout.rkt index bf777829..489539c1 100644 --- a/quad/quadwriter/layout.rkt +++ b/quad/quadwriter/layout.rkt @@ -125,12 +125,17 @@ #:draw-start (if draw-debug-line? draw-debug void))) (define-quad line-spacer-quad line-break-quad ()) -(define (make-post-paragraph-spacer) + +(define only-prints-in-middle (λ (q sig) (not (memq sig '(start end))))) +(define (make-paragraph-spacer maybe-first-line-q key default-val) + (define arbitrary-width 20) (q #:type line-spacer-quad - #:size (pt 20 (* default-line-height 0.6)) + #:size (pt arbitrary-width (cond + [(and maybe-first-line-q (quad-ref maybe-first-line-q key))] + [else default-val])) #:from 'sw #:to 'nw - #:printable (λ (q sig) (not (memq sig '(start end)))) + #:printable only-prints-in-middle #:draw-start (if (draw-debug-line?) draw-debug void))) (define softies (map string '(#\space #\- #\u00AD))) @@ -336,10 +341,13 @@ #:type offsetter-quad) elems)]) 'sw))]))] [_ null])])) - (append new-lines (match ending-q - [(? page-break-quad? page-break) (list page-break)] ; hard page break - [#false (list (make-post-paragraph-spacer))] ; paragraph break - [_ null]))) ; hard line break + (define maybe-first-line (and (pair? new-lines) (car new-lines))) + (append (list (make-paragraph-spacer maybe-first-line :space-before 0)) + new-lines + (match ending-q + [(? page-break-quad? page-break) (list page-break)] ; hard page break + [#false (list (make-paragraph-spacer maybe-first-line :space-after (* default-line-height 0.6)))] ; paragraph break + [_ null]))) ; hard line break (define (line-wrap qs wrap-size) @@ -450,7 +458,7 @@ (define q:column-spacer (q #:type column-spacer-quad #:from 'ne #:to 'nw - #:printable (λ (q sig) (not (memq sig '(start end)))))) + #:printable only-prints-in-middle)) (define q:page (q #:id 'page