Fixed a bug where folder structure of 'source' is not preserved in 'output'

master
Aadhavan Srinivasan 10 months ago
parent e1cd7ce290
commit cc64d4482c

@ -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

Loading…
Cancel
Save