From 8dfbc5ef259d7cc173d50ba13055efee55b84db1 Mon Sep 17 00:00:00 2001 From: Christoph Wagner Date: Sat, 23 Nov 2024 23:51:01 +0100 Subject: [PATCH] referencable appendix --- appendix.ly | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 appendix.ly diff --git a/appendix.ly b/appendix.ly new file mode 100644 index 0000000..36e56dd --- /dev/null +++ b/appendix.ly @@ -0,0 +1,44 @@ +appendix = +#(define-void-function (parser location title) (markup?) + (define (appendix-item->markup layout props appendix-item) + (interpret-markup layout props + (markup + #:override (cons 'appendixItem:heading (assoc-ref appendix-item "heading")) + #:override (cons 'appendixItem:text (assoc-ref appendix-item "text")) + (ly:output-def-lookup layout 'appendixItemMarkup)))) + (ly:book-add-bookpart! (ly:parser-lookup '$current-book) + #{ + \bookpart { + \markup { #title } + #(for-each + (lambda (item) + (add-score (ly:make-page-label-marker (string->symbol (car item)))) + (add-text + (make-on-the-fly-markup + (lambda (layout props arg) (appendix-item->markup layout props (cdr item))) + (make-null-markup))) + ) + (reverse APPENDIX_DATA)) + } + #})) + +#(define-markup-command (appendix-ref layout props label) (symbol?) + "call page-ref to appendix-item" + (interpret-markup layout props + (markup #:with-link label + #:override (cons 'appendixPage (make-page-ref-markup label "XXX" "?")) + (ly:output-def-lookup layout 'appendixReferenceMarkup)))) + +\paper { + appendixItemMarkup = \markup { + \left-column { + \line { \large \bold \fromproperty #'appendixItem:heading } + \vspace #0.2 + \sans \wordwrap-field #'appendixItem:text + \vspace #0.7 + } + } + appendixReferenceMarkup = \markup { + \fromproperty #'appendixPage + } +} \ No newline at end of file