Skip to content

add support for lualatex as engine #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \

RUN npm install --global --unsafe-perm [email protected] [email protected] [email protected] [email protected] [email protected]

# Lazy: Just put both possible texlive paths into the path. Only one will get populated.
ENV PATH="${PATH}:/usr/local/texlive/bin/aarch64-linux:/usr/local/texlive/bin/x86_64-linux"
# Important: /usr/local/texlive/bin/ paths come before other paths. We want to use the texlive we
# built above, not any that happen to have come along with our base image.
ENV PATH="/usr/local/texlive/bin/aarch64-linux:/usr/local/texlive/bin/x86_64-linux:${PATH}"

# Packages that are needed despite not being used explicitly by the template:
# bigfoot, catchfile, fancyvrb, footmisc, hardwrap, lineno, ltablex, latexmk, needspace, pgf, zref
Expand Down Expand Up @@ -183,6 +184,10 @@ RUN tlmgr update --self && tlmgr install \
latexmk \
lineno \
ltablex \
lualatex-math \
luatex \
luatex85 \
luatexbase \
makecell \
mathtools \
mdframed \
Expand Down
18 changes: 15 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ versioned_filenames="no"
pr_number=""
pr_repo=""
DIFFBASE=""
PDF_ENGINE=xelatex

# Start up the dbus daemon (drawio will use it later)
dbus-daemon --system || echo "Failed to start dbus daemon"
Expand Down Expand Up @@ -57,10 +58,11 @@ print_usage() {
echo " --versioned_filenames: insert version information before the file extension for outputs"
echo " --pr_number=number: mark the document as a pull-request draft if using Git versioning."
echo " --pr_repo=url: provide the URL for the repository for pull-request drafts (has no effect if --pr_number is not passed)."
echo " --pdf_engine=(xelatex|lualatex): use the given latex engine (default xelatex)"
}


if ! options=$(getopt --longoptions=help,puppeteer,notmp,gitversion,gitstatus,nogitversion,table_rules,plain_quotes,noplain_quotes,versioned_filenames,pr_number:,pr_repo:,diff:,pdf:,latex:,pdflog:,docx:,html:,resourcedir: --options="" -- "$@"); then
if ! options=$(getopt --longoptions=help,puppeteer,notmp,gitversion,gitstatus,nogitversion,table_rules,plain_quotes,noplain_quotes,versioned_filenames,pr_number:,pr_repo:,diff:,pdf:,latex:,pdflog:,pdf_engine:,docx:,html:,resourcedir: --options="" -- "$@"); then
echo "Incorrect options provided"
print_usage
exit 1
Expand Down Expand Up @@ -114,6 +116,10 @@ while true; do
pdflog_output="${2}"
shift 2
;;
--pdf_engine)
PDF_ENGINE="${2}"
shift 2
;;
--pdf)
pdf_output="${2}"
shift 2
Expand Down Expand Up @@ -176,6 +182,12 @@ if [ -z "${pdf_output}${latex_output}${docx_output}${html_output}" ]; then
exit 1
fi

if [ "${PDF_ENGINE}" != "xelatex" -a "${PDF_ENGINE}" != "lualatex" ]; then
>&2 echo "Unsupported PDF engine '${PDF_ENGINE}', expected one of: xelatex, lualatex"
print_usage
exit 1
fi

# Set up the output directory, either tmp or build in pwd.
if [ "${is_tmp}" == "yes" ]; then
build_dir="/tmp/tcg.pandoc"
Expand Down Expand Up @@ -345,7 +357,7 @@ fi
echo "Starting Build with"
echo "file: ${input_file}"
echo "docx: ${docx_output:-none}"
echo "pdf: ${pdf_output:-none}"
echo "pdf: ${pdf_output:-none} (engine: ${PDF_ENGINE})"
echo "latex: ${latex_ouput:-none}"
echo "html: ${html_ouput:-none}"
echo "use tmp: ${is_tmp}"
Expand Down Expand Up @@ -554,7 +566,7 @@ if [ -n "${pdf_output}" -o -n "${latex_output}" ]; then
start=$(date +%s)
# Run twice to populate aux, lof, lot, toc, then update the page numbers due
# to the impact of populating the lof, lot, toc.
latexmk "${TEMP_TEX_FILE}" -pdflatex=xelatex -pdf -diagnostics > "${LATEX_LOG}"
latexmk "${TEMP_TEX_FILE}" -pdflatex="${PDF_ENGINE}" -pdf -diagnostics > "${LATEX_LOG}"
if [ $? -ne 0 ]; then
FAILED=true
echo "PDF output failed"
Expand Down
Loading