Skip to content

Commit

Permalink
Add support for Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
remcorakers committed Apr 22, 2019
1 parent c62172a commit da7595d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
*.mtc1
*.out
*.synctex.gz
*.pdf
*.pdf
output/*
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Empty file added output/.gitkeep
Empty file.
20 changes: 8 additions & 12 deletions songbook.sh
Original file line number Diff line number Diff line change
@@ -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*
16 changes: 7 additions & 9 deletions songbook.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@
\usepackage{geometry}
\geometry{
a4paper,
total={210mm,297mm},
left=20mm,
right=20mm,
left=10mm,
right=10mm,
top=20mm,
bottom=20mm,
}

\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{
Expand All @@ -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}

Expand All @@ -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}

0 comments on commit da7595d

Please sign in to comment.