Skip to content
Snippets Groups Projects
create_html.sh 1001 B
Newer Older
#!/bin/bash
# processing command line arguments
# Define variables
MATHJAX_URL='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'

# Check commandline arguments
if [ $# -lt 1 ]
then
    PROJECT_BUILD=`pwd`"/build"
    PROJECT_TOPICS=`pwd`
    echo -e "No building directory was specified."
elif [ $# -lt 2 ] 
then
    PROJECT_BUILD="$1"
    PROJECT_TOPICS=$PROJECT_BUILD
    echo -e "No extra topics directory was specified."
else
    PROJECT_BUILD="$1"
    PROJECT_TOPICS="$2"
fi
mkdir -p $PROJECT_BUILD
echo -e "Building into directory $PROJECT_BUILD ..."
echo -e "Using .md-files from $PROJECT_TOPICS ..."

# specify URL to avoid use of local library
# see https://docs.mathjax.org/en/latest/web/start.html#ways-of-accessing-mathjax
# and https://www.jsdelivr.com/package/npm/mathjax

for f in $PROJECT_TOPICS/*.md
do
    filename=$(basename -- "$f")
    pandoc --mathjax=$MATHJAX_URL --standalone \
    -c $PROJECT_ROOT/css/pandoc.css $f -o  $PROJECT_BUILD/"${filename%.md}".html
done