refactor: move pdf builder into project dir

This commit is contained in:
relikd
2023-02-26 22:19:16 +01:00
parent 12b097e24f
commit d30a3449f3
22 changed files with 34 additions and 37 deletions

View File

@@ -1,7 +0,0 @@
/*.aux
/*.log
/*.out
/*.toc
/dyn-*.tex
/pdf-de.pdf
/pdf-en.pdf

View File

@@ -1,13 +0,0 @@
\documentclass[a4paper,12pt,twoside]{article}
\usepackage[ngerman]{babel}
\include{setup}
\include{dyn-builddir} % load \def\builddir{}
\def\tIngredients{Zutaten}
\def\tRecipe{Rezept}
\def\tPagePrefix{S.}
\begin{document}
\makefrontmatter
\include{dyn-recipes-de}
\end{document}

View File

@@ -1,13 +0,0 @@
\documentclass[letter,12pt,twoside]{article}
\usepackage[english]{babel}
\include{setup}
\include{dyn-builddir} % load \def\builddir{}
\def\tIngredients{Ingredients}
\def\tRecipe{recipe}
\def\tPagePrefix{p.}
\begin{document}
\makefrontmatter
\include{dyn-recipes-en}
\end{document}

1
src/_tex-to-pdf/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/out

View File

@@ -0,0 +1,28 @@
#!/bin/sh
cd "${0%/*}" || exit 1
rm -rf out
mkdir -p out
build_dir=$(lektor project-info --output-path)
echo "\\\\def\\\\buildDir{$build_dir}" > out/builddir.tex
find "$build_dir" -name "*.tex" | while read -r x; do
bname=$(basename "${x%.tex}") # remove extension and parent dir
shortname=${x#"$build_dir"}
for i in 1 2; do
echo lualatex "$shortname [$i/2]"
lualatex --halt-on-error --output-directory out "$x" > /dev/null || exit 13
cp -pv "out/$bname.pdf" "$(dirname "$x")" || exit 11
done
done
ec=$?
if [ $ec -eq 0 ]; then
# only delete if successful, on error keep logs
rm -rf out
else
tail -50 out/*.log
echo "Error."
exit $ec
fi

View File

@@ -18,7 +18,8 @@
%------------------------------------------- %-------------------------------------------
% Defines & Geometry % Defines & Geometry
%------------------------------------------- %-------------------------------------------
\graphicspath{{\builddir/en/}} \input{out/builddir} % \def\buildDir{LEKTOR_OUTPUT_PATH}
\graphicspath{{\buildDir/}}
\definecolor{red2}{HTML}{AA203A} \definecolor{red2}{HTML}{AA203A}
\definecolor{red3}{HTML}{EE6A84} \definecolor{red3}{HTML}{EE6A84}
@@ -157,7 +158,7 @@
\vspace*{.06\textheight} \vspace*{.06\textheight}
\includegraphics[width=54mm]{misc/logo.pdf}\par \includegraphics[width=54mm]{misc/logo.pdf}\par
\vspace*{.06\textheight} \vspace*{.06\textheight}
{\huge\sf recipe lekture} {\huge\sf\tTitle}
\vfill \vfill
\today \today
\end{titlepage} \end{titlepage}
@@ -186,8 +187,8 @@
\enlargethispage{5.75ex} \enlargethispage{5.75ex}
\let\thefootnote\relax\footnotetext{% \let\thefootnote\relax\footnotetext{%
\hspace{-.6em} Source: \ifx\relax#2\relax#1\else\href{#1}{#2}\fi% \hspace{-.6em} Source: \ifx\relax#2\relax#1\else\href{#1}{#2}\fi%
}%
}\fi% }\fi%
}
} }
\newcommand{\newrecipe}[2]{\clearpage\section{#2}\label{#1}} \newcommand{\newrecipe}[2]{\clearpage\section{#2}\label{#1}}