diff --git a/NEWS.md b/NEWS.md index 1966a401..b05c8f1d 100644 --- a/NEWS.md +++ b/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) diff --git a/patacrep/data/templates/songs/chordpro/latex/content_word b/patacrep/data/templates/songs/chordpro/latex/content_word index ebe4d86f..f52978c4 100644 --- a/patacrep/data/templates/songs/chordpro/latex/content_word +++ b/patacrep/data/templates/songs/chordpro/latex/content_word @@ -1 +1 @@ -(( content.value|escape_specials('{}&#_^%~$\\') )) +(( content.value|escape_specials('{}&#_%$\\') )) diff --git a/patacrep/data/templates/songs/chordpro/latex/song b/patacrep/data/templates/songs/chordpro/latex/song index af97c285..b1a35715 100644 --- a/patacrep/data/templates/songs/chordpro/latex/song +++ b/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 *) ] diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index 9d10d7b4..7f3a88e1 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/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'\$', diff --git a/test/test_book/special.tex.control b/test/test_book/special.tex.control index e2fa50fe..967a6c22 100644 --- a/test/test_book/special.tex.control +++ b/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 diff --git a/test/test_book/special_datadir/songs/special.csg b/test/test_book/special_datadir/songs/special.csg index f5874022..84d3f8be 100644 --- a/test/test_book/special_datadir/songs/special.csg +++ b/test/test_book/special_datadir/songs/special.csg @@ -3,6 +3,8 @@ {album: & $ % # _ \} \{ ~ ^ \\} {url: http://&$%#_~^} +[A] + & $ % \# _ \} \{ ~ ^ \\ {start_of_chorus} diff --git a/test/test_song/special.tsg b/test/test_song/special.tsg index a7b232bb..8011323a 100644 --- a/test/test_song/special.tsg +++ b/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