add footer-text attribute

main
Matthew Butterick 5 years ago
parent f84ff7be91
commit 6360f313cc

@ -1,4 +1,4 @@
#lang scribble/manual
f#lang scribble/manual
@(require racket/runtime-path scribble/example quadwriter pitfall/page pitfall/color racket/format (for-label txexpr (except-in pollen #%module-begin) xml racket/base racket/draw quadwriter)
pollen/scribblings/mb-tools quad/pict)
@ -526,6 +526,10 @@ Columns per page. @racket[column-count] is a positive integer; @racket[column-ga
Whether footer is displayed. Default is @racket["true"]. Footer is suppressed if this value is @racket["none"] or @racket["false"].
}
@defthing[#:kind "attribute" footer-text symbol?]{
Text displayed in footer. Default is @racket["false"], which will lead to default text being used for the footer (= a combination of page number, document name, and time / date).
}
@subsubsection{Block-level attributes}

@ -174,6 +174,7 @@ Naming guidelines
page-margin-gutter
footer-display
footer-text
fn-ref
fn-text

@ -531,15 +531,17 @@
(font-size doc (* .8 default-font-size))
(font doc (path->string (quad-ref q font-path-key default-font-face)))
(fill-color doc default-font-color)
(text doc (format "~a · ~a at ~a" (quad-ref q :page-number 0)
(text doc (or (quad-ref q :footer-text)
(format "~a · ~a at ~a" (quad-ref q :page-number 0)
(if (quadwriter-test-mode) "test" (quad-ref q :doc-title "untitled"))
(date->string (if (quadwriter-test-mode) (seconds->date 0 #f) (current-date)) #t))
(date->string (if (quadwriter-test-mode) (seconds->date 0 #f) (current-date)) #t)))
x y))
(define (make-footer-quad col-q page-idx path)
(define-values (dir name _) (split-path (path-replace-extension path #"")))
(define attrs (let ([attrs (make-hasheq)])
(hash-set*! attrs
:footer-text (quad-ref col-q :footer-text)
:page-number (+ (quad-ref col-q :page-number-start (add1 (section-pages-used))) (sub1 page-idx))
:doc-title (string-titlecase (path->string name))
:font-family "text")
@ -731,8 +733,9 @@ https://github.com/mbutterick/typesetter/blob/882ec681ad1fa6eaee6287e53bc4320d96
(define ((page-finish-wrap make-page-quad path) cols q0 q page-idx)
(define page-quad (make-page-quad (+ (section-pages-used) page-idx)))
#R (quad-ref (car cols) :footer-text #true)
(define elems
(match (quad-ref (car cols) :footer-display #true)
(match #R (quad-ref (car cols) :footer-display #true)
[(or #false "none") (from-parent cols 'nw)]
[_ (cons (make-footer-quad (car cols) page-idx path) (from-parent cols 'nw))]))
(list (quad-copy page-quad

Loading…
Cancel
Save