Fix lyrics import errors

This commit is contained in:
Matthias Neeracher 2007-10-17 16:07:49 +00:00
parent 37954c7b4f
commit cb762c4eee

View File

@ -376,11 +376,13 @@ while tokens.length > 0
stack.push([block, level, ""]) stack.push([block, level, ""])
block = token block = token
level = nestLevel level = nestLevel
stanzas.push(lyrics= []) stanzas.push(lyrics= []) if block == '\lyricmode'
when '\chordmode' when '\chordmode'
stack.push([block, level, ""]) stack.push([block, level, ""])
block = '\chords' block = '\chords'
level = nestLevel level = nestLevel
when '\lyricsto'
tokens[0..3] = nil
when '\new' when '\new'
if tokens[0] == "Lyrics" if tokens[0] == "Lyrics"
stack.push([block, level, ""]) stack.push([block, level, ""])
@ -495,13 +497,13 @@ while notes.size > 0 || chords.size > 0
if lyrics.size > 0 if lyrics.size > 0
stanza = i+1 stanza = i+1
syll = lyrics.shift syll = lyrics.shift
ly.push({'text' => syll[0], 'kind' => syll[1]}) ly.push({'text' => syll[0].gsub('_', ' '), 'kind' => syll[1]})
else else
ly.push({'text' => '', 'kind' => 0}) ly.push({'text' => '', 'kind' => 0})
end end
end end
if stanza < ly.size if stanza < ly.size
ly[ly.size-stanza..-1] = nil ly[stanza..-1] = nil
end end
note['lyrics'] = ly if stanza > 0 note['lyrics'] = ly if stanza > 0
end end