1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 2004--2014 Jan Nieuwenhuizen <janneke@gnu.org>
4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl>
6 ;;;; LilyPond is free software: you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation, either version 3 of the License, or
9 ;;;; (at your option) any later version.
11 ;;;; LilyPond is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;;; GNU General Public License for more details.
16 ;;;; You should have received a copy of the GNU General Public License
17 ;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
19 (define-public (layout-extract-page-properties layout)
20 (list (append `((line-width . ,(ly:paper-get-number
22 (ly:output-def-lookup layout 'text-font-defaults))))
26 (define ((marked-up-headfoot what-odd what-even)
27 layout scopes page-number is-last-bookpart is-bookpart-last-page)
28 "Read variables @var{what-odd}, @var{what-even} from @var{layout},
29 and interpret them as markup. The @var{props} argument will include
30 variables set in @var{scopes} and @code{page:is-bookpart-last-page},
31 @code{page:is-last-bookpart}, @code{page:page-number-string}, and
32 @code{page:page-number}."
35 (ly:output-def-lookup layout sym))
37 (define (interpret-in-page-env potential-markup)
38 (if (markup? potential-markup)
39 (let* ((alists (map ly:module->alist scopes))
47 (symbol->string (car entry))))
54 (ly:modules-lookup scopes 'tagline
55 (ly:output-def-lookup layout 'tagline)))
56 (cons 'page:is-last-bookpart is-last-bookpart)
57 (cons 'page:is-bookpart-last-page is-bookpart-last-page)
58 (cons 'page:page-number-string
59 (number->string page-number))
60 (cons 'page:page-number page-number)))
64 (layout-extract-page-properties layout))))
65 (interpret-markup layout props potential-markup))
69 (interpret-in-page-env
70 (if (and (even? page-number)
71 (markup? (get what-even)))
74 (export marked-up-headfoot)
76 (define ((marked-up-title what) layout scopes)
77 "Read variables @var{what} from @var{scopes}, and interpret it as markup.
78 The @var{props} argument will include variables set in @var{scopes} (prefixed
82 (let ((x (ly:modules-lookup scopes sym)))
83 (if (markup? x) x #f)))
85 (let* ((alists (map ly:module->alist scopes))
93 (symbol->string (car entry))))
97 (props (append prefixed-alist
98 (layout-extract-page-properties layout)))
100 (markup (ly:output-def-lookup layout what)))
103 (interpret-markup layout props markup)
105 (export marked-up-title)