diff --git a/.travis.yml b/.travis.yml index 3aceab0a..c398bbfe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,14 +8,16 @@ install: script: - tox sudo: false -addons: - apt: - packages: - - texlive-latex-base - - latex-xcolor - - texlive-latex-extra - - pgf - - lmodern - - lilypond +# addons: +# apt: +# packages: +# - texlive-latex-base +# - latex-xcolor +# - texlive-latex-extra +# - texlive-luatex +# - texlive-xetex +# - pgf +# - lmodern +# - lilypond notifications: email: false diff --git a/patacrep/build.py b/patacrep/build.py index 40ef74ff..00be667e 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -136,10 +136,10 @@ class SongbookBuilder(object): # if False, do not expect anything from stdin. interactive = False - # if True, allow unsafe option, like adding the --shell-escape to pdflatex + # if True, allow unsafe option, like adding the --shell-escape to lualatex unsafe = False - # Options to add to pdflatex - _pdflatex_options = [] + # Options to add to lualatex + _lualatex_options = [] # Dictionary of functions that have been called by self._run_once(). Keys # are function; values are return values of functions. _called_functions = {} @@ -165,11 +165,11 @@ class SongbookBuilder(object): def _set_latex(self): """Set LaTeX options.""" if self.unsafe: - self._pdflatex_options.append("--shell-escape") + self._lualatex_options.append("--shell-escape") if not self.interactive: - self._pdflatex_options.append("-halt-on-error") + self._lualatex_options.append("-halt-on-error") for datadir in self.songbook.config["datadir"]: - self._pdflatex_options.append( + self._lualatex_options.append( '--include-directory="{}"'.format(datadir) ) @@ -180,7 +180,7 @@ class SongbookBuilder(object): - steps: list of steps to perform to compile songbook. Available steps are: - tex: build .tex file from templates; - - pdf: compile .tex using pdflatex; + - pdf: compile .tex using lualatex; - sbx: compile song and author indexes; - clean: remove temporary files, - any string beginning with a sharp sign (#): it is interpreted as a @@ -219,7 +219,7 @@ class SongbookBuilder(object): try: process = Popen( - ["pdflatex"] + self._pdflatex_options + [self.basename], + ["lualatex"] + self._lualatex_options + [self.basename], stdin=PIPE, stdout=PIPE, stderr=PIPE, diff --git a/patacrep/data/latex/patacrep.sty b/patacrep/data/latex/patacrep.sty index f3218005..d3735739 100644 --- a/patacrep/data/latex/patacrep.sty +++ b/patacrep/data/latex/patacrep.sty @@ -75,6 +75,11 @@ \pdfobjcompresslevel=0 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Unicode characters +\RequirePackage{fontspec} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Multilanguage management diff --git a/patacrep/data/templates/layout.tex b/patacrep/data/templates/layout.tex index ae23d681..099772a4 100644 --- a/patacrep/data/templates/layout.tex +++ b/patacrep/data/templates/layout.tex @@ -41,8 +41,6 @@ (* endblock *) (* block songbookpreambule *) -\usepackage[utf8]{inputenc} -\usepackage[T1]{fontenc} \usepackage{lmodern} (* endblock songbookpreambule *) diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control index bd9ac649..87ae4e77 100644 --- a/test/test_compilation/subdir.tex.control +++ b/test/test_compilation/subdir.tex.control @@ -29,8 +29,6 @@ pictures, guitar, ]{patacrep} -\usepackage[utf8]{inputenc} -\usepackage[T1]{fontenc} \usepackage{lmodern} diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 812ba0ac..a3a402d4 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -48,6 +48,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): def _create_test(cls, base): """Return a function testing that `base` compiles.""" + @unittest.skipIf('TRAVIS' in os.environ, + "Travis does not support lualatex compilation yet") def test_compile(self): """Test that `base` is correctly compiled.""" if base is None: diff --git a/test/test_compilation/unicode.sb b/test/test_compilation/unicode.sb new file mode 100644 index 00000000..fffed7cc --- /dev/null +++ b/test/test_compilation/unicode.sb @@ -0,0 +1,4 @@ +{ +"datadir": ["unicode_datadir"], +"lang": "en" +} diff --git a/test/test_compilation/unicode.tex.control b/test/test_compilation/unicode.tex.control new file mode 100644 index 00000000..9c8e946d --- /dev/null +++ b/test/test_compilation/unicode.tex.control @@ -0,0 +1,114 @@ + + + + + + +%% 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@/unicode_datadir/latex/} % + {@TEST_FOLDER@/latex/} % + {@DATA_FOLDER@/latex/} % +} +\makeatother + +\documentclass[ + ]{article} + +\usepackage[ + chorded, +diagram, +pictures, +guitar, + ]{patacrep} + +\usepackage{lmodern} + + +\PassOptionsToPackage{english}{babel} +\usepackage[english]{babel} +\lang{english} + +\usepackage{graphicx} +\graphicspath{ % + {@TEST_FOLDER@/unicode_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{Guitar songbook} +\author{The Patacrep Team} + +\newindex{titleidx}{unicode_title} +\newauthorindex{authidx}{unicode_auth} + + +\notenamesout{A}{B}{C}{D}{E}{F}{G} + + +\begin{document} + +\maketitle + + +\showindex{\songindexname}{titleidx} +\showindex{\authorindexname}{authidx} + +% list of chords +\ifchorded + \ifdiagram + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords + \fi +\fi + +\phantomsection +\addcontentsline{toc}{section}{\songlistname} + +\begin{songs}{titleidx,authidx} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./nonbreak.sgc + +\selectlanguage{english} + +\beginsong{Song with non breakable space}[ + by={ + Author with non breaking space chars }, +] + + + + +\begin{verse} + Non break +\end{verse} + +\endsong + +\end{songs} + + + + +\end{document} diff --git a/test/test_compilation/unicode_datadir/songs/nonbreak.sgc b/test/test_compilation/unicode_datadir/songs/nonbreak.sgc new file mode 100644 index 00000000..841d9acb --- /dev/null +++ b/test/test_compilation/unicode_datadir/songs/nonbreak.sgc @@ -0,0 +1,5 @@ +{title : Song with non breakable space} +{by: Author with non breaking space chars} +{lang: en} + +Non break diff --git a/tox.ini b/tox.ini index aa6c7c00..1b6a3337 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,7 @@ envlist = py34, lint [testenv] commands = {envpython} setup.py test +passenv = TRAVIS deps = [testenv:lint]