I have the following function but it is repetitive and not scalable if I have 5, 6, etc.
append_footnote(){
file=$1
if [ "$#" -ge 2 ];then
depth=$2
if [ $depth -eq 1 ];then
echo '<span style="float: footnote;"><a href="../index.html#toc">Go to TOC</a></span>' >> "$file"
elif [ $depth -eq 2 ];then
echo '<span style="float: footnote;"><a href="../../index.html#toc">Go to TOC</a></span>' >> "$file"
elif [ $depth -eq 3 ];then
echo '<span style="float: footnote;"><a href="../../../index.html#toc">Go to TOC</a></span>' >> "$file"
elif [ $depth -eq 4 ];then
echo '<span style="float: footnote;"><a href="../../../../index.html#toc">Go to TOC</a></span>' >> "$file"
fi
else
echo '<span style="float: footnote;"><a href="./index.html#toc">Go to TOC</a></span>' >> "$file"
fi
}
It just add ../
in front of index.html#toc
depending on $2
arg.
How can I make it better?