diff --git a/patacrep/authors.py b/patacrep/authors.py index 11d1df60..03221ebc 100644 --- a/patacrep/authors.py +++ b/patacrep/authors.py @@ -16,12 +16,12 @@ def compile_authwords(authwords): return { 'ignore': authwords.get('ignore', []), 'after': [ - re.compile(RE_AFTER.format(word), re.LOCALE) - for word in authwords.get('after') + re.compile(RE_AFTER.format(word)) + for word in authwords.get('after', []) ], 'separators': [ - re.compile(RE_SEPARATOR.format(word), re.LOCALE) - for word in ([" %s" % word for word in authwords['separators']] + [',', ';']) + re.compile(RE_SEPARATOR.format(word)) + for word in ([" %s" % word for word in authwords.get('separators', [])] + [',', ';']) ], } diff --git a/patacrep/build.py b/patacrep/build.py index de7bb3ce..3998244d 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -29,8 +29,6 @@ GENERATED_EXTENSIONS = [ "_title.sxd", ] - - # pylint: disable=too-few-public-methods class Songbook: """Represent a songbook (.yaml) file. @@ -101,7 +99,11 @@ class Songbook: ) self._config['filename'] = output.name[:-4] + # Processing special options self._config['_bookoptions'] = iter_bookoptions(self._config) + self._config['chords']['_notenames'] = self._get_chord_names( + self._config['chords']['notation'] + ) renderer.render_tex(output, self._config) @@ -111,6 +113,15 @@ class Songbook: if self.has_errors(): raise errors.SongbookError("Some songs contain errors. Stopping as requested.") + @staticmethod + def _get_chord_names(notation): + """Return a list of chord names, given the user option.""" + if notation == "alphascale": + return ["A", "B", "C", "D", "E", "F", "G"] + if notation == "solfedge": + return ["La", "Si", "Do", r"R\'e", "Mi", "Fa", "Sol"] + return notation + def has_errors(self): """Return `True` iff errors have been encountered in the book. diff --git a/patacrep/content/sort.py b/patacrep/content/sort.py index 7ee5aff0..cb10d157 100755 --- a/patacrep/content/sort.py +++ b/patacrep/content/sort.py @@ -56,7 +56,7 @@ def key_generator(sort): field = song.data[key] except KeyError: LOGGER.debug( - "Ignoring unknown key '{}' for song {}.".format( + "Ignoring missing key '{}' for song {}.".format( key, files.relpath(song.fullpath), ) diff --git a/patacrep/data/img/internet.png b/patacrep/data/img/internet.png new file mode 100644 index 00000000..43299f17 Binary files /dev/null and b/patacrep/data/img/internet.png differ diff --git a/patacrep/data/templates/songbook/default.tex b/patacrep/data/templates/songbook/default.tex index 52d759b9..b16d0cba 100644 --- a/patacrep/data/templates/songbook/default.tex +++ b/patacrep/data/templates/songbook/default.tex @@ -66,8 +66,8 @@ description: \usepackage{chords} -\title{(( template_var.title ))} -\author{(( template_var.author ))} +\title{(( template_var.title|escape_specials() ))} +\author{(( template_var.author|escape_specials() ))} \newindex{titleidx}{((filename))_title} \newauthorindex{authidx}{((filename))_auth} @@ -85,11 +85,7 @@ description: \authsepword{((word))} (* endfor *) -(* if chords.notation=="alphascale" -*) - \notenamesout{A}{B}{C}{D}{E}{F}{G} -(* else -*) - \notenamesout{La}{Si}{Do}{R\'e}{Mi}{Fa}{Sol} -(* endif *) +\notenamesout{(( chords._notenames[0] ))}{(( chords._notenames[1] ))}{(( chords._notenames[2] ))}{(( chords._notenames[3] ))}{(( chords._notenames[4] ))}{(( chords._notenames[5] ))}{(( chords._notenames[6] ))} (* endblock *) (* block title *) @@ -103,12 +99,11 @@ description: (* block chords *) % list of chords -\ifchorded - \ifdiagram - \phantomsection - \addcontentsline{toc}{section}{\chordlistname} - \chords - \fi +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords \fi +\setcounter{songnum}{1}% (* endblock *) diff --git a/patacrep/data/templates/songbook/patacrep.tex b/patacrep/data/templates/songbook/patacrep.tex index 627ee080..d57f44e4 100644 --- a/patacrep/data/templates/songbook/patacrep.tex +++ b/patacrep/data/templates/songbook/patacrep.tex @@ -138,12 +138,12 @@ description: ]{hyperref} -\subtitle{(( template_var.subtitle ))} +\subtitle{(( template_var.subtitle|escape_specials ))} (* if template_var.version -*) \version{(( template_var.version ))} (* endif *) -\mail{(( template_var.email ))} -\web{(( template_var.url ))} +\mail{(( template_var.email|escape_url ))} +\web{(( template_var.url|escape_url ))} \picture{(( template_var.picture ))} \picturecopyright{(( template_var.picturecopyright ))} \footer{(( template_var.footer ))} diff --git a/patacrep/data/templates/songbook_model.yml b/patacrep/data/templates/songbook_model.yml index 05c40f2b..e1418e97 100644 --- a/patacrep/data/templates/songbook_model.yml +++ b/patacrep/data/templates/songbook_model.yml @@ -27,7 +27,15 @@ schema: type: //rec required: show: //bool - diagrampage: //bool + diagrampage: + type: //any + of: + - type: //str + value: "none" + - type: //str + value: "important" + - type: //str + value: "all" repeatchords: //bool lilypond: //bool tablatures: //bool @@ -48,12 +56,17 @@ schema: - type: //str value: "ukulele" notation: - type: //any - of: - - type: //str - value: "alphascale" - - type: //str - value: "solfedge" + type: //any + of: + - type: //str + value: "alphascale" + - type: //str + value: "solfedge" + - type: //arr + contents: //str + length: + min: 7 + max: 7 authors: type: //rec required: @@ -97,7 +110,7 @@ default: chords: show: yes diagramreminder: important - diagrampage: yes + diagrampage: all repeatchords: yes lilypond: no tablatures: no @@ -149,7 +162,7 @@ description: lilypond: "Display lilypond scores" tablatures: "Display tablatures" instrument: "Instrument for the diagrams" - notation: "Chord notation" + notation: "List of chord names, with special values `solfedge` being an alias for `['La', 'Si', 'Do', 'Ré', 'Mi', 'Fa', 'Sol']`, and `alphascale` for `['A', 'B', 'C', 'D', 'E', 'F', 'G']`." authors: separators: "Separator words between artists" @@ -175,7 +188,7 @@ description: lilypond: "Inclure les partitions lilypond" tablatures: "Inclure les tablatures" instrument: "Instrument pour les diagrammes d'accords" - notation: "Notation des accords" + notation: "Liste des noms de notes, en commençant par LA, sachant que `solfedge` est un alias pour `['La', 'Si', 'Do', 'Ré', 'Mi', 'Fa', 'Sol']`, et `alphascale` pour `['A', 'B', 'C', 'D', 'E', 'F', 'G']`." authors: separators: "Mots de séparation entre les artistes" diff --git a/patacrep/data/templates/songs/chordpro/chordpro/content_image b/patacrep/data/templates/songs/chordpro/chordpro/content_image index 4f9bf06c..7398eec3 100644 --- a/patacrep/data/templates/songs/chordpro/chordpro/content_image +++ b/patacrep/data/templates/songs/chordpro/chordpro/content_image @@ -1 +1 @@ -{image: (( content.argument|search_image ))} +{image: "(( content.filename|search_image ))" ((content.size|render_size))} diff --git a/patacrep/data/templates/songs/chordpro/chordpro/content_word b/patacrep/data/templates/songs/chordpro/chordpro/content_word index d9dd7a30..e90a86e9 100644 --- a/patacrep/data/templates/songs/chordpro/chordpro/content_word +++ b/patacrep/data/templates/songs/chordpro/chordpro/content_word @@ -1 +1 @@ -(( content.value )) +(( content.value|escape_specials('{}\\#') )) diff --git a/patacrep/data/templates/songs/chordpro/chordpro/song_header b/patacrep/data/templates/songs/chordpro/chordpro/song_header index 56ad6a3a..bca4357e 100644 --- a/patacrep/data/templates/songs/chordpro/chordpro/song_header +++ b/patacrep/data/templates/songs/chordpro/chordpro/song_header @@ -9,16 +9,16 @@ (* endif *) (*- for title in titles -*) - {title: (( title ))} + {title: (( title|escape_specials('{}\\') ))} (* endfor -*) (*- for author in authors -*) - {artist: (( author[1] )) (( author[0] ))} + {artist: (( author[1]|escape_specials('{}\\') )) (( author[0]|escape_specials('{}\\') ))} (* endfor -*) (*- for key in ['album', 'copyright'] *) (* if key in metadata -*) - {(( key )): (( metadata[key] ))} + {(( key )): (( metadata[key]|escape_specials('{}\\') ))} (* endif *) (* endfor *) (* if 'cover' in metadata -*) @@ -30,9 +30,13 @@ (* endfor -*) (*- for key in metadata.morekeys -*) - {key: (( key.keyword )): (( key.argument ))} + {key: (( key.keyword )): (( key.argument|escape_specials('{}\\') ))} (* endfor *) +(*- if 'url' in metadata -*) + {url: (( metadata.url|escape_url ))} +(* endif -*) + (*- for chord in metadata['define'] *) ((- render(chord) )) (* endfor *) diff --git a/patacrep/data/templates/songs/chordpro/latex/content_image b/patacrep/data/templates/songs/chordpro/latex/content_image index a567730d..be75cec6 100644 --- a/patacrep/data/templates/songs/chordpro/latex/content_image +++ b/patacrep/data/templates/songs/chordpro/latex/content_image @@ -1,6 +1,6 @@ (* block image *) -(* set image = content.argument|search_image|path2posix *) +(* set image = content.filename|search_image|path2posix *) (* if image *) -\image{(( image ))} +\image[(( content.size|render_size ))]{(( image ))} (*- endif *) (*- endblock *) diff --git a/patacrep/data/templates/songs/chordpro/latex/content_word b/patacrep/data/templates/songs/chordpro/latex/content_word index d9dd7a30..ebe4d86f 100644 --- a/patacrep/data/templates/songs/chordpro/latex/content_word +++ b/patacrep/data/templates/songs/chordpro/latex/content_word @@ -1 +1 @@ -(( content.value )) +(( content.value|escape_specials('{}&#_^%~$\\') )) diff --git a/patacrep/data/templates/songs/chordpro/latex/song b/patacrep/data/templates/songs/chordpro/latex/song index cb29cc29..08591d3a 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 )) + (( 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,9 +24,12 @@ }, (* for key in ['album', 'copyright'] *) (* if key in metadata *) - (( key ))={(( metadata[key] ))}, + (( key ))={(( metadata[key]|escape_specials('{}&#_^%~$\\') ))}, (* endif *) (* endfor *) + (* if 'url' in metadata *) + url={(( metadata.url|escape_url ))}, + (* endif *) (* if 'cover' in metadata *) (* block cover *) (* set cover = metadata["cover"].argument|search_image|path2posix *) @@ -36,7 +39,7 @@ (* endblock *) (* endif *) (* for key in metadata.morekeys *) - (( key.keyword ))={(( key.argument ))}, + (( key.keyword ))={(( key.argument|escape_specials('{}&#_^%~$\\') ))}, (* endfor *) ] diff --git a/patacrep/data/templates/styles/chords.sty b/patacrep/data/templates/styles/chords.sty index 236606e7..5f498e69 100644 --- a/patacrep/data/templates/styles/chords.sty +++ b/patacrep/data/templates/styles/chords.sty @@ -24,7 +24,7 @@ \raisebox{2em}{\chordname{##1}} % } % % Placing boxes - \ifimportantdiagramonly% + \ifdiagrampagereduced% \pl@cechord{#1}% \hspace{\stretch{1}}% \usebox{\@chordgroupbox@ii}% @@ -75,7 +75,17 @@ \newcommand{\chords}{ + \ifdiagrampage \begin{songs}{} + %important diagrams are hidden by \chordtabs + \renewcommand{\gtab}{\@ifstar + \gtab@Original% + \gtab@Original% + } + \renewcommand{\utab}{\@ifstar + \utab@Original% + \utab@Original% + } %hide song number \definecolor{SongNumberBgColor}{HTML}{FFFFFF} \renewcommand{\snumbgcolor}{SongNumberBgColor} @@ -391,5 +401,6 @@ \fi \end{songs} + \fi } \endinput diff --git a/patacrep/data/templates/styles/crepbook.sty b/patacrep/data/templates/styles/crepbook.sty index 8d7139c0..f89bebee 100644 --- a/patacrep/data/templates/styles/crepbook.sty +++ b/patacrep/data/templates/styles/crepbook.sty @@ -79,8 +79,8 @@ % Title page \long\def\subtitle#1{\long\def\@subtitle{#1}} \def\version#1{\def\@version{#1}} -\def\web#1{\def\@web{#1}} -\def\mail#1{\def\@mail{#1}} +\def\web#1{\def\@web{\url{#1}}} +\def\mail#1{\def\@mail{\href{mailto:#1}{\nolinkurl{#1}}}} \def\email#1{\def\@email{#1}} \def\picture#1{\def\@picture{#1}} \def\picturecopyright#1{\def\@picturecopyright{#1}} diff --git a/patacrep/data/templates/styles/patacrep.sty b/patacrep/data/templates/styles/patacrep.sty index 5ed071c2..7e5dcb5e 100644 --- a/patacrep/data/templates/styles/patacrep.sty +++ b/patacrep/data/templates/styles/patacrep.sty @@ -6,6 +6,7 @@ \NeedsTeXFormat{LaTeX2e}[1994/06/01] \ProvidesPackage{patacrep}[2014/06/17 Patacrep Package, version 1] +\RequirePackage[space]{grffile} \RequirePackage{graphicx,xcolor} % \RequirePackage{epstopdf} % \RequirePackage{fancybox} @@ -26,6 +27,14 @@ \newif{\iflilypondauto} \DeclareOption{lilypond}{\lilypondautotrue\lilypondtrue} +% diagram: insert a page of diagrams before the songs +\newif{\ifdiagrampage} +\DeclareOption{diagrampage}{\diagrampagetrue} + +% diagram: insert a page of the "important diagrams" before the songs +\newif{\ifdiagrampagereduced} +\DeclareOption{diagrampagereduced}{\diagrampagereducedtrue\diagrampagetrue} + % diagram: display chord diagrams at the beginning \newif{\ifdiagram} \DeclareOption{diagram}{\diagramtrue} @@ -392,7 +401,9 @@ \renewcommand{\textnote}[2][]{% \vspace{.1cm} \IfStrEq{}{#1}{\@textnoteold{#2}}{ - \iflanguage{#1}{\@textnoteold{#2}}{} + \IfStrEq{\mainlanguage}{#1}{ + \@textnoteold{#2} + }{} } } @@ -400,7 +411,9 @@ \renewcommand{\musicnote}[2][]{% \vspace{.1cm} \IfStrEq{}{#1}{\@musicnoteold{#2}}{ - \iflanguage{#1}{\@musicnoteold{#2}}{} + \IfStrEq{\mainlanguage}{#1}{ + \@musicnoteold{#2} + }{} } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/patacrep/index.py b/patacrep/index.py index d572f872..e520e713 100644 --- a/patacrep/index.py +++ b/patacrep/index.py @@ -16,8 +16,8 @@ from patacrep.latex import tex2plain EOL = "\n" # Pattern set to ignore latex command in title prefix -KEYWORD_PATTERN = re.compile(r"^%(\w+)\s?(.*)$", re.LOCALE) -FIRST_LETTER_PATTERN = re.compile(r"^(?:\{?\\\w+\}?)*[^\w]*(\w)", re.LOCALE) +KEYWORD_PATTERN = re.compile(r"^%(\w+)\s?(.*)$") +FIRST_LETTER_PATTERN = re.compile(r"^(?:\{?\\\w+\}?)*[^\w]*(\w)") def process_sxd(filename): """Parse sxd file. @@ -90,8 +90,7 @@ class Index: if 'prefix' in self.keywords: for prefix in self.keywords['prefix']: self.prefix_patterns.append(re.compile( - r"^({prefix})(\b|\\)(\s*.*)$".format(prefix=prefix), - re.LOCALE + r"^({prefix})(\b|\\)(\s*.*)$".format(prefix=prefix) )) if self.indextype == "AUTHOR": diff --git a/patacrep/latex/__init__.py b/patacrep/latex/__init__.py index d2a57fc8..34954a15 100644 --- a/patacrep/latex/__init__.py +++ b/patacrep/latex/__init__.py @@ -16,7 +16,7 @@ LOGGER = logging.getLogger(__name__) DEFAULT_LANGUAGE = "en_us" BABEL_LANGUAGES = OrderedDict(( - ('de_de', 'german'), + ('de_de', 'ngerman'), # german (old), germanb (like german) ('de_at', 'austrian'), ('eo_uy', 'esperanto'), ('en_us', 'english'), # USenglish, american @@ -53,8 +53,6 @@ BABEL_LANGUAGES = OrderedDict(( # ('??_??', 'finnish'), # ('??_??', 'acadian'), # ('??_??', 'galician'), - # ('??_??', 'germanb'), - # ('??_??', 'ngerman'), # ('??_??', 'naustrian'), # ('??_??', 'greek'), # ('??_??', 'polutonikogreek'), diff --git a/patacrep/songs/__init__.py b/patacrep/songs/__init__.py index b1d80f5d..c58aaae9 100644 --- a/patacrep/songs/__init__.py +++ b/patacrep/songs/__init__.py @@ -294,7 +294,7 @@ def unprefixed_title(title, prefixes): """Remove the first prefix of the list in the beginning of title (if any). """ for prefix in prefixes: - match = re.compile(r"^(%s)\b\s*(.*)$" % prefix, re.LOCALE).match(title) + match = re.compile(r"^(%s)\b\s*(.*)$" % prefix).match(title) if match: return match.group(2) return title diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index a7fd3e3b..8464131f 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -3,6 +3,7 @@ import logging import operator import os +import urllib from jinja2 import Environment, FileSystemLoader, ChoiceLoader from jinja2 import contextfunction @@ -30,6 +31,13 @@ class ChordproSong(Song): # pylint: disable=abstract-method output_language = None + _translation_map = {} + _translation_map_url = None + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + if self._translation_map_url is None: + self._translation_map_url = self._translation_map def _parse(self): """Parse content, and return the dictionary of song data.""" @@ -50,6 +58,8 @@ class ChordproSong(Song): filters.update({ 'search_image': self.search_image, 'search_partition': self.search_partition, + 'escape_specials': self._escape_specials, + 'escape_url': self._escape_url, }) return filters @@ -84,6 +94,20 @@ class ChordproSong(Song): context.vars['content'] = content return context.environment.get_template(content.template()).render(context) + def _escape_specials(self, content, chars=None, *, translation_map=None): + if translation_map is None: + translation_map = self._translation_map + if chars is None: + chars = translation_map.keys() + return str(content).translate(str.maketrans({ + key: value + for key, value in translation_map.items() + if key in chars + })) + + def _escape_url(self, content): + return self._escape_specials(content, translation_map=self._translation_map_url) + class Chordpro2HtmlSong(ChordproSong): """Render chordpro song to html code""" @@ -104,6 +128,25 @@ 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'\_', + } + _translation_map_url = { + " ": urllib.parse.quote(" "), + "{": urllib.parse.quote("{"), + "}": urllib.parse.quote("}"), + '%': r'\%', + '#': r'\#', + } def search_file(self, filename, extensions=None, *, datadirs=None): _datadir, filename, _extension = self.search_datadir_file( @@ -139,6 +182,7 @@ class Chordpro2LatexSong(ChordproSong): parent = super()._filters() parent.update({ 'lang2babel': self.lang2babel, + 'render_size': self._render_size, }) return parent @@ -160,15 +204,48 @@ class Chordpro2LatexSong(ChordproSong): self.errors.append(new_error) return error.babel + @staticmethod + def _render_size(size): + items = [] + for name, value, unit in size: + items.append(name + "=" + value + unit) + return ", ".join(items) + class Chordpro2ChordproSong(ChordproSong): """Render chordpro song to chordpro code""" output_language = "chordpro" + _translation_map = { + '{': r'\{', + '}': r'\}', + '\\': '\\\\', + '#': r'\#', + } + _translation_map_url = { + '{': r'\{', + '}': r'\}', + '\\': '\\\\', + } + + def _filters(self): + parent = super()._filters() + parent.update({ + 'render_size': self._render_size, + }) + return parent def search_file(self, filename, extensions=None, *, datadirs=None): # pylint: disable=unused-variable return filename + @staticmethod + def _render_size(size): + items = [] + for name, value, unit in size: + items.append(name + "=" + value + unit) + return " ".join(items) + + SONG_RENDERERS = { "tsg": { 'csg': Chordpro2LatexSong, diff --git a/patacrep/songs/chordpro/ast.py b/patacrep/songs/chordpro/ast.py index 37dbae28..6f764e34 100644 --- a/patacrep/songs/chordpro/ast.py +++ b/patacrep/songs/chordpro/ast.py @@ -405,6 +405,22 @@ class Define(Directive): def __str__(self): return None +class Image(Directive): + """An image + + .. attribute:: filename + The filename of the image. + .. attribute:: size + An iterable of tuples ``(type, float, unit)``. + """ + + def __init__(self, filename, size=None): + self.filename = filename + if size is None: + size = [] + self.size = size + super().__init__("image", None) + class Tab(AST): """Tablature""" diff --git a/patacrep/songs/chordpro/lexer.py b/patacrep/songs/chordpro/lexer.py index 7674c22f..c63049aa 100644 --- a/patacrep/songs/chordpro/lexer.py +++ b/patacrep/songs/chordpro/lexer.py @@ -49,7 +49,7 @@ class ChordProLexer: t_directive_SPACE = r'[ \t]+' t_directive_KEYWORD = r'[a-zA-Z_]+' - t_directiveargument_TEXT = r'[^}]+' + t_directiveargument_TEXT = r'[^\\}]+' @staticmethod def t_SOC(token): @@ -118,7 +118,7 @@ class ChordProLexer: @staticmethod def t_WORD(token): - r'[^{}\r\n\]\[\t ]+' + r'[^{}\\\r\n\]\[\t ]+' return token def t_LBRACKET(self, __token): @@ -150,6 +150,20 @@ class ChordProLexer: self.lexer.push_state('directiveargument') return token + @staticmethod + def t_ESCAPED(token): + r'\\[{} #\\]' + token.value = token.value[1] + token.type = "WORD" + return token + + @staticmethod + def t_directiveargument_ESCAPED(token): + r'\\[{} #\\]' + token.value = token.value[1] + token.type = "TEXT" + return token + def error(self, token, more=""): """Display error message, and skip illegal token.""" message = "Illegal character '{char}'{more}.".format( diff --git a/patacrep/songs/chordpro/syntax.py b/patacrep/songs/chordpro/syntax.py index b4c28cc7..a1e3f6e6 100644 --- a/patacrep/songs/chordpro/syntax.py +++ b/patacrep/songs/chordpro/syntax.py @@ -2,6 +2,7 @@ import logging import re +import shlex import ply.yacc as yacc @@ -124,10 +125,67 @@ class ChordproParser(Parser): fingers=fingers, ) + def _iter_raw_image_size_arguments(self, arguments, *, lineno): + for item in arguments: + prefix, _, suffix = item.partition("=") + if prefix in ['width', 'height']: + match = re.compile( + r"^(?P(\d*\.\d+|\d+))(?Pcm|em|pt)$", + re.VERBOSE, + ).match(suffix) + if match is not None: + yield (prefix, match.groupdict()['value'], match.groupdict()['unit']) + continue + elif prefix in ['scale']: + match = re.compile( + r"^(?P(\d*\.\d+|\d+))$", + re.VERBOSE, + ).match(suffix) + if match is not None: + yield (prefix, match.groupdict()['value'], "") + continue + else: + self.error( + line=lineno, + message="Image: Unknown argument name '{}'.".format(prefix), + ) + continue + self.error( + line=lineno, + message="Image: Unsupported {} value: '{}'.".format(prefix, suffix), + ) + + def _iter_image_size_arguments(self, argument, *, lineno): + arguments = set() + length_names = frozenset(["width", "height"]) + for name, value, unit in self._iter_raw_image_size_arguments(argument, lineno=lineno): + if name in arguments: + self.error( + line=lineno, + message="Image: Ignoring repeated argument: {}.".format(name), + ) + continue + if ( + name == "scale" and not length_names.isdisjoint(arguments) + ) or ( + name in length_names and "scale" in arguments + ): + self.error( + line=lineno, + message=( + "Image: Ignoring '{}' argument: Cannot mix scale and " + "width or height argument." + ).format(name), + ) + continue + arguments.add(name) + yield name, value, unit + def p_directive(self, symbols): """directive : LBRACE KEYWORD directive_next RBRACE | LBRACE SPACE KEYWORD directive_next RBRACE """ + # pylint: disable=too-many-branches if len(symbols) == 5: keyword = symbols[2] argument = symbols[3] @@ -171,7 +229,21 @@ class ChordproParser(Parser): symbols[0] = ast.Error() return self._directives.append(define) - + elif keyword == "image": + splitted = shlex.split(argument) + if len(splitted) < 1: + self.error( + line=symbols.lexer.lineno, + message="Missing filename for image directive", + ) + symbols[0] = ast.Error() + else: + symbols[0] = ast.Image( + splitted[0], + list( + self._iter_image_size_arguments(splitted[1:], lineno=symbols.lexer.lineno) + ), + ) else: directive = ast.Directive(keyword, argument) if directive.inline: @@ -182,9 +254,8 @@ class ChordproParser(Parser): @staticmethod def p_directive_next(symbols): - """directive_next : SPACE COLON TEXT - | COLON TEXT - | COLON + """directive_next : SPACE COLON directive_argument + | COLON directive_argument | empty """ if len(symbols) == 3: @@ -196,6 +267,16 @@ class ChordproParser(Parser): else: symbols[0] = None + @staticmethod + def p_directive_argument(symbols): + """directive_argument : TEXT directive_argument + | empty + """ + if len(symbols) == 3: + symbols[0] = symbols[1] + symbols[2] + else: + symbols[0] = "" + def p_line_error(self, symbols): """line_error : error directive""" self.error( diff --git a/patacrep/templates.py b/patacrep/templates.py index ca6740a1..214320eb 100644 --- a/patacrep/templates.py +++ b/patacrep/templates.py @@ -2,6 +2,7 @@ import logging import re +import urllib import yaml @@ -16,15 +17,6 @@ import patacrep.encoding LOGGER = logging.getLogger(__name__) -_LATEX_SUBS = ( - (re.compile(r'\\'), r'\\textbackslash'), - (re.compile(r'([{}_#%&$])'), r'\\\1'), - (re.compile(r'~'), r'\~{}'), - (re.compile(r'\^'), r'\^{}'), - (re.compile(r'"'), r"''"), - (re.compile(r'\.\.\.+'), r'\\ldots'), -) - _VARIABLE_REGEXP = re.compile( r""" \(\*-?\ *variables\ *\*\) # Match (* variables *) or (*- variables *) @@ -46,15 +38,47 @@ _VARIABLE_REGEXP = re.compile( """, re.VERBOSE|re.DOTALL) -def _escape_tex(value): +TRANSLATION_MAP = { + '{': r'\{', + '}': r'\}', + '\\': r'\textbackslash{}', + '^': r'\textasciicircum{}', + '~': r'\textasciitilde{}', + '#': r'\#', + '&': r'\&', + '$': r'\$', + '%': r'\%', + '_': r'\_', +} +TRANSLATION_MAP_URL = { + ' ': '\\' + urllib.parse.quote(" "), + '{': '\\' + urllib.parse.quote("{"), + '}': '\\' + urllib.parse.quote("}"), + '%': '\\%', + '\\': '\\\\', + '#': '\\#', + '&': '\\&', + } + +def _escape_specials(text, *, chars=None, translation_map=None): '''Escape TeX special characters''' - newval = value - for pattern, replacement in _LATEX_SUBS: - newval = pattern.sub(replacement, newval) - return newval + if translation_map is None: + translation_map = TRANSLATION_MAP + if chars is None: + chars = translation_map.keys() + return str(text).translate(str.maketrans({ + key: value + for key, value in translation_map.items() + if key in chars + })) + +def _escape_url(text): + """Escape TeX special characters, in url.""" + return _escape_specials(text, translation_map=TRANSLATION_MAP_URL) DEFAULT_FILTERS = { - "escape_tex": _escape_tex, + "escape_specials": _escape_specials, + "escape_url": _escape_url, "iter_datadirs": files.iter_datadirs, "path2posix": files.path2posix, } @@ -296,4 +320,9 @@ def iter_bookoptions(config): elif config['chords']['diagramreminder'] == "all": yield 'diagram' + if config['chords']['diagrampage'] == "important": + yield 'diagrampagereduced' + elif config['chords']['diagrampage'] == "all": + yield 'diagrampage' + yield config['chords']['instrument'] diff --git a/patacrep/tools/__main__.py b/patacrep/tools/__main__.py index 13794b14..1bfc3fab 100644 --- a/patacrep/tools/__main__.py +++ b/patacrep/tools/__main__.py @@ -2,85 +2,26 @@ """Command line client to :mod:`tools`""" -import argparse import logging -import operator -import os -import pkgutil -import re import sys +import argdispatch + import patacrep # Logging configuration logging.basicConfig(level=logging.INFO) LOGGER = logging.getLogger("patatools") -def _execlp(program, args): - """Call :func:`os.execlp`, adding `program` as the first argument to itself.""" - return os.execlp(program, program, *args) - -def _iter_subcommands(): - """Iterate over subcommands. - - The objects returned are tuples of: - - the name of the command; - - its description; - - the function to call to execute the subcommand. - """ - subcommands = [] - - # Get python subcommands - path = [os.path.join(item, "patacrep", "tools") for item in sys.path] - prefix = "patacrep.tools." - module_re = re.compile(r'{}(?P[^\.]*)\.__main__'.format(prefix)) - for module_loader, name, _ in pkgutil.walk_packages(path, prefix): - match = module_re.match(name) - if match: - module = module_loader.find_module(match.string).load_module() - if hasattr(module, "SUBCOMMAND_DESCRIPTION"): - subcommands.append(match.groupdict()['subcommand']) - yield ( - match.groupdict()['subcommand'], - getattr(module, "SUBCOMMAND_DESCRIPTION"), - module.main, - ) - -class ArgumentParser(argparse.ArgumentParser): - """Proxy class to circumvent an :mod:`argparse` bug. - - Contrarily to what documented, the `argparse.REMAINDER - `_ `nargs` setting - does not include the remainder arguments if the first one begins with `-`. - - This bug is reperted as `17050 `_. This - class can be deleted once this bug has been fixed. - """ - - def parse_args(self, args=None, namespace=None): - if args is None: - args = sys.argv[1:] - subcommands = [command[0] for command in set(_iter_subcommands())] - if len(args) > 0: - if args[0] in subcommands: - args = [args[0], "--"] + args[1:] - - value = super().parse_args(args, namespace) - - if hasattr(value, 'remainder'): - value.remainder = value.remainder[1:] - return value - - def commandline_parser(): """Return a command line parser.""" - parser = ArgumentParser( + parser = argdispatch.ArgumentParser( prog="patatools", description=( "Miscellaneous tools for patacrep." ), - formatter_class=argparse.RawTextHelpFormatter, + formatter_class=argdispatch.RawTextHelpFormatter, ) parser.add_argument( @@ -96,11 +37,7 @@ def commandline_parser(): ) subparsers.required = True subparsers.dest = "subcommand" - - for command, message, function in sorted(_iter_subcommands(), key=operator.itemgetter(0)): - sub1 = subparsers.add_parser(command, help=message, add_help=False) - sub1.add_argument('remainder', nargs=argparse.REMAINDER) - sub1.set_defaults(function=function) + subparsers.add_submodules("patacrep.tools") return parser @@ -108,9 +45,7 @@ def main(args=None): """Main function""" if args is None: args = sys.argv - parser = commandline_parser() - args = parser.parse_args(args[1:]) - args.function(["patatools-{}".format(args.subcommand)] + args.remainder) + commandline_parser().parse_args(args[1:]) if __name__ == "__main__": main() diff --git a/patacrep/tools/cache/__main__.py b/patacrep/tools/cache/__main__.py index 6bf2cd8e..5c75d52d 100644 --- a/patacrep/tools/cache/__main__.py +++ b/patacrep/tools/cache/__main__.py @@ -1,4 +1,4 @@ -"""`patatools cache` command: cache manipulation.""" +"""Perform operations on cache.""" import argparse import logging @@ -11,7 +11,6 @@ from patacrep import errors from patacrep.songbook import open_songbook LOGGER = logging.getLogger("patatools.cache") -SUBCOMMAND_DESCRIPTION = "Perform operations on cache." def filename(name): """Check that argument is an existing, readable file name. @@ -27,7 +26,7 @@ def commandline_parser(): parser = argparse.ArgumentParser( prog="patatools cache", - description=SUBCOMMAND_DESCRIPTION, + description="Convert between song formats.", formatter_class=argparse.RawTextHelpFormatter, ) diff --git a/patacrep/tools/convert/__main__.py b/patacrep/tools/convert/__main__.py index a7b25455..65b82d8b 100644 --- a/patacrep/tools/convert/__main__.py +++ b/patacrep/tools/convert/__main__.py @@ -1,4 +1,4 @@ -"""`patatools.convert` command: convert between song formats""" +"""Convert between song formats.""" import os import logging @@ -10,7 +10,6 @@ from patacrep.utils import yesno from patacrep.build import config_model LOGGER = logging.getLogger("patatools.convert") -SUBCOMMAND_DESCRIPTION = "Convert between song formats" def _usage(): return "patatools convert INPUTFORMAT OUTPUTFORMAT FILES" diff --git a/setup.py b/setup.py index 4d0c74c5..aacfe910 100755 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ setup( packages=find_packages(exclude=["test*"]), license="GPLv2 or any later version", install_requires=[ - "unidecode", "jinja2", "ply", "pyyaml", + "argdispatch", "unidecode", "jinja2", "ply", "pyyaml", ], entry_points={ 'console_scripts': [ diff --git a/test/test_songbook/.gitignore b/test/test_book/.gitignore similarity index 100% rename from test/test_songbook/.gitignore rename to test/test_book/.gitignore diff --git a/test/test_songbook/__init__.py b/test/test_book/__init__.py similarity index 100% rename from test/test_songbook/__init__.py rename to test/test_book/__init__.py diff --git a/test/test_songbook/content.tex.control b/test/test_book/content.tex.control similarity index 95% rename from test/test_songbook/content.tex.control rename to test/test_book/content.tex.control index 9fd7d242..38a79074 100644 --- a/test/test_songbook/content.tex.control +++ b/test/test_book/content.tex.control @@ -26,6 +26,7 @@ chorded, pictures, diagram, +diagrampage, guitar, ]{patacrep} @@ -79,13 +80,12 @@ guitar, \showindex{\authorindexname}{authidx} % list of chords -\ifchorded - \ifdiagram - \phantomsection - \addcontentsline{toc}{section}{\chordlistname} - \chords - \fi +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords \fi +\setcounter{songnum}{1}% \phantomsection \addcontentsline{toc}{section}{\songlistname} diff --git a/test/test_songbook/content.yaml b/test/test_book/content.yaml similarity index 100% rename from test/test_songbook/content.yaml rename to test/test_book/content.yaml diff --git a/test/test_songbook/content_datadir/content/foo.tex b/test/test_book/content_datadir/content/foo.tex similarity index 100% rename from test/test_songbook/content_datadir/content/foo.tex rename to test/test_book/content_datadir/content/foo.tex diff --git a/test/test_songbook/content_datadir/content/inter.isg b/test/test_book/content_datadir/content/inter.isg similarity index 100% rename from test/test_songbook/content_datadir/content/inter.isg rename to test/test_book/content_datadir/content/inter.isg diff --git a/test/test_songbook/content_datadir/content/song.csg b/test/test_book/content_datadir/content/song.csg similarity index 100% rename from test/test_songbook/content_datadir/content/song.csg rename to test/test_book/content_datadir/content/song.csg diff --git a/test/test_songbook/content_datadir/content/song.tsg b/test/test_book/content_datadir/content/song.tsg similarity index 100% rename from test/test_songbook/content_datadir/content/song.tsg rename to test/test_book/content_datadir/content/song.tsg diff --git a/test/test_songbook/content_datadir/songs/include.sbc b/test/test_book/content_datadir/songs/include.sbc similarity index 100% rename from test/test_songbook/content_datadir/songs/include.sbc rename to test/test_book/content_datadir/songs/include.sbc diff --git a/test/test_songbook/content_datadir/songs/inter.isg b/test/test_book/content_datadir/songs/inter.isg similarity index 100% rename from test/test_songbook/content_datadir/songs/inter.isg rename to test/test_book/content_datadir/songs/inter.isg diff --git a/test/test_songbook/content_datadir/songs/song.csg b/test/test_book/content_datadir/songs/song.csg similarity index 100% rename from test/test_songbook/content_datadir/songs/song.csg rename to test/test_book/content_datadir/songs/song.csg diff --git a/test/test_songbook/content_datadir/songs/song.tsg b/test/test_book/content_datadir/songs/song.tsg similarity index 100% rename from test/test_songbook/content_datadir/songs/song.tsg rename to test/test_book/content_datadir/songs/song.tsg diff --git a/test/test_songbook/datadir.tex.control b/test/test_book/datadir.tex.control similarity index 92% rename from test/test_songbook/datadir.tex.control rename to test/test_book/datadir.tex.control index 1154a6fd..bdc8a210 100644 --- a/test/test_songbook/datadir.tex.control +++ b/test/test_book/datadir.tex.control @@ -28,6 +28,7 @@ chorded, pictures, repeatchords, importantdiagramonly, +diagrampage, guitar, ]{patacrep} @@ -82,13 +83,12 @@ guitar, \showindex{\authorindexname}{authidx} % list of chords -\ifchorded - \ifdiagram - \phantomsection - \addcontentsline{toc}{section}{\chordlistname} - \chords - \fi +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords \fi +\setcounter{songnum}{1}% \phantomsection \addcontentsline{toc}{section}{\songlistname} @@ -111,7 +111,7 @@ Chordpro}[ \lilypond{scores/datadir.ly} -\image{img/datadir.png} +\image[]{img/datadir.png} \endsong @@ -138,7 +138,7 @@ Chordpro}[ \lilypond{scores/datadir2.ly} -\image{img/datadir2.png} +\image[]{img/datadir2.png} \endsong @@ -165,7 +165,7 @@ Chordpro}[ \lilypond{@TEST_FOLDER@/datadir_datadir/songs/./relative.ly} -\image{@TEST_FOLDER@/datadir_datadir/songs/./relative.png} +\image[]{@TEST_FOLDER@/datadir_datadir/songs/./relative.png} \endsong @@ -192,7 +192,7 @@ Chordpro}[ \lilypond{@TEST_FOLDER@/datadir_datadir/songs/./subdir/subdir.ly} -\image{@TEST_FOLDER@/datadir_datadir/songs/./subdir/subdir.png} +\image[]{@TEST_FOLDER@/datadir_datadir/songs/./subdir/subdir.png} \endsong diff --git a/test/test_songbook/datadir.yaml b/test/test_book/datadir.yaml similarity index 100% rename from test/test_songbook/datadir.yaml rename to test/test_book/datadir.yaml diff --git a/test/test_songbook/datadir_datadir/img/datadir.png b/test/test_book/datadir_datadir/img/datadir.png similarity index 100% rename from test/test_songbook/datadir_datadir/img/datadir.png rename to test/test_book/datadir_datadir/img/datadir.png diff --git a/test/test_songbook/datadir_datadir/scores/datadir.ly b/test/test_book/datadir_datadir/scores/datadir.ly similarity index 100% rename from test/test_songbook/datadir_datadir/scores/datadir.ly rename to test/test_book/datadir_datadir/scores/datadir.ly diff --git a/test/test_songbook/datadir_datadir/songs/datadir.csg b/test/test_book/datadir_datadir/songs/datadir.csg similarity index 100% rename from test/test_songbook/datadir_datadir/songs/datadir.csg rename to test/test_book/datadir_datadir/songs/datadir.csg diff --git a/test/test_songbook/datadir_datadir/songs/datadir.tsg b/test/test_book/datadir_datadir/songs/datadir.tsg similarity index 100% rename from test/test_songbook/datadir_datadir/songs/datadir.tsg rename to test/test_book/datadir_datadir/songs/datadir.tsg diff --git a/test/test_songbook/datadir_datadir/songs/datadir2.csg b/test/test_book/datadir_datadir/songs/datadir2.csg similarity index 100% rename from test/test_songbook/datadir_datadir/songs/datadir2.csg rename to test/test_book/datadir_datadir/songs/datadir2.csg diff --git a/test/test_songbook/datadir_datadir/songs/datadir2.sg b/test/test_book/datadir_datadir/songs/datadir2.sg similarity index 100% rename from test/test_songbook/datadir_datadir/songs/datadir2.sg rename to test/test_book/datadir_datadir/songs/datadir2.sg diff --git a/test/test_songbook/datadir_datadir/songs/relative.csg b/test/test_book/datadir_datadir/songs/relative.csg similarity index 100% rename from test/test_songbook/datadir_datadir/songs/relative.csg rename to test/test_book/datadir_datadir/songs/relative.csg diff --git a/test/test_songbook/datadir_datadir/songs/relative.ly b/test/test_book/datadir_datadir/songs/relative.ly similarity index 100% rename from test/test_songbook/datadir_datadir/songs/relative.ly rename to test/test_book/datadir_datadir/songs/relative.ly diff --git a/test/test_songbook/datadir_datadir/songs/relative.png b/test/test_book/datadir_datadir/songs/relative.png similarity index 100% rename from test/test_songbook/datadir_datadir/songs/relative.png rename to test/test_book/datadir_datadir/songs/relative.png diff --git a/test/test_songbook/datadir_datadir/songs/relative.tsg b/test/test_book/datadir_datadir/songs/relative.tsg similarity index 100% rename from test/test_songbook/datadir_datadir/songs/relative.tsg rename to test/test_book/datadir_datadir/songs/relative.tsg diff --git a/test/test_songbook/datadir_datadir/songs/subdir/subdir.csg b/test/test_book/datadir_datadir/songs/subdir/subdir.csg similarity index 100% rename from test/test_songbook/datadir_datadir/songs/subdir/subdir.csg rename to test/test_book/datadir_datadir/songs/subdir/subdir.csg diff --git a/test/test_songbook/datadir_datadir/songs/subdir/subdir.ly b/test/test_book/datadir_datadir/songs/subdir/subdir.ly similarity index 100% rename from test/test_songbook/datadir_datadir/songs/subdir/subdir.ly rename to test/test_book/datadir_datadir/songs/subdir/subdir.ly diff --git a/test/test_songbook/datadir_datadir/songs/subdir/subdir.png b/test/test_book/datadir_datadir/songs/subdir/subdir.png similarity index 100% rename from test/test_songbook/datadir_datadir/songs/subdir/subdir.png rename to test/test_book/datadir_datadir/songs/subdir/subdir.png diff --git a/test/test_songbook/datadir_datadir/songs/subdir/subdir.tsg b/test/test_book/datadir_datadir/songs/subdir/subdir.tsg similarity index 100% rename from test/test_songbook/datadir_datadir/songs/subdir/subdir.tsg rename to test/test_book/datadir_datadir/songs/subdir/subdir.tsg diff --git a/test/test_songbook/datadir_datadir2/img/datadir2.png b/test/test_book/datadir_datadir2/img/datadir2.png similarity index 100% rename from test/test_songbook/datadir_datadir2/img/datadir2.png rename to test/test_book/datadir_datadir2/img/datadir2.png diff --git a/test/test_songbook/datadir_datadir2/scores/datadir2.ly b/test/test_book/datadir_datadir2/scores/datadir2.ly similarity index 100% rename from test/test_songbook/datadir_datadir2/scores/datadir2.ly rename to test/test_book/datadir_datadir2/scores/datadir2.ly diff --git a/test/test_book/lang_de.tex.control b/test/test_book/lang_de.tex.control new file mode 100644 index 00000000..5ed6126b --- /dev/null +++ b/test/test_book/lang_de.tex.control @@ -0,0 +1,131 @@ + + + + + + +%% Automatically generated document. +%% You may edit this file but all changes will be overwritten. +%% If you want to change this document, have a look at +%% the templating system. +%% +%% Generated using Songbook + +\makeatletter +\def\input@path{ % + {@TEST_FOLDER@/templates/styles/} % + {@DATA_FOLDER@/templates/styles/} % +} +\makeatother + +\documentclass[ + ]{article} + +\usepackage[ +chorded, +pictures, +repeatchords, +importantdiagramonly, +diagrampage, +guitar, + ]{crepbook} + +\usepackage[ + a4paper % paper size + ,includeheadfoot % include header and footer into text size + ,hmarginratio=1:1 % ratio between inner and outer margin (default) + ,outer=1.8cm % outer margin (right) + ,vmarginratio=1:1 % ratio between top and bottom margin + ,bmargin=1.3cm % bottom margin + ]{geometry} + +\usepackage{lmodern} + + +\usepackage[ngerman]{babel} +\lang{ngerman} + +\usepackage{graphicx} +\graphicspath{ % + {@TEST_FOLDER@/} % + {@DATA_FOLDER@/} % +} + + +\makeatletter +\@ifpackageloaded{hyperref}{}{ + \usepackage{url} + \newcommand{\phantomsection}{} + \newcommand{\hyperlink}[2]{#2} + \newcommand{\href}[2]{\expandafter\url\expandafter{#1}} +} +\makeatother + + +\usepackage{chords} + +\title{Guitar songbook} +\author{The Patacrep Team} + +\newindex{titleidx}{lang_de_title} +\newauthorindex{authidx}{lang_de_auth} + +\authignoreword{unknown} +\authbyword{by} +\authsepword{and} + +\notenamesout{A}{B}{C}{D}{E}{F}{G} + + +\pagestyle{empty}\definecolor{SongNumberBgColor}{HTML}{D1E4AE} +\definecolor{NoteBgColor}{HTML}{D1E4AE} +\definecolor{IndexBgColor}{HTML}{D1E4AE} + +\renewcommand{\snumbgcolor}{SongNumberBgColor} +\renewcommand{\notebgcolor}{NoteBgColor} +\renewcommand{\idxbgcolor}{IndexBgColor} + +\definecolor{tango-green-3}{HTML}{4e9a06} +\definecolor{tango-blue-3}{HTML}{204a87} +\usepackage[ + bookmarks, + bookmarksopen, + hyperfigures=true, + colorlinks=true, + linkcolor=tango-green-3, + urlcolor=tango-blue-3 + ]{hyperref} + + +\subtitle{} +\mail{crep@team-on-fire.com} +\web{http://www.patacrep.com} +\picture{img/treble_a} +\picturecopyright{Dbolton \url{http://commons.wikimedia.org/wiki/User:Dbolton}} +\footer{Generated using Songbook (\url{http://www.patacrep.com})} + + +\begin{document} + +\maketitle + + +\showindex{\songindexname}{titleidx} +\showindex{\authorindexname}{authidx} + +% list of chords +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords +\fi +\setcounter{songnum}{1}% + +\phantomsection +\addcontentsline{toc}{section}{\songlistname} + + + + + +\end{document} diff --git a/test/test_book/lang_de.yaml b/test/test_book/lang_de.yaml new file mode 100644 index 00000000..12ba0364 --- /dev/null +++ b/test/test_book/lang_de.yaml @@ -0,0 +1,5 @@ +book: + lang: de + +content: + - sort: \ No newline at end of file diff --git a/test/test_songbook/lang_default.tex.control b/test/test_book/lang_default.tex.control similarity index 94% rename from test/test_songbook/lang_default.tex.control rename to test/test_book/lang_default.tex.control index 42f1e087..40391656 100644 --- a/test/test_songbook/lang_default.tex.control +++ b/test/test_book/lang_default.tex.control @@ -26,6 +26,7 @@ chorded, pictures, repeatchords, importantdiagramonly, +diagrampage, guitar, ]{crepbook} @@ -113,13 +114,12 @@ guitar, \showindex{\authorindexname}{authidx} % list of chords -\ifchorded - \ifdiagram - \phantomsection - \addcontentsline{toc}{section}{\chordlistname} - \chords - \fi +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords \fi +\setcounter{songnum}{1}% \phantomsection \addcontentsline{toc}{section}{\songlistname} diff --git a/test/test_songbook/lang_default.yaml b/test/test_book/lang_default.yaml similarity index 100% rename from test/test_songbook/lang_default.yaml rename to test/test_book/lang_default.yaml diff --git a/test/test_songbook/lang_en.tex.control b/test/test_book/lang_en.tex.control similarity index 94% rename from test/test_songbook/lang_en.tex.control rename to test/test_book/lang_en.tex.control index 11a9f401..55573ddd 100644 --- a/test/test_songbook/lang_en.tex.control +++ b/test/test_book/lang_en.tex.control @@ -26,6 +26,7 @@ chorded, pictures, repeatchords, importantdiagramonly, +diagrampage, guitar, ]{crepbook} @@ -113,13 +114,12 @@ guitar, \showindex{\authorindexname}{authidx} % list of chords -\ifchorded - \ifdiagram - \phantomsection - \addcontentsline{toc}{section}{\chordlistname} - \chords - \fi +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords \fi +\setcounter{songnum}{1}% \phantomsection \addcontentsline{toc}{section}{\songlistname} diff --git a/test/test_songbook/lang_en.yaml b/test/test_book/lang_en.yaml similarity index 100% rename from test/test_songbook/lang_en.yaml rename to test/test_book/lang_en.yaml diff --git a/test/test_songbook/lang_fr.tex.control b/test/test_book/lang_fr.tex.control similarity index 94% rename from test/test_songbook/lang_fr.tex.control rename to test/test_book/lang_fr.tex.control index 1255dcce..aca45a48 100644 --- a/test/test_songbook/lang_fr.tex.control +++ b/test/test_book/lang_fr.tex.control @@ -26,6 +26,7 @@ chorded, pictures, repeatchords, importantdiagramonly, +diagrampage, guitar, ]{crepbook} @@ -113,13 +114,12 @@ guitar, \showindex{\authorindexname}{authidx} % list of chords -\ifchorded - \ifdiagram - \phantomsection - \addcontentsline{toc}{section}{\chordlistname} - \chords - \fi +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords \fi +\setcounter{songnum}{1}% \phantomsection \addcontentsline{toc}{section}{\songlistname} diff --git a/test/test_songbook/lang_fr.yaml b/test/test_book/lang_fr.yaml similarity index 100% rename from test/test_songbook/lang_fr.yaml rename to test/test_book/lang_fr.yaml diff --git a/test/test_songbook/languages.tex.control b/test/test_book/languages.tex.control similarity index 95% rename from test/test_songbook/languages.tex.control rename to test/test_book/languages.tex.control index 46d888dc..a1cfa123 100644 --- a/test/test_songbook/languages.tex.control +++ b/test/test_book/languages.tex.control @@ -27,6 +27,7 @@ chorded, pictures, repeatchords, importantdiagramonly, +diagrampage, guitar, ]{patacrep} @@ -82,13 +83,12 @@ guitar, \showindex{\authorindexname}{authidx} % list of chords -\ifchorded - \ifdiagram - \phantomsection - \addcontentsline{toc}{section}{\chordlistname} - \chords - \fi +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords \fi +\setcounter{songnum}{1}% \phantomsection \addcontentsline{toc}{section}{\songlistname} diff --git a/test/test_songbook/languages.yaml b/test/test_book/languages.yaml similarity index 100% rename from test/test_songbook/languages.yaml rename to test/test_book/languages.yaml diff --git a/test/test_songbook/languages_datadir/songs/language.csg b/test/test_book/languages_datadir/songs/language.csg similarity index 100% rename from test/test_songbook/languages_datadir/songs/language.csg rename to test/test_book/languages_datadir/songs/language.csg diff --git a/test/test_songbook/languages_datadir/songs/language_location.csg b/test/test_book/languages_datadir/songs/language_location.csg similarity index 100% rename from test/test_songbook/languages_datadir/songs/language_location.csg rename to test/test_book/languages_datadir/songs/language_location.csg diff --git a/test/test_songbook/languages_datadir/songs/no_language.csg b/test/test_book/languages_datadir/songs/no_language.csg similarity index 100% rename from test/test_songbook/languages_datadir/songs/no_language.csg rename to test/test_book/languages_datadir/songs/no_language.csg diff --git a/test/test_songbook/languages_datadir/songs/wrong_language.csg b/test/test_book/languages_datadir/songs/wrong_language.csg similarity index 100% rename from test/test_songbook/languages_datadir/songs/wrong_language.csg rename to test/test_book/languages_datadir/songs/wrong_language.csg diff --git a/test/test_songbook/languages_datadir/songs/wrong_location.csg b/test/test_book/languages_datadir/songs/wrong_location.csg similarity index 100% rename from test/test_songbook/languages_datadir/songs/wrong_location.csg rename to test/test_book/languages_datadir/songs/wrong_location.csg diff --git a/test/test_songbook/onthefly/content.onthefly.tex.control b/test/test_book/onthefly/content.onthefly.tex.control similarity index 93% rename from test/test_songbook/onthefly/content.onthefly.tex.control rename to test/test_book/onthefly/content.onthefly.tex.control index 8a882c85..3ee52e2e 100644 --- a/test/test_songbook/onthefly/content.onthefly.tex.control +++ b/test/test_book/onthefly/content.onthefly.tex.control @@ -25,6 +25,7 @@ chorded, pictures, diagram, +diagrampage, guitar, ]{patacrep} @@ -77,13 +78,12 @@ guitar, \showindex{\authorindexname}{authidx} % list of chords -\ifchorded - \ifdiagram - \phantomsection - \addcontentsline{toc}{section}{\chordlistname} - \chords - \fi +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords \fi +\setcounter{songnum}{1}% \phantomsection \addcontentsline{toc}{section}{\songlistname} diff --git a/test/test_songbook/onthefly/content.onthefly.yaml b/test/test_book/onthefly/content.onthefly.yaml similarity index 100% rename from test/test_songbook/onthefly/content.onthefly.yaml rename to test/test_book/onthefly/content.onthefly.yaml diff --git a/test/test_book/special.tex.control b/test/test_book/special.tex.control new file mode 100644 index 00000000..8f7d845a --- /dev/null +++ b/test/test_book/special.tex.control @@ -0,0 +1,162 @@ + + + + + + +%% Automatically generated document. +%% You may edit this file but all changes will be overwritten. +%% If you want to change this document, have a look at +%% the templating system. +%% +%% Generated using Songbook + +\makeatletter +\def\input@path{ % + {@TEST_FOLDER@/special_datadir/templates/styles/} % + {@TEST_FOLDER@/templates/styles/} % + {@DATA_FOLDER@/templates/styles/} % +} +\makeatother + +\documentclass[ + ]{article} + +\usepackage[ +chorded, +pictures, +repeatchords, +importantdiagramonly, +diagrampage, +guitar, + ]{crepbook} + +\usepackage[ + a4paper % paper size + ,includeheadfoot % include header and footer into text size + ,hmarginratio=1:1 % ratio between inner and outer margin (default) + ,outer=1.8cm % outer margin (right) + ,vmarginratio=1:1 % ratio between top and bottom margin + ,bmargin=1.3cm % bottom margin + ]{geometry} + +\usepackage{lmodern} + + +\PassOptionsToPackage{english}{babel} +\usepackage[english]{babel} +\lang{english} + +\usepackage{graphicx} +\graphicspath{ % + {@TEST_FOLDER@/special_datadir/} % + {@TEST_FOLDER@/} % + {@DATA_FOLDER@/} % +} + + +\makeatletter +\@ifpackageloaded{hyperref}{}{ + \usepackage{url} + \newcommand{\phantomsection}{} + \newcommand{\hyperlink}[2]{#2} + \newcommand{\href}[2]{\expandafter\url\expandafter{#1}} +} +\makeatother + + +\usepackage{chords} + +\title{\& \% \$ \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}} +\author{\& \% \$ \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}} + +\newindex{titleidx}{special_title} +\newauthorindex{authidx}{special_auth} + +\authignoreword{unknown} +\authbyword{by} +\authsepword{and} + +\notenamesout{A}{B}{C}{D}{E}{F}{G} + + +\pagestyle{empty}\definecolor{SongNumberBgColor}{HTML}{D1E4AE} +\definecolor{NoteBgColor}{HTML}{D1E4AE} +\definecolor{IndexBgColor}{HTML}{D1E4AE} + +\renewcommand{\snumbgcolor}{SongNumberBgColor} +\renewcommand{\notebgcolor}{NoteBgColor} +\renewcommand{\idxbgcolor}{IndexBgColor} + +\definecolor{tango-green-3}{HTML}{4e9a06} +\definecolor{tango-blue-3}{HTML}{204a87} +\usepackage[ + bookmarks, + bookmarksopen, + hyperfigures=true, + colorlinks=true, + linkcolor=tango-green-3, + urlcolor=tango-blue-3 + ]{hyperref} + + +\subtitle{\& \% \$ \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}} +\mail{foo@\\\%\&$\#_~^\%20\%7B\%7D} +\web{http://\\\%\&$\#_~^\%20\%7B\%7D} +\picture{img/treble_a} +\picturecopyright{Dbolton \url{http://commons.wikimedia.org/wiki/User:Dbolton}} +\footer{Generated using Songbook (\url{http://www.patacrep.com})} + + +\begin{document} + +\maketitle + + +\showindex{\songindexname}{titleidx} +\showindex{\authorindexname}{authidx} + +% list of chords +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords +\fi +\setcounter{songnum}{1}% + +\phantomsection +\addcontentsline{toc}{section}{\songlistname} + +\begin{songs}{titleidx,authidx} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./special.csg + +\selectlanguage{english} + +\beginsong{\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}}[ + by={ + \& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} }, + album={\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}}, + url={http://&$\%\#_~^}, +] + + + + +\begin{verse} + \& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} +\end{verse} + + +\begin{chorus} + \& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} +\end{chorus} + +\endsong + +\end{songs} + + + + +\end{document} diff --git a/test/test_book/special.yaml b/test/test_book/special.yaml new file mode 100644 index 00000000..24731c57 --- /dev/null +++ b/test/test_book/special.yaml @@ -0,0 +1,14 @@ +book: + datadir: + - special_datadir + +template: + default.tex: + title: "& % $ # _ } { ~ ^ \\" + author: "& % $ # _ } { ~ ^ \\" + patacrep.tex: + subtitle: "& % $ # _ } { ~ ^ \\" + url: "http://\\%&$#_~^ {}" + email: "foo@\\%&$#_~^ {}" + picture: "img/treble_a" + diff --git a/test/test_book/special_datadir/songs/special.csg b/test/test_book/special_datadir/songs/special.csg new file mode 100644 index 00000000..f5874022 --- /dev/null +++ b/test/test_book/special_datadir/songs/special.csg @@ -0,0 +1,10 @@ +{title: & $ % # _ \} \{ ~ ^ \\} +{artist: & $ % # _ \} \{ ~ ^ \\} +{album: & $ % # _ \} \{ ~ ^ \\} +{url: http://&$%#_~^} + +& $ % \# _ \} \{ ~ ^ \\ + +{start_of_chorus} +& $ % \# _ \} \{ ~ ^ \\ +{end_of_chorus} diff --git a/test/test_songbook/syntax.tex.control b/test/test_book/syntax.tex.control similarity index 56% rename from test/test_songbook/syntax.tex.control rename to test/test_book/syntax.tex.control index 1c925801..719dfc2f 100644 --- a/test/test_songbook/syntax.tex.control +++ b/test/test_book/syntax.tex.control @@ -2,8 +2,6 @@ - - %% Automatically generated document. %% You may edit this file but all changes will be overwritten. %% If you want to change this document, have a look at @@ -27,6 +25,7 @@ chorded, pictures, repeatchords, importantdiagramonly, +diagrampage, guitar, ]{patacrep} @@ -79,18 +78,80 @@ guitar, \showindex{\authorindexname}{authidx} % list of chords -\ifchorded - \ifdiagram - \phantomsection - \addcontentsline{toc}{section}{\chordlistname} - \chords - \fi +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords \fi +\setcounter{songnum}{1}% \phantomsection \addcontentsline{toc}{section}{\songlistname} \begin{songs}{titleidx,authidx} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./images.csg + +\selectlanguage{english} + +\beginsong{}[ + by={ + }, +] + + +\image[]{img/image.png} +\image[]{img/image with spaces.png} + + + +\image[scale=2]{img/image.png} +\image[scale=.20]{img/image with spaces.png} +\image[scale=1.2]{img/image.png} + + + +\image[width=2cm]{img/image.png} +\image[height=2cm]{img/image with spaces.png} +\image[width=2cm, height=1cm]{img/image.png} + + + +\image[width=2em]{img/image.png} +\image[height=2em]{img/image with spaces.png} +\image[width=2em, height=1em]{img/image.png} + + + +\image[width=50pt]{img/image.png} +\image[height=50pt]{img/image with spaces.png} +\image[width=50pt, height=100pt]{img/image.png} + + + +\image[width=2.5cm]{img/image.png} +\image[height=2.5cm]{img/image with spaces.png} +\image[width=2.5cm, height=1.5cm]{img/image.png} + + + +\image[width=3cm, height=10pt]{img/image.png} +\image[width=10pt, height=3cm]{img/image with spaces.png} + + + +\image[]{img/image.png} +\image[]{img/image.png} +\image[]{img/image with spaces.png} +\image[]{img/image with spaces.png} +\image[]{img/image.png} +\image[width=2cm]{img/image.png} +\image[width=2cm]{img/image.png} +\image[width=2cm]{img/image.png} + + +\endsong + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% songs/./musicnote.csg @@ -117,4 +178,4 @@ guitar, -\end{document} \ No newline at end of file +\end{document} diff --git a/test/test_songbook/syntax.yaml b/test/test_book/syntax.yaml similarity index 100% rename from test/test_songbook/syntax.yaml rename to test/test_book/syntax.yaml diff --git a/test/test_book/syntax_datadir/img/image with spaces.png b/test/test_book/syntax_datadir/img/image with spaces.png new file mode 100644 index 00000000..f088bf46 Binary files /dev/null and b/test/test_book/syntax_datadir/img/image with spaces.png differ diff --git a/test/test_book/syntax_datadir/img/image.png b/test/test_book/syntax_datadir/img/image.png new file mode 100644 index 00000000..f088bf46 Binary files /dev/null and b/test/test_book/syntax_datadir/img/image.png differ diff --git a/test/test_book/syntax_datadir/songs/images.csg b/test/test_book/syntax_datadir/songs/images.csg new file mode 100644 index 00000000..49d843a2 --- /dev/null +++ b/test/test_book/syntax_datadir/songs/images.csg @@ -0,0 +1,35 @@ +{image: image.png} +{image: "image with spaces.png"} + +{image: image.png scale=2 } +{image: "image with spaces.png" scale=.20} +{image: image.png scale=1.2} + +{image: image.png width=2cm} +{image: "image with spaces.png" height=2cm} +{image: image.png width=2cm height=1cm} + +{image: image.png width=2em} +{image: "image with spaces.png" height=2em} +{image: image.png width=2em height=1em} + +{image: image.png width=50pt} +{image: "image with spaces.png" height=50pt} +{image: image.png width=50pt height=100pt} + +{image: image.png width=2.5cm} +{image: "image with spaces.png" height=2.5cm} +{image: image.png width=2.5cm height=1.5cm} + +{image: image.png width=3cm height=10pt} +{image: "image with spaces.png" width=10pt height=3cm} + +{image: image.png width= height=} +{image: image.png error=foo} +{image: "image with spaces.png" not_a_size} +{image: "image with spaces.png" too many arguments} +{image: image.png width=2ex height=3km} +{image: image.png width=2cm width=3cm} +{image: image.png width=2cm scale=3cm} +{image: image.png width=2cm scale=3} +{image: } diff --git a/test/test_songbook/syntax_datadir/songs/musicnote.csg b/test/test_book/syntax_datadir/songs/musicnote.csg similarity index 100% rename from test/test_songbook/syntax_datadir/songs/musicnote.csg rename to test/test_book/syntax_datadir/songs/musicnote.csg diff --git a/test/test_songbook/test_compilation.py b/test/test_book/test_compilation.py similarity index 100% rename from test/test_songbook/test_compilation.py rename to test/test_book/test_compilation.py diff --git a/test/test_songbook/unicode.tex.control b/test/test_book/unicode.tex.control similarity index 93% rename from test/test_songbook/unicode.tex.control rename to test/test_book/unicode.tex.control index 7d088978..38ce6118 100644 --- a/test/test_songbook/unicode.tex.control +++ b/test/test_book/unicode.tex.control @@ -27,6 +27,7 @@ chorded, pictures, repeatchords, importantdiagramonly, +diagrampage, guitar, ]{patacrep} @@ -79,13 +80,12 @@ guitar, \showindex{\authorindexname}{authidx} % list of chords -\ifchorded - \ifdiagram - \phantomsection - \addcontentsline{toc}{section}{\chordlistname} - \chords - \fi +\ifdiagrampage + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords \fi +\setcounter{songnum}{1}% \phantomsection \addcontentsline{toc}{section}{\songlistname} diff --git a/test/test_songbook/unicode.yaml b/test/test_book/unicode.yaml similarity index 100% rename from test/test_songbook/unicode.yaml rename to test/test_book/unicode.yaml diff --git a/test/test_songbook/unicode_datadir/songs/nonbreak.csg b/test/test_book/unicode_datadir/songs/nonbreak.csg similarity index 100% rename from test/test_songbook/unicode_datadir/songs/nonbreak.csg rename to test/test_book/unicode_datadir/songs/nonbreak.csg diff --git a/test/test_song/image with spaces.png b/test/test_song/image with spaces.png new file mode 100644 index 00000000..e69de29b diff --git a/test/test_song/image.csg b/test/test_song/image.csg new file mode 100644 index 00000000..9f698456 --- /dev/null +++ b/test/test_song/image.csg @@ -0,0 +1,44 @@ +{lang: en} + +{image: "image.png" } +{image: "image with spaces.png" } + + +{image: "image.png" scale=2} +{image: "image with spaces.png" scale=.20} +{image: "image.png" scale=1.2} + + +{image: "image.png" width=2cm} +{image: "image with spaces.png" height=2cm} +{image: "image.png" width=2cm height=1cm} + + +{image: "image.png" width=2em} +{image: "image with spaces.png" height=2em} +{image: "image.png" width=2em height=1em} + + +{image: "image.png" width=50pt} +{image: "image with spaces.png" height=50pt} +{image: "image.png" width=50pt height=100pt} + + +{image: "image.png" width=2.5cm} +{image: "image with spaces.png" height=2.5cm} +{image: "image.png" width=2.5cm height=1.5cm} + + +{image: "image.png" width=3cm height=10pt} +{image: "image with spaces.png" width=10pt height=3cm} + + +{image: "image.png" } +{image: "image.png" } +{image: "image with spaces.png" } +{image: "image with spaces.png" } +{image: "image.png" } +{image: "image.png" width=2cm} +{image: "image.png" width=2cm} +{image: "image.png" width=2cm} + diff --git a/test/test_song/image.csg.source b/test/test_song/image.csg.source new file mode 100644 index 00000000..49d843a2 --- /dev/null +++ b/test/test_song/image.csg.source @@ -0,0 +1,35 @@ +{image: image.png} +{image: "image with spaces.png"} + +{image: image.png scale=2 } +{image: "image with spaces.png" scale=.20} +{image: image.png scale=1.2} + +{image: image.png width=2cm} +{image: "image with spaces.png" height=2cm} +{image: image.png width=2cm height=1cm} + +{image: image.png width=2em} +{image: "image with spaces.png" height=2em} +{image: image.png width=2em height=1em} + +{image: image.png width=50pt} +{image: "image with spaces.png" height=50pt} +{image: image.png width=50pt height=100pt} + +{image: image.png width=2.5cm} +{image: "image with spaces.png" height=2.5cm} +{image: image.png width=2.5cm height=1.5cm} + +{image: image.png width=3cm height=10pt} +{image: "image with spaces.png" width=10pt height=3cm} + +{image: image.png width= height=} +{image: image.png error=foo} +{image: "image with spaces.png" not_a_size} +{image: "image with spaces.png" too many arguments} +{image: image.png width=2ex height=3km} +{image: image.png width=2cm width=3cm} +{image: image.png width=2cm scale=3cm} +{image: image.png width=2cm scale=3} +{image: } diff --git a/test/test_song/image.png b/test/test_song/image.png new file mode 100644 index 00000000..e69de29b diff --git a/test/test_song/image.tsg b/test/test_song/image.tsg new file mode 100644 index 00000000..1ec6a98d --- /dev/null +++ b/test/test_song/image.tsg @@ -0,0 +1,59 @@ +\selectlanguage{english} + +\beginsong{}[ + by={ + }, +] + + +\image[]{img/image.png} +\image[]{img/image with spaces.png} + + + +\image[scale=2]{img/image.png} +\image[scale=.20]{img/image with spaces.png} +\image[scale=1.2]{img/image.png} + + + +\image[width=2cm]{img/image.png} +\image[height=2cm]{img/image with spaces.png} +\image[width=2cm, height=1cm]{img/image.png} + + + +\image[width=2em]{img/image.png} +\image[height=2em]{img/image with spaces.png} +\image[width=2em, height=1em]{img/image.png} + + + +\image[width=50pt]{img/image.png} +\image[height=50pt]{img/image with spaces.png} +\image[width=50pt, height=100pt]{img/image.png} + + + +\image[width=2.5cm]{img/image.png} +\image[height=2.5cm]{img/image with spaces.png} +\image[width=2.5cm, height=1.5cm]{img/image.png} + + + +\image[width=3cm, height=10pt]{img/image.png} +\image[width=10pt, height=3cm]{img/image with spaces.png} + + + +\image[]{img/image.png} +\image[]{img/image.png} +\image[]{img/image with spaces.png} +\image[]{img/image with spaces.png} +\image[]{img/image.png} +\image[width=2cm]{img/image.png} +\image[width=2cm]{img/image.png} +\image[width=2cm]{img/image.png} + + +\endsong \ No newline at end of file diff --git a/test/test_song/metadata.csg b/test/test_song/metadata.csg index 322a591b..825b8ece 100644 --- a/test/test_song/metadata.csg +++ b/test/test_song/metadata.csg @@ -16,7 +16,7 @@ {comment: Comment} {guitar_comment: GuitarComment} {partition: metadata_lilypond} -{image: metadata_image} +{image: "metadata_image" } Foo diff --git a/test/test_song/metadata.tsg b/test/test_song/metadata.tsg index 52582de4..09c768bf 100644 --- a/test/test_song/metadata.tsg +++ b/test/test_song/metadata.tsg @@ -20,7 +20,7 @@ Subtitle5}[ \textnote{Comment} \musicnote{GuitarComment} \lilypond{scores/metadata_lilypond} -\image{img/metadata_image} +\image[]{img/metadata_image} diff --git a/test/test_song/special.csg b/test/test_song/special.csg new file mode 100644 index 00000000..59b8d817 --- /dev/null +++ b/test/test_song/special.csg @@ -0,0 +1,13 @@ +{lang: en} +{title: & $ % # _ \} \{ ~ ^ \\} +{artist: & $ % # _ \} \{ ~ ^ \\} +{album: & $ % # _ \} \{ ~ ^ \\} +{url: http://&$%#_~^} + + +& $ % \# _ \} \{ ~ ^ \\ + + +{start_of_chorus} + & $ % \# _ \} \{ ~ ^ \\ +{end_of_chorus} diff --git a/test/test_song/special.csg.source b/test/test_song/special.csg.source new file mode 100644 index 00000000..f5874022 --- /dev/null +++ b/test/test_song/special.csg.source @@ -0,0 +1,10 @@ +{title: & $ % # _ \} \{ ~ ^ \\} +{artist: & $ % # _ \} \{ ~ ^ \\} +{album: & $ % # _ \} \{ ~ ^ \\} +{url: http://&$%#_~^} + +& $ % \# _ \} \{ ~ ^ \\ + +{start_of_chorus} +& $ % \# _ \} \{ ~ ^ \\ +{end_of_chorus} diff --git a/test/test_song/special.tsg b/test/test_song/special.tsg new file mode 100644 index 00000000..a7b232bb --- /dev/null +++ b/test/test_song/special.tsg @@ -0,0 +1,22 @@ +\selectlanguage{english} + +\beginsong{\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}}[ + by={ + \& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} }, + album={\& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{}}, + url={http://&$\%\#_~^}, +] + + + + +\begin{verse} + \& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} +\end{verse} + + +\begin{chorus} + \& \$ \% \# \_ \} \{ \textasciitilde{} \textasciicircum{} \textbackslash{} +\end{chorus} + +\endsong