AnalogueLife

Analogue witterings...

Full Code-block as it stands:

# Ask for file to convert, then publish post from Markdown to HTML using Pandoc. Also create snippet to inject to index.html
publish () {
MSG="Choose file to Publish, or 0 to exit: "
filefind;
awk '/tags:/{for(i=2; i<=NF; i++) print "<li>" $i "</li>"}' <$file >tmpl/tags.txt
pandoc -s $file -o "${file%.md}.html" --template="$DEFAULTFOLDER/tmpl/main.html"
sed -i "/<!-- TAGS -->/r tmpl/tags.txt" "${file%.md}.html"
pandoc -s $file -o "entry.html" --template="$DEFAULTFOLDER/tmpl/entry.html"
sed -i "/<!-- ENTRY -->/r entry.html" "$INDEXFILE"
mv drafts/*.html "${DEFAULTFOLDER}/posts/"
rm -f "$file"; rm -f "entry.html"; rm -f "tmpl/tags.txt";
echo "File converted and saved to ${DEFAULTFOLDER}/"
}
  • bash-scripting
© matthew@analoguelife | 2023-12-31 19:24