Browse Source

Merge pull request #239 from patacrep/songs_special_chars

Better manage tilde and circum
pull/240/head
oliverpool 9 years ago
committed by GitHub
parent
commit
d8e00899f6
  1. 1
      NEWS.md
  2. 2
      patacrep/data/templates/songs/chordpro/latex/content_word
  3. 8
      patacrep/data/templates/songs/chordpro/latex/song
  4. 4
      patacrep/songs/chordpro/__init__.py
  5. 17
      test/test_book/special.tex.control
  6. 2
      test/test_book/special_datadir/songs/special.csg
  7. 10
      test/test_song/special.tsg

1
NEWS.md

@ -16,6 +16,7 @@
* The 'error' option is considered for contentlist errors (incorrect syntax for instance) [#226](https://github.com/patacrep/patacrep/pull/226) * The 'error' option is considered for contentlist errors (incorrect syntax for instance) [#226](https://github.com/patacrep/patacrep/pull/226)
* Chordpro songs * Chordpro songs
* The `meta` directive is now supported: `{meta: COMMANDNAME:arg}` [#220](https://github.com/patacrep/patacrep/pull/220) * The `meta` directive is now supported: `{meta: COMMANDNAME:arg}` [#220](https://github.com/patacrep/patacrep/pull/220)
* The `~` and `^` characters will not be escaped [#239](https://github.com/patacrep/patacrep/pull/239)
* LaTeX songs * LaTeX songs
* The `meta` directive is now supported: `\metacrep{COMMANDNAME}{arg}` [#220](https://github.com/patacrep/patacrep/pull/220) * The `meta` directive is now supported: `\metacrep{COMMANDNAME}{arg}` [#220](https://github.com/patacrep/patacrep/pull/220)
* Faster index generation [#233](https://github.com/patacrep/patacrep/pull/233) * Faster index generation [#233](https://github.com/patacrep/patacrep/pull/233)

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

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

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

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

4
patacrep/songs/chordpro/__init__.py

@ -132,8 +132,8 @@ class Chordpro2LatexSong(ChordproSong):
'{': r'\{', '{': r'\{',
'}': r'\}', '}': r'\}',
'\\': r'\textbackslash{}', '\\': r'\textbackslash{}',
'^': r'\textasciicircum{}', '^': r'\textasciicircum{}', # Has special meaning in songs package (repeat chord)
'~': r'\textasciitilde{}', '~': r'\textasciitilde{}', # Used for non-breaking space in LaTeX
'#': r'\#', '#': r'\#',
'&': r'\&', '&': r'\&',
'$': r'\$', '$': r'\$',

17
test/test_book/special.tex.control

@ -134,23 +134,30 @@ guitar,
\selectlanguage{english} \selectlanguage{english}
\beginsong{\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}}[ \beginsong{\& \$ \% \# \_ \} \{ ~ \textasciicircum{} \textbackslash{}}[
by={ by={
\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} }, \& \$ \% \# \_ \} \{ ~ \textasciicircum{} \textbackslash{} },
album={\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}}, album={\& \$ \% \# \_ \} \{ ~ \textasciicircum{} \textbackslash{}},
url={http://&$\%\#_~^}, url={http://&$\%\#_~^},
] ]
\ifchorded
\begin{verse*}
\musicnote {\nolyrics \[A]}
\end{verse*}
\fi
\begin{verse} \begin{verse}
\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} \& \$ \% \# \_ \} \{ ~ ^ \textbackslash{}
\end{verse} \end{verse}
\begin{chorus} \begin{chorus}
\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} \& \$ \% \# \_ \} \{ ~ ^ \textbackslash{}
\end{chorus} \end{chorus}
\endsong \endsong

2
test/test_book/special_datadir/songs/special.csg

@ -3,6 +3,8 @@
{album: & $ % # _ \} \{ ~ ^ \\} {album: & $ % # _ \} \{ ~ ^ \\}
{url: http://&$%#_~^} {url: http://&$%#_~^}
[A]
& $ % \# _ \} \{ ~ ^ \\ & $ % \# _ \} \{ ~ ^ \\
{start_of_chorus} {start_of_chorus}

10
test/test_song/special.tsg

@ -1,9 +1,9 @@
\selectlanguage{english} \selectlanguage{english}
\beginsong{\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}}[ \beginsong{\& \$ \% \# \_ \} \{ ~ \textasciicircum{} \textbackslash{}}[
by={ by={
\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} }, \& \$ \% \# \_ \} \{ ~ \textasciicircum{} \textbackslash{} },
album={\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}}, album={\& \$ \% \# \_ \} \{ ~ \textasciicircum{} \textbackslash{}},
url={http://&$\%\#_~^}, url={http://&$\%\#_~^},
] ]
@ -11,12 +11,12 @@
\begin{verse} \begin{verse}
\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} \& \$ \% \# \_ \} \{ ~ ^ \textbackslash{}
\end{verse} \end{verse}
\begin{chorus} \begin{chorus}
\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} \& \$ \% \# \_ \} \{ ~ ^ \textbackslash{}
\end{chorus} \end{chorus}
\endsong \endsong

Loading…
Cancel
Save