Matthew Butterick 4 years ago
parent c797052580
commit 31d14bcb82

@ -131,19 +131,19 @@
(format-id #'TYPES "q:~a-break" type)))])
#'(begin
(define TYPE-BREAK '(q ((break TYPE-STR)))) ...
(define ALL-BREAKS-ID (list (cons TYPE-BREAK Q:TYPE-BREAK) ...))))]))
(define ALL-BREAKS-ID (list (cons TYPE-STR Q:TYPE-BREAK) ...))))]))
(define-break-types all-breaks para line page column hr section)
(define (convert-break-quad x)
(define (convert-break-quad q)
;; replaces Q-expressions representing breaks
;; with special typed quads representing breaks.
;; Because typed quads have their own predicates,
;; it's faster to find them in wrapping operations
;; (instead of, say, using `equal?`)
(cond
[(assoc x all-breaks) => cdr]
[else x]))
[(assoc (quad-ref q :break) all-breaks) => cdr]
[else q]))
(define (convert-draw-quad q)
(quad-update! q

@ -139,7 +139,6 @@
(define qexpr (decode qx-arg
#:string-proc (compose1 smart-ellipses smart-dashes)
#:txexpr-proc smart-quotes))
(define super-qexpr (replace-breaks qexpr))
;; apply some default styling attributes.
;; These will only be used if the underlying q-expression hasn't specified its own values,
@ -148,7 +147,7 @@
(qexpr->quad (list 'q (list->attrs
:font-family default-font-family
:font-size (number->string default-font-size)
:line-height (number->string (floor (* default-line-height-multiplier default-font-size)))) super-qexpr)))
:line-height (number->string (floor (* default-line-height-multiplier default-font-size)))) qexpr)))
(setup-font-path-table! base-dir)
(define atomized-qs (atomize the-quad
#:attrs-proc handle-cascading-attrs
@ -157,10 +156,10 @@
#:emoji "fallback-emoji"
#:math "fallback-math"
#:font-path-resolver resolve-font-path!))
(define trimmed-qs (drop-leading-breaks atomized-qs))
(define hyphenated-qs (time-log hyphenate (handle-hyphenate trimmed-qs)))
(define hyphenated-qs (time-log hyphenate (handle-hyphenate atomized-qs)))
(define typed-quads (map generic->typed-quad hyphenated-qs))
(define indented-qs (insert-first-line-indents typed-quads))
(define trimmed-qs (drop-leading-breaks typed-quads))
(define indented-qs (insert-first-line-indents trimmed-qs))
indented-qs)
(define (setup-margins qs page-width page-height)

Loading…
Cancel
Save