From da7595de538c8c641bcca2f9edfcb305f71b6f99 Mon Sep 17 00:00:00 2001 From: Remco Rakers Date: Mon, 22 Apr 2019 12:15:06 +0200 Subject: [PATCH] Add support for Docker --- .gitignore | 3 ++- README.md | 12 +++++------- output/.gitkeep | 0 songbook.sh | 20 ++++++++------------ songbook.tex | 16 +++++++--------- 5 files changed, 22 insertions(+), 29 deletions(-) create mode 100644 output/.gitkeep diff --git a/.gitignore b/.gitignore index 4c3d6fe..536c2ff 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,5 @@ *.mtc1 *.out *.synctex.gz -*.pdf \ No newline at end of file +*.pdf +output/* diff --git a/README.md b/README.md index bbcdf53..87fff57 100644 --- a/README.md +++ b/README.md @@ -6,17 +6,15 @@ This is a first rudimentary version, but sufficient for now. The PDF has an inde ## Prerequisites -- `xelatex` should be installed (see [XeTeX's Wikipedia page](https://en.wikipedia.org/wiki/XeTeX) for more info) -- Script needs read/write permission in the current folder -- Files in the target directory are stored as `.txt` files -- Tested and developed on OSX, but should be possible to make it work on other platforms without much effort. +- Docker +- Files in the tabs directory are stored as `.txt` files ## How to generate your PDF? -Run the following command from the directory containing this repo code: +Run the following command from the directory containing this repo code, where you replace `/path/to/your/tabs/directory` with the actual value of the path on your system: ```Shell -$ bash ./songbook.sh /path/to/tab/directory +$ docker run -w /src -v $(pwd):/src -v /path/to/your/tabs/directory:/tabs moss/xelatex bash /src/songbook.sh /tabs ``` -This will create a file named `songbook.pdf` containing all the `.txt` files from the provided directory. +This will create a file named `songbook.pdf` in the `./output` directory, containing all the `.txt` files from the provided directory with tabs. diff --git a/output/.gitkeep b/output/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/songbook.sh b/songbook.sh index 577d3d4..2da52f2 100644 --- a/songbook.sh +++ b/songbook.sh @@ -1,27 +1,23 @@ #!/bin/bash if [ "$1" == "" ]; then - echo "Please provide an path where your tab files are located." + echo "Please provide a path where your tab files are located." exit 4 fi -tabDir=${1%/} # remove last slash, if existing - -escapedDir="${tabDir//\//\/}" -expression="%s/TABDIR/$escapedDir/g" - # use a temp file, based on songbook.tex -cp ./songbook.tex ./songbook.temp.tex +cp ./songbook.tex ./output/songbook.temp.tex # replace TABDIR placeholder with actual value of the directory with tab files -ex -sc $expression -cx ./songbook.temp.tex +tabDir=${1%/} # remove last slash, if existing +sed -i "s|TABDIR|$tabDir|g" ./output/songbook.temp.tex # run twice: first run for the table of contenst, second one for complete PDF -xelatex -enable-write18 "./songbook.temp.tex" -xelatex -enable-write18 "./songbook.temp.tex" +xelatex -enable-write18 -output-directory=./output "./output/songbook.temp.tex" +xelatex -enable-write18 -output-directory=./output "./output/songbook.temp.tex" # rename generated songbook pdf -mv ./songbook.temp.pdf songbook.pdf +mv ./output/songbook.temp.pdf ./output/songbook.pdf # clean up temp files -rm ./*temp* +rm ./output/*temp* diff --git a/songbook.tex b/songbook.tex index 5de3636..a34844b 100644 --- a/songbook.tex +++ b/songbook.tex @@ -6,9 +6,8 @@ \usepackage{geometry} \geometry{ a4paper, - total={210mm,297mm}, - left=20mm, - right=20mm, + left=10mm, + right=10mm, top=20mm, bottom=20mm, } @@ -16,9 +15,8 @@ \usepackage{fancyhdr} \pagestyle{fancy} \fancyhf{} -\fancyhead[LE,RO]{\thepage} -\fancyhead[RE]{\textit{\leftmark}} -\fancyhead[LO]{\textit{\rightmark}} +\fancyhead[R]{\thepage} +\fancyhead[L]{\textit{\rightmark}} \usepackage{hyperref} \hypersetup{ @@ -34,7 +32,7 @@ \usepackage[titles]{tocloft} \setlength{\cftbeforesecskip}{-.1ex} -\immediate\write18{./generate.sh TABDIR > tabs.temp.tex} +\immediate\write18{./generate.sh TABDIR > ./output/tabs.temp.tex} \begin{document} @@ -43,8 +41,8 @@ \tableofcontents \clearpage -\input{tabs.temp.tex} +\input{./output/tabs.temp.tex} -\immediate\write18{rm ./tabs.temp.tex} +\immediate\write18{rm ./output/tabs.temp.tex} \end{document}