diff options
author | Tyler Davis <tyler@gluecode.net> | 2024-11-05 21:05:16 +0000 |
---|---|---|
committer | Tyler Davis <tyler@gluecode.net> | 2024-11-05 21:05:16 +0000 |
commit | 1b075024b628d55984c715191e70cb373da77fe9 (patch) | |
tree | 429df5651926f25f87cb345fc186f8292c3c2c35 /gen.sh | |
parent | bcf29367cbb22f067d8973fd90e5cb9da0c39380 (diff) | |
download | journal-1b075024b628d55984c715191e70cb373da77fe9.tar.gz journal-1b075024b628d55984c715191e70cb373da77fe9.zip |
Finalize gen.sh
Diffstat (limited to 'gen.sh')
-rwxr-xr-x | gen.sh | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -110,15 +110,26 @@ for m in $MDLIST; do dirpath=$(eval "echo $m | sed -e 's,${WORKDIR}/,,' -e 's,/.*.md$,,' ") filename=$(eval "echo $m | sed -e 's,${WORKDIR}/,,' -e 's,${dirpath}/,,' -e 's,\.md,,' ") if [ $verbose -gt 0 ]; then - echo "Processing: ${shortpath}, ${dirpath} ${filename}" + echo "Processing: ${shortpath}" fi + + OUTPATH="${OUTDIR}/${dirpath}/${filename}.html" + + # Output directly to file if $dirpath ends in ".md" for root-level files + case $dirpath in *.md) + OUTPATH="${OUTDIR}/${filename}.html" + ;; + + *) + # Make the outdir if not ending in ".md" if [ ! -d "${OUTDIR}/${dirpath}" ]; then mkdir ${OUTDIR}/${dirpath} ; fi + esac - echo $HEADER > "${OUTDIR}/${dirpath}/${filename}.html" - cmark --safe --validate-utf8 -t html --width 80 $m >> "${OUTDIR}/${dirpath}/${filename}.html" - echo $FOOTER >> "${OUTDIR}/${dirpath}/${filename}.html" + echo $HEADER > "${OUTPATH}" + cmark --safe --validate-utf8 -t html --width 80 $m >> "${OUTPATH}" + echo $FOOTER >> "${OUTPATH}" if [ $verbose -gt 0 ]; then - echo "Created: ${OUTDIR}/${dirpath}/${filename}.html" + echo "Created: ${OUTPATH}" fi done |