|
|
@ -25,6 +25,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(define-tag-function (blockquote attrs exprs)
|
|
|
|
(define-tag-function (blockquote attrs exprs)
|
|
|
|
(qexpr (append '((display "block")
|
|
|
|
(qexpr (append '((display "block")
|
|
|
|
|
|
|
|
(line-align "center")
|
|
|
|
(background-color "#eee")
|
|
|
|
(background-color "#eee")
|
|
|
|
(font-family "fira") (font-size "10") (line-height "15")
|
|
|
|
(font-family "fira") (font-size "10") (line-height "15")
|
|
|
|
(border-width-top "0.5") (border-color-top "gray") (border-inset-top "8")
|
|
|
|
(border-width-top "0.5") (border-color-top "gray") (border-inset-top "8")
|
|
|
@ -63,7 +64,7 @@
|
|
|
|
(define h6 h3)
|
|
|
|
(define h6 h3)
|
|
|
|
|
|
|
|
|
|
|
|
(define-tag-function (code attrs exprs)
|
|
|
|
(define-tag-function (code attrs exprs)
|
|
|
|
(qexpr (append '((font-family "fira-mono")(font-size "10")(bg "aliceblue")) attrs) exprs))
|
|
|
|
(qexpr (append '((font-family "fira-mono")(line-align "right")(font-size "10")(bg "aliceblue")) attrs) exprs))
|
|
|
|
|
|
|
|
|
|
|
|
(define-tag-function (pre attrs exprs)
|
|
|
|
(define-tag-function (pre attrs exprs)
|
|
|
|
;; pre needs to convert white space to equivalent layout elements
|
|
|
|
;; pre needs to convert white space to equivalent layout elements
|
|
|
@ -82,7 +83,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define draw-debug? #t)
|
|
|
|
(define draw-debug? #t)
|
|
|
|
(define draw-debug-line? #f)
|
|
|
|
(define draw-debug-line? #t)
|
|
|
|
(define draw-debug-block? #t)
|
|
|
|
(define draw-debug-block? #t)
|
|
|
|
(define draw-debug-string? #f)
|
|
|
|
(define draw-debug-string? #f)
|
|
|
|
|
|
|
|
|
|
|
@ -220,7 +221,8 @@
|
|
|
|
border-width-left border-width-right border-width-top border-width-bottom
|
|
|
|
border-width-left border-width-right border-width-top border-width-bottom
|
|
|
|
border-color-left border-color-right border-color-top border-color-bottom
|
|
|
|
border-color-left border-color-right border-color-top border-color-bottom
|
|
|
|
background-color
|
|
|
|
background-color
|
|
|
|
keep-lines keep-first keep-last keep-all keep-with-next))
|
|
|
|
keep-lines keep-first keep-last keep-all keep-with-next
|
|
|
|
|
|
|
|
line-align line-align-first line-align-last))
|
|
|
|
(for* ([k (in-list block-attrs)]
|
|
|
|
(for* ([k (in-list block-attrs)]
|
|
|
|
[v (in-value (hash-ref source-hash k #f))]
|
|
|
|
[v (in-value (hash-ref source-hash k #f))]
|
|
|
|
#:when v)
|
|
|
|
#:when v)
|
|
|
@ -255,17 +257,34 @@
|
|
|
|
(match (consolidate-runs pcs)
|
|
|
|
(match (consolidate-runs pcs)
|
|
|
|
[(? pair? elems)
|
|
|
|
[(? pair? elems)
|
|
|
|
(define elem (unsafe-car elems))
|
|
|
|
(define elem (unsafe-car elems))
|
|
|
|
|
|
|
|
(match-define (list line-width line-height) (quad-size q:line))
|
|
|
|
|
|
|
|
(define new-size (let ()
|
|
|
|
|
|
|
|
(define line-heights
|
|
|
|
|
|
|
|
(filter-map (λ (q) (quad-ref q 'line-height)) pcs))
|
|
|
|
|
|
|
|
(pt line-width (if (empty? line-heights) line-height (apply max line-heights)))))
|
|
|
|
(list (struct-copy quad q:line
|
|
|
|
(list (struct-copy quad q:line
|
|
|
|
;; move block attrs up, so they are visible in page wrap
|
|
|
|
;; move block attrs up, so they are visible in page wrap
|
|
|
|
[attrs (copy-block-attrs (quad-attrs elem)
|
|
|
|
[attrs (copy-block-attrs (quad-attrs elem)
|
|
|
|
(hash-copy (quad-attrs q:line)))]
|
|
|
|
(hash-copy (quad-attrs q:line)))]
|
|
|
|
;; line width is static
|
|
|
|
;; line width is static
|
|
|
|
;; line height is the max 'line-height value or the natural height of q:line
|
|
|
|
;; line height is the max 'line-height value or the natural height of q:line
|
|
|
|
[size (let ()
|
|
|
|
[size new-size]
|
|
|
|
(define line-heights
|
|
|
|
#|
|
|
|
|
(filter-map (λ (q) (quad-ref q 'line-height)) pcs))
|
|
|
|
line alignment
|
|
|
|
(match-define (list w h) (quad-size q:line))
|
|
|
|
naive approach works but:
|
|
|
|
(pt w (if (empty? line-heights) h (apply max line-heights))))]
|
|
|
|
+ `line-width` is not the right reference value for calculating offset adjust
|
|
|
|
|
|
|
|
+ alignment width reference needs to take account of inset due to border
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|#
|
|
|
|
|
|
|
|
[offset (match (quad-ref elem 'line-align "left")
|
|
|
|
|
|
|
|
["left" (pt 0 0)]
|
|
|
|
|
|
|
|
[val (define elems-width (pt-x (apply pt+ (map size elems))))
|
|
|
|
|
|
|
|
(define h-divisor (match val
|
|
|
|
|
|
|
|
["right" 1]
|
|
|
|
|
|
|
|
["center" 2]))
|
|
|
|
|
|
|
|
(define offset-adjust
|
|
|
|
|
|
|
|
(pt (/ (- line-width elems-width) h-divisor) 0))
|
|
|
|
|
|
|
|
(pt+ offset-adjust (quad-offset q:line))])]
|
|
|
|
;; handle list indexes. drop new quad into line to hold list index
|
|
|
|
;; handle list indexes. drop new quad into line to hold list index
|
|
|
|
;; could also use this for line numbers
|
|
|
|
;; could also use this for line numbers
|
|
|
|
[elems (append
|
|
|
|
[elems (append
|
|
|
@ -362,8 +381,8 @@
|
|
|
|
(match-define (list bil bit bir bib)
|
|
|
|
(match-define (list bil bit bir bib)
|
|
|
|
(map (λ (k) (quad-ref first-line k 0))
|
|
|
|
(map (λ (k) (quad-ref first-line k 0))
|
|
|
|
'(border-inset-left border-inset-top border-inset-right border-inset-bottom)))
|
|
|
|
'(border-inset-left border-inset-top border-inset-right border-inset-bottom)))
|
|
|
|
(match-define (list left top) (map + (quad-origin q) (list bil bit)))
|
|
|
|
(match-define (list left top) (pt+ (quad-origin q) (list bil bit)))
|
|
|
|
(match-define (list width height) (map - (size q) (list (+ bil bir) (+ bit bib))))
|
|
|
|
(match-define (list width height) (pt- (size q) (list (+ bil bir) (+ bit bib))))
|
|
|
|
;; fill rect
|
|
|
|
;; fill rect
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
[(quad-ref first-line 'background-color)
|
|
|
|
[(quad-ref first-line 'background-color)
|
|
|
|