|
|
|
@ -400,6 +400,28 @@
|
|
|
|
|
(cons new-section sections-acc)])
|
|
|
|
|
(section-pages-used (+ (section-pages-used) (length section-pages))))))
|
|
|
|
|
|
|
|
|
|
(define (resolve-parents doc)
|
|
|
|
|
;; resolve location of any quad with a dynamic anchor-parent attribute like @line:1
|
|
|
|
|
(for* ([section (in-list (quad-elems doc))]
|
|
|
|
|
[(page page-idx) (in-indexed (quad-elems section))]
|
|
|
|
|
#:when (page-quad? page))
|
|
|
|
|
(define unresolved-qs
|
|
|
|
|
(let loop ([x page])
|
|
|
|
|
(match x
|
|
|
|
|
[(? quad?) ((if (quad-ref x :anchor-parent)
|
|
|
|
|
(λ (tail) (cons x tail))
|
|
|
|
|
values) (append-map loop (quad-elems x)))]
|
|
|
|
|
[_ null])))
|
|
|
|
|
(for ([line (in-list (quad-elems page))]
|
|
|
|
|
[line-num (in-naturals 1)]
|
|
|
|
|
#:when (line-quad? line))
|
|
|
|
|
(define line-key (format "@line:~a" line-num))
|
|
|
|
|
#R line-key
|
|
|
|
|
(for ([uq (in-list unresolved-qs)]
|
|
|
|
|
#:when (equal? (quad-ref uq :anchor-parent) line-key))
|
|
|
|
|
(quad-update! line [elems (append (quad-elems line) (list uq))]))))
|
|
|
|
|
doc)
|
|
|
|
|
|
|
|
|
|
(define (correct-line-alignment doc)
|
|
|
|
|
;; correct lines with inner / outer alignment
|
|
|
|
|
;; all inner / outer lines are initially filled as if they were right-aligned
|
|
|
|
@ -474,7 +496,10 @@
|
|
|
|
|
(setup-pdf-metadata! qs (current-pdf))
|
|
|
|
|
;; all the heavy lifting happens inside `make-sections`
|
|
|
|
|
;; which calls out to `make-pages`, `make-columns`, and so on.
|
|
|
|
|
(define doc (correct-line-alignment (quad-update! q:doc [elems (make-sections qs)])))
|
|
|
|
|
(define doc (let* ([doc (quad-update! q:doc [elems (make-sections qs)])]
|
|
|
|
|
[doc (correct-line-alignment doc)]
|
|
|
|
|
[doc (resolve-parents doc)])
|
|
|
|
|
doc))
|
|
|
|
|
;; call `position` and `draw` separately so we can print a timer for each
|
|
|
|
|
(define positioned-doc (time-log position (position doc)))
|
|
|
|
|
;; drawing implies that a PDF is written to disk
|
|
|
|
|