2021-05-28 20:03:42 +02:00
|
|
|
#!/bin/bash
|
|
|
|
while [ -n "$1" ]; do # gestion des paramètres
|
|
|
|
case "$1" in
|
2021-06-18 15:53:50 +02:00
|
|
|
-h) echo "
|
2021-08-17 11:00:20 +02:00
|
|
|
Script qui transforme des fichiers markdown html.
|
2021-06-18 15:53:50 +02:00
|
|
|
"
|
|
|
|
exit 0;;
|
2021-05-28 20:03:42 +02:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2021-06-03 11:03:55 +02:00
|
|
|
set -e
|
2021-05-28 20:03:42 +02:00
|
|
|
IN_DIR="./input-cv-md"
|
|
|
|
OUT_DIR="./output"
|
|
|
|
STYLES_DIR="styles"
|
|
|
|
STYLE="aou"
|
|
|
|
|
2021-06-03 11:03:55 +02:00
|
|
|
# Si il n'y a pas de fichier markdown dans le dossier d'entrée, le script s'arrète
|
|
|
|
if [[ ! -d "$IN_DIR" ]] || [[ -z "$(ls -A $IN_DIR/*.md)" ]]; then
|
|
|
|
echo "Attention il n'y a aucun CV en markdown dans le dossier $IN_DIR"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-05-28 20:03:42 +02:00
|
|
|
|
|
|
|
for f in $IN_DIR/*.md; do
|
2021-06-03 11:03:55 +02:00
|
|
|
|
2021-05-28 20:03:42 +02:00
|
|
|
FILE_NAME=`basename $f | sed 's/.md//g'`;
|
2021-06-03 11:03:55 +02:00
|
|
|
mkdir -p $OUT_DIR/$FILE_NAME;
|
2021-05-28 20:03:42 +02:00
|
|
|
|
2021-08-17 11:00:20 +02:00
|
|
|
pandoc --standalone --css ../../$STYLES_DIR/$STYLE.css \
|
|
|
|
--from markdown --to html \
|
|
|
|
--output $OUT_DIR/$FILE_NAME/index.html $f \
|
|
|
|
--metadata pagetitle=$FILE_NAME;
|
2021-06-03 11:03:55 +02:00
|
|
|
|
2021-08-17 11:00:20 +02:00
|
|
|
echo "### Transfmormation du Markdown $IN_DIR/$FILE_NAME.md en HTML dans $OUT_DIR/$FILE_NAME/"
|
|
|
|
done
|