diff --git a/patacrep/data/examples/example-all.sb b/patacrep/data/examples/example-all.sb index a9599a26..dba08cc0 100644 --- a/patacrep/data/examples/example-all.sb +++ b/patacrep/data/examples/example-all.sb @@ -6,6 +6,7 @@ "pictures" ], "booktype" : "chorded", +"template" : "patacrep.tex", "lang" : "french", "encoding": "utf8", "authwords" : { diff --git a/patacrep/data/templates/default.tex b/patacrep/data/templates/default.tex index 5f40d2d9..65c56c8f 100644 --- a/patacrep/data/templates/default.tex +++ b/patacrep/data/templates/default.tex @@ -1,23 +1,22 @@ -%! Copyright (C) 2014 The Patacrep 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/ - +%!- Copyright (C) 2014 The Patacrep 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 *) { @@ -40,47 +39,49 @@ "default": {"default": "alphascale", "french": "solfedge"} } } -(* endvariables *) +(* endvariables -*) -(* extends "songs.tex" *) -(* set indexes = "titleidx,authidx" *) +(*- extends "songs.tex" -*) +(*- set indexes = "titleidx,authidx" -*) (* block documentclass *) -\documentclass[(* for option in classoptions *) - ((option)), - (* endfor *)]{article} +\documentclass[ + (* for option in classoptions *) + ((option)), + (* endfor *) + ]{article} (* endblock *) (* block songbookpreambule *) - (( super() )) +(( super() )) - \usepackage{chords} +\usepackage{chords} - \title{((title))} - \author{((author))} +\title{((title))} +\author{((author))} - \newindex{titleidx}{((filename))_title} - \newauthorindex{authidx}{((filename))_auth} +\newindex{titleidx}{((filename))_title} +\newauthorindex{authidx}{((filename))_auth} - (* for prefix in titleprefixwords *) - \titleprefixword{((prefix))} - (* endfor*) - (* for word in authwords.ignore *) - \authignoreword{((word))} - (* endfor *) - (* for word in authwords.after *) - \authbyword{((word))} - (* endfor *) - (* for word in authwords.sep *) - \authsepword{((word))} - (* endfor *) +(* for prefix in titleprefixwords -*) + \titleprefixword{((prefix))} +(* endfor*) +(* for word in authwords.ignore -*) + \authignoreword{((word))} +(* endfor *) +(* for word in authwords.after -*) + \authbyword{((word))} +(* endfor *) +(* for word in authwords.sep -*) + \authsepword{((word))} +(* endfor *) - (* if notenamesout=="alphascale" *) - \notenamesout{A}{B}{C}{D}{E}{F}{G} - (* else *) - \notenamesout{La}{Si}{Do}{R\'e}{Mi}{Fa}{Sol} - (* endif *) +(* if notenamesout=="alphascale" -*) + \notenamesout{A}{B}{C}{D}{E}{F}{G} +(* else -*) + \notenamesout{La}{Si}{Do}{R\'e}{Mi}{Fa}{Sol} +(* endif *) (* endblock *) (* block title *) @@ -88,18 +89,18 @@ (* endblock *) (* block index *) - \showindex{\songindexname}{titleidx} - \showindex{\authorindexname}{authidx} +\showindex{\songindexname}{titleidx} +\showindex{\authorindexname}{authidx} (* endblock *) (* block chords *) - % list of chords - \ifchorded - \ifdiagram - \phantomsection - \addcontentsline{toc}{section}{\chordlistname} - \chords - \fi - \fi +% list of chords +\ifchorded + \ifdiagram + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords + \fi +\fi (* endblock *) diff --git a/patacrep/data/templates/layout.tex b/patacrep/data/templates/layout.tex index f525abd3..ae23d681 100644 --- a/patacrep/data/templates/layout.tex +++ b/patacrep/data/templates/layout.tex @@ -1,23 +1,22 @@ -%! Copyright (C) 2014 The Patacrep 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/ - +%!- Copyright (C) 2014 The Patacrep 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/ %% Automatically generated document. %% You may edit this file but all changes will be overwritten. @@ -27,10 +26,11 @@ %% Generated using Songbook \makeatletter -\def\input@path{(* for dir in datadir *) - {(( path2posix(dir) ))/latex/} % - (* endfor *) - } +\def\input@path{ % + (* for dir in datadir *) + {(( path2posix(dir) ))/latex/} % + (* endfor *) +} \makeatother (* block documentclass *) @@ -41,9 +41,9 @@ (* endblock *) (* block songbookpreambule *) - \usepackage[utf8]{inputenc} - \usepackage[T1]{fontenc} - \usepackage{lmodern} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{lmodern} (* endblock songbookpreambule *) (* block preambule *) @@ -71,4 +71,4 @@ \end{document} -%! End of file +%!- End of file diff --git a/patacrep/data/templates/patacrep.tex b/patacrep/data/templates/patacrep.tex index 21a84e64..96367078 100644 --- a/patacrep/data/templates/patacrep.tex +++ b/patacrep/data/templates/patacrep.tex @@ -1,23 +1,22 @@ -%! Copyright (C) 2014 The Patacrep 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/ - +%!- Copyright (C) 2014 The Patacrep 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 *) { @@ -61,21 +60,25 @@ "Des", "El", "Les", "Ma", "Mon", "Un"]} } } -(* endvariables *) +(* endvariables -*) -(* extends "default.tex" *) +(*- extends "default.tex" -*) (* block songbookpackages *) %! booktype, bookoptions and instruments are defined in "songs.tex" -\usepackage[((booktype)), - (* for option in bookoptions *)((option)), - (* endfor *) - (* for instrument in instruments *)((instrument)), - (* endfor *)]{crepbook} +\usepackage[ + ((booktype)), + (* for option in bookoptions *) + ((option)), + (* endfor *) + (* for instrument in instruments *) + ((instrument)), + (* endfor *) + ]{crepbook} (* endblock *) (* block songbookpreambule *) - \usepackage[ +\usepackage[ a4paper % paper size ,includeheadfoot % include header and footer into text size ,hmarginratio=1:1 % ratio between inner and outer margin (default) @@ -84,35 +87,37 @@ ,bmargin=1.3cm % bottom margin ]{geometry} - (( super() )) +(( super() )) - \pagestyle{empty} +\pagestyle{empty} - \definecolor{SongNumberBgColor}{HTML}{((songnumberbgcolor))} - \definecolor{NoteBgColor}{HTML}{((notebgcolor))} - \definecolor{IndexBgColor}{HTML}{((indexbgcolor))} +\definecolor{SongNumberBgColor}{HTML}{((songnumberbgcolor))} +\definecolor{NoteBgColor}{HTML}{((notebgcolor))} +\definecolor{IndexBgColor}{HTML}{((indexbgcolor))} - \renewcommand{\snumbgcolor}{SongNumberBgColor} - \renewcommand{\notebgcolor}{NoteBgColor} - \renewcommand{\idxbgcolor}{IndexBgColor} +\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} +\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{((subtitle))} - (* if version!="undefined" *) - \version{((version))} - (* endif *) - \mail{((mail))} - \web{((web))} - \picture{((picture))} - \picturecopyright{((picturecopyright))} - \footer{((footer))} +\subtitle{((subtitle))} +(* if version!="undefined" -*) + \version{((version))} +(* endif *) +\mail{((mail))} +\web{((web))} +\picture{((picture))} +\picturecopyright{((picturecopyright))} +\footer{((footer))} (* endblock *) diff --git a/patacrep/data/templates/songs.tex b/patacrep/data/templates/songs.tex index 802c216d..1ef8ea7a 100644 --- a/patacrep/data/templates/songs.tex +++ b/patacrep/data/templates/songs.tex @@ -1,22 +1,22 @@ -%! Copyright (C) 2014 The Patacrep 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/ +%!- Copyright (C) 2014 The Patacrep 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 *) { @@ -63,48 +63,51 @@ "default": {"default": {}} } } -(* endvariables *) +(* endvariables -*) -(* extends "layout.tex" *) +(*- extends "layout.tex" -*) (* block songbookpackages *) -\usepackage[((booktype)), - (* for option in bookoptions *)((option)), - (* endfor *) - (* for instrument in instruments *)((instrument)), - (* endfor *)]{patacrep} +\usepackage[ + ((booktype)), + (* for option in bookoptions *)((option)), + (* endfor *) + (* for instrument in instruments *)((instrument)), + (* endfor *) + ]{patacrep} (* endblock *) (* block songbookpreambule *) - (( super() )) +(( super() )) - (* for lang in _languages *) - \PassOptionsToPackage{((lang))}{babel} - (* endfor *) - \usepackage[((lang))]{babel} - \lang{((lang))} +(* for lang in _languages -*) + \PassOptionsToPackage{((lang))}{babel} +(* endfor *) +\usepackage[((lang))]{babel} +\lang{((lang))} - \usepackage{graphicx} - \graphicspath{(* for dir in datadir *) - {(( path2posix(dir) ))/img/} % - (* endfor *) - } +\usepackage{graphicx} +\graphicspath{ % + (* for dir in datadir *) + {(( path2posix(dir) ))/img/} % + (* endfor *) +} - \makeatletter - \@ifpackageloaded{hyperref}{}{ - \usepackage{url} - \newcommand{\phantomsection}{} - \newcommand{\hyperlink}[2]{#2} - \newcommand{\href}[2]{\expandafter\url\expandafter{#1}} - } - \makeatother +\makeatletter +\@ifpackageloaded{hyperref}{}{ + \usepackage{url} + \newcommand{\phantomsection}{} + \newcommand{\hyperlink}[2]{#2} + \newcommand{\href}[2]{\expandafter\url\expandafter{#1}} +} +\makeatother (* endblock *) (* block songs *) - \phantomsection - \addcontentsline{toc}{section}{\songlistname} +\phantomsection +\addcontentsline{toc}{section}{\songlistname} - ((render_content(content) )) +((render_content(content) )) (* endblock *) diff --git a/patacrep/songs/chordpro/data/latex/chordpro.tex b/patacrep/songs/chordpro/data/latex/chordpro.tex index 1f21adb1..dec5f3f5 100644 --- a/patacrep/songs/chordpro/data/latex/chordpro.tex +++ b/patacrep/songs/chordpro/data/latex/chordpro.tex @@ -1,26 +1,27 @@ + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ((path)) -(* if language is defined *) -\selectlanguage{((language))} +(* if language is defined -*) + \selectlanguage{((language))} (* endif *) \songcolumns{((metadata.columns))} \beginsong{((titles))}[ by={((authors))}, (* for (key, argument) in beginsong *) - ((key))={((argument))}, + ((key))={((argument))}, (* endfor *) - ] +] - (* if (metadata.cov is defined) or (metadata.vcov is defined) *) - \cover - (* endif *) +(* if (metadata.cov is defined) or (metadata.vcov is defined) *) +\cover +(* endif -*) - (* for item in content *) - (( render(item) )) - (* endfor *) +(* for item in content -*) + (( render(item) )) +(* endfor *) \endsong %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/patacrep/songs/chordpro/data/latex/content_line.tex b/patacrep/songs/chordpro/data/latex/content_line.tex index bdad1100..03ca80b7 100644 --- a/patacrep/songs/chordpro/data/latex/content_line.tex +++ b/patacrep/songs/chordpro/data/latex/content_line.tex @@ -1 +1,3 @@ -(* for item in content.line *)(( render(item) ))(* endfor *) +(* for item in content.line -*) + (( render(item) )) +(*- endfor *) diff --git a/patacrep/songs/chordpro/data/latex/content_verse.tex b/patacrep/songs/chordpro/data/latex/content_verse.tex index dc50f3f0..ac169e98 100644 --- a/patacrep/songs/chordpro/data/latex/content_verse.tex +++ b/patacrep/songs/chordpro/data/latex/content_verse.tex @@ -1,6 +1,5 @@ \begin{(( content.type ))} - (* for line in content.lines *) + (* for line in content.lines -*) (( render(line) )) (* endfor *) \end{(( content.type ))} - diff --git a/patacrep/templates.py b/patacrep/templates.py index 95c06469..69e5f10c 100644 --- a/patacrep/templates.py +++ b/patacrep/templates.py @@ -22,22 +22,22 @@ _LATEX_SUBS = ( _VARIABLE_REGEXP = re.compile( r""" - \(\*\ *variables\ *\*\) # Match (* variables *) - ( # Match and capture the following: - (?: # Start of non-capturing group, used to match a single character - (?! # only if it's impossible to match the following: - \(\*\ * # - a literal (* - (?: # Inner non-capturing group, used for the following alternation: - variables # - Either match the word variables - | # or - endvariables # - the word endvariables - ) # End of inner non-capturing group - \ *\*\) # - a literal *) - ) # End of negative lookahead assertion - . # Match any single character - )* # Repeat as often as possible - ) # End of capturing group 1 - \(\*\ *endvariables\ *\*\) # until (* endvariables *) is matched. + \(\*-?\ *variables\ *\*\) # Match (* variables *) or (*- variables *) + ( # Match and capture the following: + (?: # Start of non-capturing group, used to match a single character + (?! # only if it's impossible to match the following: + \(\*-?\ * # - a literal (* or (*- + (?: # Inner non-capturing group, used for the following alternation: + variables # - Either match the word variables + | # or + endvariables # - the word endvariables + ) # End of inner non-capturing group + \ *-?\*\) # - a literal *) or -*) + ) # End of negative lookahead assertion + . # Match any single character + )* # Repeat as often as possible + ) # End of capturing group 1 + \(\*\ *endvariables\ *-?\*\) # until (* endvariables *) or (* endvariables -*) is matched. """, re.VERBOSE|re.DOTALL)