A how-to generator for my blog
I started to take a screenshot of almost every step of my KiCad HowTo. It turned out I created 86 screenshots that needed to be referenced from the Markdown sources using a Jekyll include. The screenshots were already grouped into folders for subsections.
The Solution
// go through all directories
for i in $(ls -d */);
do
// print the directory as subsection
echo "## The ${i%/}";
// find all files that ar not "*.sm.*" files and sort naturally
for f in $(ls $i | grep -v ".sm" | sort -t - -k2 -g);
do
// print each file to be included via the howto-image snippet
echo "{% include howto-image.html src=\"/assets/kicad-howto/$i${f%.*}\" ext=\"${f##*.}\"";
echo " caption=\"Some Caption\" %}";
done
done
Which creates the following Markdown output:
## The 01-general
{% include howto-image.html src="/assets/kicad-howto/01-general/screen-1" ext="png"
caption="Some Caption" % }
{ % include howto-image.html src="/assets/kicad-howto/01-general/screen-2" ext="png"
caption="Some Caption" % }
{ % include howto-image.html src="/assets/kicad-howto/01-general/screen-3" ext="png"
caption="Some Caption" % }
[...]