From 6f74c8b55a9caf02396f4f64ad2ca803794af930 Mon Sep 17 00:00:00 2001 From: Louis Date: Sun, 27 Sep 2015 19:58:03 +0200 Subject: [PATCH 1/2] [WIP] Detect verses not containing any lyrics. They are not rendered correctly yet. Discussed in #87 --- patacrep/songs/chordpro/ast.py | 9 ++++++ .../songs/chordpro/data/latex/content_verse | 7 +++++ test/test_chordpro/nolyrics.sgc | 14 +++++++++ test/test_chordpro/nolyrics.source | 9 ++++++ test/test_chordpro/nolyrics.tex | 30 +++++++++++++++++++ 5 files changed, 69 insertions(+) create mode 100644 test/test_chordpro/nolyrics.sgc create mode 100644 test/test_chordpro/nolyrics.source create mode 100644 test/test_chordpro/nolyrics.tex 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 From 32a0065ef25304f26fba14c6699ce2fca183aa93 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Tue, 6 Oct 2015 16:04:40 +0200 Subject: [PATCH 2/2] Proposition of support for verse without lyrics --- .../songs/chordpro/data/latex/content_verse | 11 ++++++---- test/test_chordpro/nolyrics.tex | 22 +++++++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/patacrep/songs/chordpro/data/latex/content_verse b/patacrep/songs/chordpro/data/latex/content_verse index 8b641270..7f27c4eb 100644 --- a/patacrep/songs/chordpro/data/latex/content_verse +++ b/patacrep/songs/chordpro/data/latex/content_verse @@ -1,8 +1,11 @@ (*- if content.nolyrics -*) - TODO NOLYRICS - (* for line in content.lines *) - (( render(line) )) - (* endfor *) +\begin{verse*} +\musicnote{\nolyrics + (* for line in content.lines *) + (( render(line) )) + (* endfor *) +} +\end{verse*} (*- else *) \begin{(( content.type ))} (* for line in content.lines *) diff --git a/test/test_chordpro/nolyrics.tex b/test/test_chordpro/nolyrics.tex index cac94e23..2f017724 100644 --- a/test/test_chordpro/nolyrics.tex +++ b/test/test_chordpro/nolyrics.tex @@ -12,15 +12,19 @@ \end{verse} -TODO NOLYRICS - \[A B#] - - - -TODO NOLYRICS - \[A] \[B] - \[C] - +\begin{verse*} +\musicnote{\nolyrics + \[A B#] +} +\end{verse*} + + +\begin{verse*} +\musicnote{\nolyrics + \[A] \[B] + \[C] +} +\end{verse*} \begin{verse}