Browse Source

Merge pull request #105 from patacrep/nolyrics

Verses not containing lyrics are correctly rendered
pull/110/head
Louis 9 years ago
parent
commit
865b902be2
  1. 9
      patacrep/songs/chordpro/ast.py
  2. 10
      patacrep/songs/chordpro/data/latex/content_verse
  3. 14
      test/test_chordpro/nolyrics.sgc
  4. 9
      test/test_chordpro/nolyrics.source
  5. 34
      test/test_chordpro/nolyrics.tex

9
patacrep/songs/chordpro/ast.py

@ -173,6 +173,15 @@ class Verse(AST):
self.lines.insert(0, data)
return self
@property
def nolyrics(self):
"""Return `True` iff verse contains only notes (no lyrics)"""
for line in self.lines:
for item in line.line:
if not (isinstance(item, Space) or isinstance(item, ChordList)):
return False
return True
class Chorus(Verse):
"""Chorus"""
type = 'chorus'

10
patacrep/songs/chordpro/data/latex/content_verse

@ -1,5 +1,15 @@
(*- if content.nolyrics -*)
\begin{verse*}
\musicnote{\nolyrics
(* for line in content.lines *)
(( render(line) ))
(* endfor *)
}
\end{verse*}
(*- else *)
\begin{(( content.type ))}
(* for line in content.lines *)
(( render(line) ))
(* endfor *)
\end{(( content.type ))}
(*- endif *)

14
test/test_chordpro/nolyrics.sgc

@ -0,0 +1,14 @@
{language: english}
A chorus [A]with lyrics
[Emaj3]maj et nombre
[A B#]
[A] [B]
[C]
A chorus [C]with lyrics

9
test/test_chordpro/nolyrics.source

@ -0,0 +1,9 @@
A chorus [A]with lyrics
[Emaj3]maj et nombre
[A B#]
[A] [B]
[C]
A chorus [C]with lyrics

34
test/test_chordpro/nolyrics.tex

@ -0,0 +1,34 @@
\selectlanguage{english}
\beginsong{}[
by={
},
]
\begin{verse}
A chorus \[A]with lyrics
\[Emaj3]maj et nombre
\end{verse}
\begin{verse*}
\musicnote{\nolyrics
\[A B#]
}
\end{verse*}
\begin{verse*}
\musicnote{\nolyrics
\[A] \[B]
\[C]
}
\end{verse*}
\begin{verse}
A chorus \[C]with lyrics
\end{verse}
\endsong
Loading…
Cancel
Save