Browse Source

cleanup publish script

master
Jonathan Cobb 3 years ago
parent
commit
043d4645c8
1 changed files with 8 additions and 8 deletions
  1. +8
    -8
      legal/publish_html.sh

+ 8
- 8
legal/publish_html.sh View File

@@ -1,27 +1,27 @@
#!/bin/bash

if [[ -z $(which markdown) ]] ; then
if [[ -z $(which markdown) ]]; then
echo "Installing markdown-to-html from npm..."
sudo npm install markdown-to-html -g
fi

THISDIR=$(cd $(dirname $0) && pwd)
cd ${THISDIR}
for f in $(find . -type f -name "*.md" ) ; do
THISDIR="$(cd "$(dirname "${0}")" && pwd)"
cd "${THISDIR}" || exit 1
find . -type f -name "*.md" | while read -r f; do

# Files we'll use
doc="$(echo $(basename ${f}) | sed -e 's/.md//')"
doc="$(echo "$(basename "${f}")" | sed -e 's/.md//')"
TMP="./html/${doc}.tmp"
HTML="./html/${doc}.html"

# Convert to HTML
echo "Converting ${f} to HTML"
markdown $f > ${TMP}
markdown "${f}" > "${TMP}"

# Change links to .md to .html
echo "Rewriting markdown links to HTML and creating ${HTML}"
cat header.html ${TMP} footer.html | sed -e 's/.md"/.html"/' > ${HTML}
cat header.html "${TMP}" footer.html | sed -e 's/.md"/.html"/' > "${HTML}"

# Cleanup
rm -f ${TMP}
rm -f "${TMP}"
done

Loading…
Cancel
Save