Last active
December 31, 2018 08:23
-
-
Save finelagusaz/10449910 to your computer and use it in GitHub Desktop.
カレントディレクトリ以下にあるMarkdown形式のファイルをPandocでHTMLに変換するためのシェルスクリプトです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Markdown形式のファイルパスを取得し配列に格納する | |
mdpath=($(find ./ -name "*.md")) | |
# カウンタ | |
cnt=0 | |
# 配列でループ | |
for mdfile in ${mdpath[@]}; do | |
# 拡張子をhtmlに変換する | |
htfile=$(echo $mdfile | sed -e "s|\.md|.html|") | |
# ファイルの更新日時を比較する | |
if [ $mdfile -nt $htfile ]; then | |
# mdが新しければPandocでHTML生成 | |
pandoc -i $mdfile -o $htfile | |
# 変換したファイル数をカウント | |
cnt=`expr $cnt+1` | |
fi | |
done | |
# 結果表示 | |
echo "markdown to html: " $cnt "files" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment