diff --git a/songbook_core/data/templates/default.tex b/songbook_core/data/templates/default.tex index 141102ea..f506f956 100644 --- a/songbook_core/data/templates/default.tex +++ b/songbook_core/data/templates/default.tex @@ -1,3 +1,24 @@ +(%%) Copyright (C) 2014 The Songbook team (www.patacrep.com) +(%%) +(%%) This program is free software; you can redistribute it and/or +(%%) modify it under the terms of the GNU General Public License +(%%) as published by the Free Software Foundation; either version 2 +(%%) of the License, or (at your option) any later version. +(%%) +(%%) This program is distributed in the hope that it will be useful, +(%%) but WITHOUT ANY WARRANTY; without even the implied warranty of +(%%) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +(%%) GNU General Public License for more details. +(%%) +(%%) You should have received a copy of the GNU General Public License +(%%) along with this program; if not, write to the Free Software +(%%) Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +(%%) MA 02110-1301, USA. +(%%) +(%%) The latest version of this program can be obtained from +(%%) https://github.com/patacrep/ + + (% variables %) { "title": {"description": {"english": "Title", "french": "Titre"}, diff --git a/songbook_core/data/templates/layout.tex b/songbook_core/data/templates/layout.tex index 907a9b18..331f194e 100644 --- a/songbook_core/data/templates/layout.tex +++ b/songbook_core/data/templates/layout.tex @@ -1,27 +1,30 @@ +(%%) Copyright (C) 2014 The Songbook team (www.patacrep.com) +(%%) +(%%) This program is free software; you can redistribute it and/or +(%%) modify it under the terms of the GNU General Public License +(%%) as published by the Free Software Foundation; either version 2 +(%%) of the License, or (at your option) any later version. +(%%) +(%%) This program is distributed in the hope that it will be useful, +(%%) but WITHOUT ANY WARRANTY; without even the implied warranty of +(%%) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +(%%) GNU General Public License for more details. +(%%) +(%%) You should have received a copy of the GNU General Public License +(%%) along with this program; if not, write to the Free Software +(%%) Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +(%%) MA 02110-1301, USA. +(%%) +(%%) The latest version of this program can be obtained from +(%%) https://github.com/patacrep/ + + %% Automaticly 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. - -% This program is free software; you can redistribute it and/or -% modify it under the terms of the GNU General Public License -% as published by the Free Software Foundation; either version 2 -% of the License, or (at your option) any later version. -% -% This program is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with this program; if not, write to the Free Software -% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -% MA 02110-1301, USA. -% -% The latest version of this program can be obtained from -% https://github.com/patacrep/ - -% Copyright (C) 2014 The Songbook team (www.patacrep.com) +%% +%% Generated using Songbook (% variables %) { @@ -107,4 +110,5 @@ (* endblock *) \end{document} -% End of file + +(%%) End of file diff --git a/songbook_core/data/templates/patacrep.tex b/songbook_core/data/templates/patacrep.tex index d923a344..b5e4f5d5 100644 --- a/songbook_core/data/templates/patacrep.tex +++ b/songbook_core/data/templates/patacrep.tex @@ -1,3 +1,24 @@ +(%%) Copyright (C) 2014 The Songbook team (www.patacrep.com) +(%%) +(%%) This program is free software; you can redistribute it and/or +(%%) modify it under the terms of the GNU General Public License +(%%) as published by the Free Software Foundation; either version 2 +(%%) of the License, or (at your option) any later version. +(%%) +(%%) This program is distributed in the hope that it will be useful, +(%%) but WITHOUT ANY WARRANTY; without even the implied warranty of +(%%) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +(%%) GNU General Public License for more details. +(%%) +(%%) You should have received a copy of the GNU General Public License +(%%) along with this program; if not, write to the Free Software +(%%) Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +(%%) MA 02110-1301, USA. +(%%) +(%%) The latest version of this program can be obtained from +(%%) https://github.com/patacrep/ + + (% variables %) { "songnumberbgcolor": {"description": {"english": "Number Shade", "french": "Couleur des numéros"}, diff --git a/songbook_core/data/templates/songs.tex b/songbook_core/data/templates/songs.tex index 4529996b..89e26229 100644 --- a/songbook_core/data/templates/songs.tex +++ b/songbook_core/data/templates/songs.tex @@ -1,3 +1,24 @@ +(%%) Copyright (C) 2014 The Songbook team (www.patacrep.com) +(%%) +(%%) This program is free software; you can redistribute it and/or +(%%) modify it under the terms of the GNU General Public License +(%%) as published by the Free Software Foundation; either version 2 +(%%) of the License, or (at your option) any later version. +(%%) +(%%) This program is distributed in the hope that it will be useful, +(%%) but WITHOUT ANY WARRANTY; without even the implied warranty of +(%%) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +(%%) GNU General Public License for more details. +(%%) +(%%) You should have received a copy of the GNU General Public License +(%%) along with this program; if not, write to the Free Software +(%%) Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +(%%) MA 02110-1301, USA. +(%%) +(%%) The latest version of this program can be obtained from +(%%) https://github.com/patacrep/ + + (* extends "layout.tex" *) (* block songbookpreambule *) diff --git a/songbook_core/templates.py b/songbook_core/templates.py index bdceea33..0a161138 100644 --- a/songbook_core/templates.py +++ b/songbook_core/templates.py @@ -3,6 +3,7 @@ """Template for .tex generation settings and utilities""" from jinja2 import Environment, FileSystemLoader, ChoiceLoader, PackageLoader, TemplateNotFound +from jinja2.ext import Extension from jinja2.meta import find_referenced_templates as find_templates import os import re @@ -19,6 +20,16 @@ _LATEX_SUBS = ( (re.compile(r'\.\.\.+'), r'\\ldots'), ) +class VariablesExtension(Extension): + + tags = set(['variables']) + + def parse(self, parser): + parser.stream.next() + + parser.parse_statements(end_tokens=['name:endvariables'], drop_needle=True) + + return nodes.Const("") def _escape_tex(value): '''Escape TeX special characters''' @@ -50,13 +61,14 @@ class TexRenderer(object): 'songbook_core', os.path.join('data', 'templates') ), ]), + extensions=[VariablesExtension], ) self.texenv.block_start_string = '(*' self.texenv.block_end_string = '*)' self.texenv.variable_start_string = '((' self.texenv.variable_end_string = '))' - self.texenv.comment_start_string = '(% variables %)' - self.texenv.comment_end_string = '(% endvariables %)' + self.texenv.comment_start_string = '(#' + self.texenv.comment_end_string = '#)' self.texenv.line_comment_prefix = '(%%)' self.texenv.filters['escape_tex'] = _escape_tex self.texenv.trim_blocks = True