|
|
|
@ -24,7 +24,7 @@
|
|
|
|
|
|
|
|
|
|
(define-tag-function (blockquote attrs exprs)
|
|
|
|
|
(qexpr (list* '(display "block")
|
|
|
|
|
'(background-color "#eee")
|
|
|
|
|
'(background-color "#eee")
|
|
|
|
|
'(font "fira") '(fontsize "10") '(line-height "15")
|
|
|
|
|
'(border-width-top "0.5") '(border-color-top "gray") '(border-inset-top "8")
|
|
|
|
|
'(border-width-left "3") '(border-color-left "gray") '(border-inset-left "20")
|
|
|
|
@ -73,7 +73,7 @@
|
|
|
|
|
'(border-inset-top "10")
|
|
|
|
|
'(border-width-left "2") '(border-color-left "#669") '(border-inset-left "0")
|
|
|
|
|
'(border-inset-right "10") '(border-inset-bottom "-4")
|
|
|
|
|
'(inset-left "12") '(inset-right "12") '(inset-top "12") '(inset-bottom "24")
|
|
|
|
|
'(inset-left "12") '(inset-right "12") '(inset-top "12") '(inset-bottom "12")
|
|
|
|
|
attrs) new-exprs))
|
|
|
|
|
|
|
|
|
|
(define (list-base attrs exprs [bullet-val #f])
|
|
|
|
@ -313,14 +313,11 @@
|
|
|
|
|
#:out 'sw
|
|
|
|
|
#:offset (pt 0 (+ (quad-ref first-line 'inset-top 0)))
|
|
|
|
|
#:elems lines
|
|
|
|
|
;; this sizing approach doesn't work.
|
|
|
|
|
;; can't add inset-top and inset-bottom here because page composition has already happened.
|
|
|
|
|
;; therefore, resizing the block quads now will throw off the calculated page breaks.
|
|
|
|
|
#:size (pt (pt-x (size first-line)) ;
|
|
|
|
|
(+ (for/sum ([line (in-list lines)])
|
|
|
|
|
(pt-y (size line)))
|
|
|
|
|
(quad-ref first-line 'inset-top 0)
|
|
|
|
|
(quad-ref first-line 'inset-bottom 0)))
|
|
|
|
|
#:size (delay (pt (pt-x (size first-line)) ;
|
|
|
|
|
(+ (for/sum ([line (in-list lines)])
|
|
|
|
|
(pt-y (size line)))
|
|
|
|
|
(quad-ref first-line 'inset-top 0)
|
|
|
|
|
(quad-ref first-line 'inset-bottom 0))))
|
|
|
|
|
#:draw-start (λ (q doc)
|
|
|
|
|
;; adjust drawing coordinates for border inset
|
|
|
|
|
(match-define (list bil bit bir bib)
|
|
|
|
@ -357,7 +354,8 @@
|
|
|
|
|
(box-side (+ right (half bw-right)) bottom (- left (half bw-left)) bottom
|
|
|
|
|
(quad-ref first-line 'border-color-bottom) bw-bottom)
|
|
|
|
|
(box-side left (+ bottom (half bw-bottom)) left (- top (half bw-top))
|
|
|
|
|
(quad-ref first-line 'border-color-left) bw-left))))
|
|
|
|
|
(quad-ref first-line 'border-color-left) bw-left))
|
|
|
|
|
#:draw-end (λ (q doc) (draw-debug q doc "#6c6" "#9c9"))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (contiguous-group-by pred xs)
|
|
|
|
@ -381,6 +379,10 @@
|
|
|
|
|
(wrap xs vertical-height
|
|
|
|
|
#:soft-break line-spacer?
|
|
|
|
|
#:wrap-anywhere? #t
|
|
|
|
|
#:distance (λ (q dist-so-far wrap-qs)
|
|
|
|
|
;; do trial block insertions
|
|
|
|
|
(for/sum ([x (in-list (insert-blocks wrap-qs))])
|
|
|
|
|
(pt-y (size x))))
|
|
|
|
|
#:finish-wrap (λ (lns q idx)
|
|
|
|
|
(list (struct-copy quad q:page
|
|
|
|
|
[attrs (let ([page-number idx]
|
|
|
|
@ -390,21 +392,15 @@
|
|
|
|
|
(split-path (path-replace-extension path #"")))
|
|
|
|
|
(hash-set! h 'doc-title (string-titlecase (path->string name)))
|
|
|
|
|
h)]
|
|
|
|
|
[elems lns])))))
|
|
|
|
|
|
|
|
|
|
(define (insert-blocks pages)
|
|
|
|
|
;; block recomposition happens after page composition because page breaks can happen between lines.
|
|
|
|
|
;; iow, the lines within a block may be split over multiple pages, each of which should be drawn
|
|
|
|
|
;; as a separate block
|
|
|
|
|
(for/list ([page (in-list pages)])
|
|
|
|
|
(define lines (quad-elems page))
|
|
|
|
|
(define groups-of-lines (contiguous-group-by (λ (x) (quad-ref x 'display)) lines))
|
|
|
|
|
(define lines-and-blocks
|
|
|
|
|
(append* (for/list ([lines (in-list groups-of-lines)])
|
|
|
|
|
(match (quad-ref (car lines) 'display)
|
|
|
|
|
["block" (list (block-wrap lines))]
|
|
|
|
|
[_ lines]))))
|
|
|
|
|
(struct-copy quad page [elems lines-and-blocks])))
|
|
|
|
|
[elems (insert-blocks lns)])))))
|
|
|
|
|
|
|
|
|
|
(define (insert-blocks lines)
|
|
|
|
|
(define groups-of-lines (contiguous-group-by (λ (x) (quad-ref x 'display)) lines))
|
|
|
|
|
(append* (for/list ([line-group (in-list groups-of-lines)])
|
|
|
|
|
(match (quad-ref (car line-group) 'display)
|
|
|
|
|
["block" (list (block-wrap line-group))]
|
|
|
|
|
[_ line-group]))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define (run xs path)
|
|
|
|
|
(define pdf (time-name make-pdf (make-pdf #:compress #t
|
|
|
|
@ -418,7 +414,6 @@
|
|
|
|
|
[x (time-name ->string-quad (map (λ (x) (->string-quad pdf x)) x))]
|
|
|
|
|
[x (time-name line-wrap (line-wrap x line-width))]
|
|
|
|
|
[x (time-name page-wrap (page-wrap x vertical-height path))]
|
|
|
|
|
[x (time-name insert-containers (insert-blocks x))]
|
|
|
|
|
[x (time-name position (position (struct-copy quad q:doc [elems x])))])
|
|
|
|
|
(time-name draw (draw x pdf))))
|
|
|
|
|
|
|
|
|
|