From cc64d4482c7dfc380a006de44f968d2ae6e5cb2e Mon Sep 17 00:00:00 2001 From: Rockingcool Date: Thu, 4 Jan 2024 22:40:32 -0600 Subject: [PATCH] Fixed a bug where folder structure of 'source' is not preserved in 'output' --- build.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 603da10..1456303 100755 --- a/build.sh +++ b/build.sh @@ -36,8 +36,8 @@ setup_temp_dir() { } setup_output_dir() { - rm -r output # Delete existing 'output' directory - cp -r source output #Copy directory structure from 'source' to 'output' + rm -r "${BASE_PATH}/output" # Delete existing 'output' directory + cp -r "${BASE_PATH}/source" "${BASE_PATH}/output" #Copy directory structure from 'source' to 'output' } del_files_in_output() { @@ -96,12 +96,17 @@ md_to_html() { let num_lines=$(echo $metadata | wc -l)+1 sed -i "1,${num_lines}d" $BASE_PATH/temp/`basename $file` - pandoc -f markdown $BASE_PATH/temp/`basename $file` > $BASE_PATH/output/`basename $file .md`.html +# Construct path for output file + path_for_output=$(realpath --relative-to="${BASE_PATH}/source" $file) + path_for_output="${BASE_PATH}/output/${path_for_output}" + path_for_output="$(dirname $path_for_output)/$(basename $path_for_output .md).html" + +# Convert the file, and place the output in the correct location + pandoc -f markdown $BASE_PATH/temp/`basename $file` > ${path_for_output} rm $BASE_PATH/temp/* - html_file="$BASE_PATH/output/`basename $file .md`.html" - add_header_and_footer $html_file - replace_vars $html_file #Uses 'meta_key' and 'meta_value' arrays + add_header_and_footer $path_for_output + replace_vars $path_for_output #Uses 'meta_key' and 'meta_value' arrays unset metadata meta_key meta_value done