diff --git a/render_file b/render_file index 1469ce6..76122dc 100755 --- a/render_file +++ b/render_file @@ -3,6 +3,9 @@ # arguments: # $1: markdown file to render +# Determine location of this script +script_dir=$(dirname "$0") + # Separate metadata and actual markdown in the .md file frontmatter=$(awk '/!startmeta/,/!endmeta/ {if ($0 != "!startmeta" && $0 != "!endmeta") print;}' "$1") docbody=$(awk '/!endmeta/ {p=1; next} p' "$1") @@ -13,17 +16,17 @@ date=$(echo "$frontmatter" | awk -F'=' '/date=/ {print $2}') if [ -f gentemplate/header ] then printf 'Generating page header...' >&2 - title="$title" date="$date" gentemplate/header + title="$title" date="$date" "$script_dir"/gentemplate/header fi if [ -f gentemplate/footer ] then printf 'Generating page footer...' >&2 - date="$date" gentemplate/footer + date="$date" "$script_dir"/gentemplate/footer fi if [ -f gentemplate/htmlhead ] then printf 'Generating page
...' >&2 - title="$title" gentemplate/htmlhead + title="$title" "$script_dir"/gentemplate/htmlhead fi # cmark doesn't create the , doctype declaration or indeed most of the document # structure for us, so we'll do it ourselves. @@ -33,12 +36,12 @@ printf '\n' printf '\n' printf '\n' # At this point, insert the -printf "%s\n" "$(cat template/htmlhead)" +printf "%s\n" "$(cat "$script_dir"/template/htmlhead)" printf '\n' printf '\n' printf '