diff --git a/genlog.sh b/genlog.sh
index a3933b7..8ff7783 100755
--- a/genlog.sh
+++ b/genlog.sh
@@ -72,15 +72,18 @@ do
# converting .gmi files in .html
/usr/local/bin/gmnitohtml < "$gmi_file" > "$tempdir/body.html"
+ cp "$tempdir/body.html" "$tempdir/work-body.html"
+
# trick to support h4 titles
- lines=$(grep "
# .*<\/h3>" "$tempdir/body.html")
- while read -r line; do
- fixed_line=${line//# /} # replace '# ' by ''
- fixed_line=${fixed_line//<\/h3>/<\/h4>} # replace '
' by '
'
- # shellcheck disable=SC2001
- fixed_line=$(echo "$fixed_line" | sed "s#\\\g") # escape eventual '&'
- sed -i "s^${line}^${fixed_line}^" "$tempdir/body.html"
- done <<< "$lines"
+ while IFS= read -r line; do
+ if echo $ "$line" | grep -q "# .*<\/h3>"; then
+ fixed_line=${line//# /} # replace '# ' by ''
+ fixed_line=${fixed_line//<\/h3>/<\/h4>} # replace '
' by '
'
+ # shellcheck disable=SC2001
+ fixed_line=$(echo "$fixed_line" | sed "s#\\\g") # escape eventual '&'
+ sed -i "s^${line}^${fixed_line}^" "$tempdir/body.html"
+ fi
+ done < "$tempdir/work-body.html"
# retrieving of the path of the current .gmi file
file_path="$(dirname "$gmi_file")"