#!/bin/zsh
# dumb script to inject epub noteref label and download buttons....
# needs overhaul

ebookfile="Le Français par la Méthode Nature.epub"

# cd ../epub
# unzip -u "$ebookfile" -d ebook
# # rm "$ebookfile"

cd ..

sed -i 's/<sup class="footnote-reference"><a href="#\([^"]*\)"/<sup class="footnote-reference"><a epub:type="noteref" id="footnote_source_\1" href="#footnote_\1" class/g' html/*.html
sed -i 's/<sup class="footnote-definition-label">\([^<]*\)<\/sup>/<sup class="footnote-definition-label"><a href="#footnote_source_\1" id="footnote_\1">\1<\/a>/g' html/*.html
sed -i 's/<div class="right-buttons">/<div class="right-buttons"> <a href=".\/Le Français par la Méthode Nature.epub" title="télécharger epub" aria-label="télécharger epub"> <i id="download-button" class="fa fa-book"><\/i>epub <\/a>/g' html/*.html
sed -i 's/<div class="right-buttons">/<div class="right-buttons"> <a href=".\/Le Français par la Méthode Nature.mobi" title="télécharger mobi" aria-label="télécharger mobi"> <i id="download-button" class="fa fa-book"><\/i>mobi <\/a>/g' html/*.html
sed -i 's/<h1 class="menu-title">/<a href="https:\/\/0124816.xyz" title="0124816.xyz" aria-label="0124816.xyz"> <i id="download-button" class="fa fa-home"><\/i><\/a> <h1 class="menu-title">/g' html/*.html
