Browse Source

[WIP] Detect verses not containing any lyrics.

They are not rendered correctly yet.

Discussed in #87
pull/105/head
Louis 9 years ago
parent
commit
6f74c8b55a
  1. 9
      patacrep/songs/chordpro/ast.py
  2. 7
      patacrep/songs/chordpro/data/latex/content_verse
  3. 14
      test/test_chordpro/nolyrics.sgc
  4. 9
      test/test_chordpro/nolyrics.source
  5. 30
      test/test_chordpro/nolyrics.tex

9
patacrep/songs/chordpro/ast.py

@ -168,6 +168,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'

7
patacrep/songs/chordpro/data/latex/content_verse

@ -1,5 +1,12 @@
(*- if content.nolyrics -*)
TODO NOLYRICS
(* for line in content.lines *)
(( render(line) ))
(* endfor *)
(*- 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

30
test/test_chordpro/nolyrics.tex

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