diff --git a/patacrep/songs/chordpro/ast.py b/patacrep/songs/chordpro/ast.py index b2cc6c08..2f32777b 100644 --- a/patacrep/songs/chordpro/ast.py +++ b/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' diff --git a/patacrep/songs/chordpro/data/latex/content_verse b/patacrep/songs/chordpro/data/latex/content_verse index b6065a7f..8b641270 100644 --- a/patacrep/songs/chordpro/data/latex/content_verse +++ b/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 *) diff --git a/test/test_chordpro/nolyrics.sgc b/test/test_chordpro/nolyrics.sgc new file mode 100644 index 00000000..fd59c884 --- /dev/null +++ b/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 diff --git a/test/test_chordpro/nolyrics.source b/test/test_chordpro/nolyrics.source new file mode 100644 index 00000000..881c1ab9 --- /dev/null +++ b/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 diff --git a/test/test_chordpro/nolyrics.tex b/test/test_chordpro/nolyrics.tex new file mode 100644 index 00000000..cac94e23 --- /dev/null +++ b/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