#!/bin/bash set -eu input=$1 parameters=$2 template=$3 output=$4 cp ${template} ${output} transform-li-current-a () { local old="
  • " local new="
  • " echo "s/${old}/${new}/" } transform-li-dropdown-current-a () { local old="
  • " local new="
  • " echo "s/${old}/${new}/" } transforms=() postprocess=true . ${parameters} sed -i s/'{TITLE}'/"${title}"/ ${output} link_stylesheets='' for s in "${stylesheets[@]}" do spath=$(realpath --relative-to $(dirname "${input}") stylesheets/"${s}".css) link_template='\n' link_stylesheets+=$(printf "${link_template}" "${spath}") done sed -i /'{STYLESHEETS}'/'c\'"${link_stylesheets}" ${output} for transform in "${transforms[@]}" do sed -i "${transform}" ${output} done sed -i -e /'{MAIN}'/"r ${input}" -e /'{MAIN}'/'c\' ${output} ${postprocess} ${output}