Skip to content

Commit 5368fe8

Browse files
committed
Ensure latexmk knows the resource path so it can find images.
This change also removes the '/extra_resources' hack, as it's no longer necessary.
1 parent d0c302c commit 5368fe8

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

build.sh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ print_usage() {
4242
echo "Usage:"
4343
echo "$(basename "${0}") [options] [input-file]"
4444
echo
45-
echo "If a volume is mapped to /extra_resources/{dir}, input files may reference its contents as extra/{dir}."
46-
echo
4745
echo "Arguments:"
4846
echo " This script takes a single markdown file input for rendering to docx/pdf/LaTeX."
4947
echo
@@ -272,10 +270,6 @@ mkdir -p "${BUILD_DIR}"
272270
# This will allow us to manipulate the Git state without side effects
273271
# to callers of docker_run.
274272
cp -r . "${BUILD_DIR}"
275-
if [[ -d /extra_resources ]]; then
276-
mkdir -p "${BUILD_DIR}/extra"
277-
cp -r /extra_resources/* "${BUILD_DIR}/extra"
278-
fi
279273
cd "${BUILD_DIR}"
280274

281275
readonly src_uidgid=$(stat -c "%u:%g" "${SOURCE_DIR}")
@@ -512,6 +506,8 @@ readonly LATEX_OUTPUT
512506
readonly PDFLOG_OUTPUT
513507
readonly DIFFPDFLOG_OUTPUT
514508

509+
readonly RESOURCE_PATH=".:/resources:${RESOURCE_DIR}"
510+
515511
echo "Starting Build with"
516512
echo "file: ${INPUT_FILE}"
517513
echo "docx: ${DOCX_OUTPUT:-none}"
@@ -521,7 +517,7 @@ echo "latex: ${latex_ouput:-none}"
521517
echo "diff latex: ${DIFFTEX_OUTPUT:-none} "
522518
echo "typst: ${TYPST_OUTPUT:-none}"
523519
echo "html: ${html_ouput:-none}"
524-
echo "resource dir: ${RESOURCE_DIR}"
520+
echo "resource path: ${RESOURCE_PATH}"
525521
echo "build dir: ${BUILD_DIR}"
526522
echo "browser: ${browser}"
527523
echo "use git version: ${DO_GITVERSION}"
@@ -803,7 +799,7 @@ do_latex() {
803799
--citeproc
804800
--lua-filter=tabularx.lua
805801
--lua-filter=divide-code-blocks.lua
806-
--resource-path=.:/resources:${RESOURCE_DIR}
802+
--resource-path=${RESOURCE_PATH}
807803
--data-dir=/resources
808804
--top-level-division=section
809805
--variable=block-headings
@@ -864,7 +860,7 @@ do_typst() {
864860
--lua-filter=parse-html.lua
865861
--filter=pandoc-crossref
866862
--citeproc
867-
--resource-path=.:/resources:${RESOURCE_DIR}
863+
--resource-path=${RESOURCE_PATH}
868864
--data-dir=/resources
869865
--top-level-division=section
870866
--variable=block-headings
@@ -915,7 +911,8 @@ do_pdf_from_latex() {
915911
if [[ "${ignore_errors}" = "true" ]]; then
916912
pdflatex="${pdflatex} -interaction=nonstopmode"
917913
fi
918-
latexmk "${input}" -pdflatex="${pdflatex}" -pdf -diagnostics -output-directory=.cache/ > "${logfile}"
914+
TEXINPUTS="${TEXINPUTS}:${RESOURCE_PATH}" \
915+
latexmk "${input}" -pdflatex="${pdflatex}" -pdf -diagnostics -output-directory=.cache/ > "${logfile}"
919916
if [ $? -ne 0 ]; then
920917
FAILED=true
921918
echo "PDF output failed"
@@ -993,7 +990,7 @@ do_docx() {
993990
--lua-filter=landscape-pages.lua
994991
--lua-filter=style-fenced-divs.lua
995992
--filter=pandoc-crossref
996-
--resource-path=.:/resources:${RESOURCE_DIR}
993+
--resource-path=${RESOURCE_PATH}
997994
--data-dir=/resources
998995
--from='${FROM}+raw_attribute'
999996
--metadata=subtitle:"'${subtitle}'"
@@ -1036,7 +1033,7 @@ do_html() {
10361033
--filter=pandoc-crossref
10371034
--lua-filter=divide-code-blocks.lua
10381035
--lua-filter=style-fenced-divs.lua
1039-
--resource-path=.:/resources:${RESOURCE_DIR}
1036+
--resource-path=${RESOURCE_PATH}
10401037
--data-dir=/resources
10411038
--top-level-division=section
10421039
--variable=block-headings

0 commit comments

Comments
 (0)