Browse Source

Merge pull request #239 from patacrep/songs_special_chars

Better manage tilde and circum
pull/240/head
oliverpool 8 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)
* Chordpro songs
* 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
* 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)

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

4
patacrep/songs/chordpro/__init__.py

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

17
test/test_book/special.tex.control

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

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

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

10
test/test_song/special.tsg

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

Loading…
Cancel
Save