Browse Source

[WIP] Special characters: Song generation works. Songbook generation remains to implement

pull/213/head
Louis 9 years ago
parent
commit
dfc7762931
  1. 2
      patacrep/data/templates/songs/chordpro/latex/content_word
  2. 8
      patacrep/data/templates/songs/chordpro/latex/song
  3. 12
      patacrep/songs/chordpro/__init__.py
  4. 2
      test/test_song/special.csg.source
  5. 14
      test/test_songbook/special_datadir/songs/special.csg

2
patacrep/data/templates/songs/chordpro/latex/content_word

@ -1 +1 @@
(( content.value ))
(( content.value|escape_specials('{}&#_^%~$\\') ))

8
patacrep/data/templates/songs/chordpro/latex/song

@ -8,7 +8,7 @@
\beginsong{
(*- for title in titles -*)
(( title ))
(( title|escape_specials('{}&#_^%~$\\') ))
(*- if not loop.last -*)
\\
(* endif *)
@ -16,7 +16,7 @@
}[
by={
(* for author in authors *)
(( author[1] )) (( author[0] ))
(( author[1]|escape_specials('{}&#_^%~$\\') )) (( author[0]|escape_specials('{}&#_^%~$\\') ))
(*- if not loop.last -*)
,
(* endif *)
@ -24,7 +24,7 @@
},
(* for key in ['album', 'copyright'] *)
(* if key in metadata *)
(( key ))={(( metadata[key] ))},
(( key ))={(( metadata[key]|escape_specials('{}&#_^%~$\\') ))},
(* endif *)
(* endfor *)
(* if 'cover' in metadata *)
@ -36,7 +36,7 @@
(* endblock *)
(* endif *)
(* for key in metadata.morekeys *)
(( key.keyword ))={(( key.argument ))},
(( key.keyword ))={(( key.argument|escape_specials('{}&#_^%~$\\') ))},
(* endfor *)
]

12
patacrep/songs/chordpro/__init__.py

@ -113,6 +113,18 @@ class Chordpro2LatexSong(ChordproSong):
"""Render chordpro song to latex code"""
output_language = "latex"
_translation_map = {
'{': r'\{',
'}': r'\}',
'\\': r'\textbackslash{}',
'^': r'\textasciicircum{}',
'~': r'\textasciitilde{}',
'#': r'\#',
'&': r'\&',
'$': r'\$',
'%': r'\%',
'_': r'\_',
}
def search_file(self, filename, extensions=None, *, datadirs=None):
_datadir, filename, _extension = self.search_datadir_file(

2
test/test_song/special.csg.source

@ -1,7 +1,7 @@
TODO url ?
{title: & $ % # _ \} \{ ~ ^ \\}
{artist: & $ % # _ \} \{ ~ ^ \\}
{album: & $ % # _ \} \{ ~ ^ \\}
{url: & $ % # _ \} \{ ~ ^ \\}
& $ % \# _ \} \{ ~ ^ \\

14
test/test_songbook/special_datadir/songs/special.csg

@ -1,8 +1,10 @@
{title : & % $ \# _ \} \{ ~ ^ \\ }
{by: & % $ \# _ }\ \{ ~ ^ \\ }
{title: & $ % # _ \} \{ ~ ^ \\}
{artist: & $ % # _ \} \{ ~ ^ \\}
{album: & $ % # _ \} \{ ~ ^ \\}
{url: & $ % # _ \} \{ ~ ^ \\}
& % $ \# _ }\ \{ ~ ^ \\
& $ % \# _ \} \{ ~ ^ \\
{soc}
& % $ \# _ }\ \{ ~ ^ \\
{eoc}
{start_of_chorus}
& $ % \# _ \} \{ ~ ^ \\
{end_of_chorus}

Loading…
Cancel
Save