Skip to content

Instantly share code, notes, and snippets.

@jnduli
Created July 26, 2021 09:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnduli/0d07305c79c542282d105c48e31d004c to your computer and use it in GitHub Desktop.
Save jnduli/0d07305c79c542282d105c48e31d004c to your computer and use it in GitHub Desktop.
#!/bin/bash
gen_html () {
mkdir -p test_compile
file_name=$1
name="${1%.*}"
ext="${1##*.}"
echo "[${name}](./${name}.html)" >> index.md
echo "" >> index.md
pandoc -f markdown -t html --mathjax --metadata title="questions" -s -o ./test_compile/${name}.html $file_name
}
export -f gen_html
rm index.md
touch index.md
echo "%Index of Questions" >> index.md
find . -maxdepth 1 -type f -name "*.md" -printf "%f\n" | sort | xargs -I % bash -c 'gen_html "$@"' _ %
pandoc -f markdown -t html --mathjax -s -o ./test_compile/index.html index.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment