extract meta data from lilypond compilation
* write that as yaml file next to the other outputs * extract lyrics * makes chordpro export work in songbooks * more metadata for chordpro export
This commit is contained in:
@@ -72,31 +72,68 @@ TEXT = \markuplist {
|
||||
(if paper (set! $defaultpaper paper))
|
||||
)
|
||||
|
||||
;; ChordPro export: Store filename and extract metadata from basicSongInfo FIRST
|
||||
;; Meta-Daten des Liedes als YAML neben die Ausgabedatei schreiben
|
||||
;; (<ly:parser-output-name>.yml, landet wie das PDF relativ zum
|
||||
;; Arbeitsverzeichnis). Die Textseiten-Strophen kommen aus dem
|
||||
;; Render-Collector (chordpro.ily), deshalb wird erst bei der Ausgabe
|
||||
;; geschrieben: unsichtbarer delayed Stencil an der letzten Textseite.
|
||||
;; Ohne (nicht-leere) Textseiten gibt es keine Collector-Daten und die
|
||||
;; yml wird sofort geschrieben.
|
||||
(when (and (defined? 'yaml-export-enabled) yaml-export-enabled)
|
||||
;; Collector-Daten auch ohne ChordPro-Flag unter dem Ausgabenamen sammeln
|
||||
(set! chordpro-default-song-key (ly:parser-output-name))
|
||||
(if (any pair? TEXT_PAGES)
|
||||
(let* ((last-index (- (length TEXT_PAGES) 1))
|
||||
(last-page (list-ref TEXT_PAGES last-index))
|
||||
(trigger-stencil (yaml-delayed-song-write
|
||||
(ly:parser-output-name) HEADER MUSIC))
|
||||
(modified-last-page #{
|
||||
\markuplist {
|
||||
#last-page
|
||||
\stencil #trigger-stencil
|
||||
}
|
||||
#}))
|
||||
(set! TEXT_PAGES
|
||||
(append (list-head TEXT_PAGES last-index)
|
||||
(list modified-last-page))))
|
||||
(scm->yml-file
|
||||
(string-append (ly:parser-output-name) ".yml")
|
||||
(extract-song-data HEADER MUSIC #f (ly:parser-output-name)))))
|
||||
|
||||
;; ChordPro export (Einzellied): Song-Key ist der Ausgabename (die .cho
|
||||
;; landet wie das PDF relativ zum Arbeitsverzeichnis); Titel/Autoren
|
||||
;; kommen aus HEADER in den per-Song-Store.
|
||||
(when (and (defined? 'chordpro-export-enabled) chordpro-export-enabled)
|
||||
;; Use ly:parser-output-name which returns the output basename
|
||||
;; This will write relative to current working directory (same as PDF)
|
||||
(let ((output-name (ly:parser-output-name)))
|
||||
(set! chordpro-current-filename output-name))
|
||||
(set! chordpro-default-song-key (ly:parser-output-name))
|
||||
(chordpro-register-song-metadata chordpro-default-song-key HEADER))
|
||||
|
||||
;; Try to extract metadata from basicSongInfo \header block
|
||||
(when (defined? 'basicSongInfo)
|
||||
(let* ((header-alist (ly:module->alist basicSongInfo))
|
||||
(title (assoc-ref header-alist 'title))
|
||||
(authors (assoc-ref header-alist 'authors)))
|
||||
(when title
|
||||
(set! chordpro-header-title
|
||||
(if (markup? title)
|
||||
(markup->string title)
|
||||
(if (string? title) title "Untitled"))))
|
||||
(when authors
|
||||
(set! chordpro-header-authors authors)))))
|
||||
|
||||
(add-score #{
|
||||
\score {
|
||||
\MUSIC
|
||||
\layout { \LAYOUT }
|
||||
}#})
|
||||
;; ChordPro_music_collector (Strophen unter den Noten, siehe chordpro.ily)
|
||||
;; braucht den aktiven Song-Key VOR der Interpretation des Hauptscores.
|
||||
;; \consists nur bei chordpro-include-music-lyrics -- sonst keine Kosten
|
||||
;; (Grob-Acknowledger fuer JEDEN Akkord/jede Silbe/Strophenmarker des
|
||||
;; Hauptscores) fuer Lieder/Buecher, die das Feature nicht nutzen. Bewusst
|
||||
;; NICHT zusaetzlich an chordpro-export-enabled gekoppelt: die Flag ist
|
||||
;; eigenstaendig gedacht (steuert nur, ob \chordpro-delayed-write bzw.
|
||||
;; \write-book-chordpro am Ende tatsaechlich etwas schreiben -- ob dafuer
|
||||
;; Daten gesammelt wurden, ist eine davon unabhaengige Entscheidung).
|
||||
(set! chordpro-active-song-key (ly:parser-output-name))
|
||||
(if (and (defined? 'chordpro-include-music-lyrics) chordpro-include-music-lyrics)
|
||||
(add-score #{
|
||||
\score {
|
||||
\MUSIC
|
||||
\layout {
|
||||
\LAYOUT
|
||||
\context {
|
||||
\Score
|
||||
\consists \ChordPro_music_collector
|
||||
}
|
||||
}
|
||||
}#})
|
||||
(add-score #{
|
||||
\score {
|
||||
\MUSIC
|
||||
\layout { \LAYOUT }
|
||||
}#}))
|
||||
(add-text-pages TEXT_PAGES)
|
||||
|
||||
(add-score #{
|
||||
|
||||
Reference in New Issue
Block a user