songleaf.chordpro¶
Parse ChordPro text into a Song.
ChordPro puts chords inline, in square brackets, at the syllable they land on
(Paper [G]boats [D]drift), and describes the song with {directive: value}
lines.
[X]becomes achordannotation at that character offset of the bracket-free lyric line; a line of chords only becomes an empty text line carrying its chords in order, as insongleaf.parse.{title},{artist},{key},{capo},{tempo}(and their short forms) become metadata.{soc}/{eoc}(and verse, bridge, tab-less variants) and{c: label}comments becomesectionannotations; a section with no lines of its own is a marker ({"marker": True}), as insongleaf.parse.{x_songleaf_before: 0, 3}(written bysongleaf.export.to_chordpro()) marks the chords at those positions, counted over the song’s chords in text order, as sounding before their syllable (timing="before"): ChordPro has no way to say it.# commentsand other unknown directives are dropped.
>>> song = parse_chordpro("{title: Paper Boats}\n{soc}\nPaper [G]boats [D]drift\n{eoc}")
>>> song.text
'Paper boats drift'
>>> [(a.start, a.body["symbol"]) for a in song.of_kind("chord")]
[(6, 'G'), (12, 'D')]
>>> song.meta["title"], song.of_kind("section")[0].body["label"]
('Paper Boats', 'Chorus')
Module Attributes
The namespaced directive carrying |
Functions
|
Parse ChordPro text into a |
- songleaf.chordpro.BEFORE_DIRECTIVE = 'x_songleaf_before'¶
The namespaced directive carrying
timing="before"chords; apps that don’t know it skip it.