Fix html.sed and related scripts

The file bin/html.sed has been fixed so that it works with
bin/md2html.sh (which has been modified and which is used via
bin/subst.entry-index.sh and output-index-inventory.sh). The script
output-index-inventory.sh was already updated to use html.sed so this
file has not been modified but the md2html.sh and subst.entry-index.sh
scripts have, along with bin/html.sed itself.

Tested make www which rebuilt several index.html files.

Updated bin/README.md as well as bin/index.html.

Testing that all the html files now are correct wrt Nu checker will have
to be done another time, however.
This commit is contained in:
Cody Boone Ferguson committed 2024-11-06 10:13:38 -08:00
1 parent fa34d80a82
commit 9787cc3a12
11 files changed
+123 -72

No files matched your search

+18 -45
View File
@@ -3,6 +3,18 @@
#
# md2html.sh - convert markdown into an IOCCC HTML file via config file
#
# This script was written in 2024 by:
#
# chongo (Landon Curt Noll, http://www.isthe.com/chongo/index.html) /\oo/\
#
# with important improvements by:
#
# @xexyl
# https://xexyl.net Cody Boone Ferguson
# https://ioccc.xexyl.net
#
# "Because sometimes even the IOCCC Judges need some help." :-)
#
# Convert a markdown file into a HTML file for the IOCCC website,
# using the bin/md2html.cfg configuration file. Conversion from
# markdown to HTML is performed via the 'pandoc wrapper tool'.
@@ -217,8 +229,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
-a . skip HTML phase number 22 (def: do nothing during HTML phase number 22)
-s token=value substitute %%token%% with value except in HTML phase numbers 20-29 (def: do not substitute any tokens)
NOTE: The 'token' string may not contain a ; (semicolon), a = (equal), or a % (percent).
NOTE: The 'value' string may not contain a ; (semicolon), nor & (ampersand).
NOTE: A later '-s token=value' will override an earlier '-s token=value' for the same 'token'.
NOTE: Multiple '-s token=value' are cumulative for the unique set of 'token's.
-S Failure to replace a %%token%% is not an error (def: exit non-zero for non-substituted tokens)
@@ -566,44 +576,7 @@ function parse_command_line
;;
esac
#
case "$NAME" in
*\;*)
echo "$0: ERROR: in -s token=value, the token may not contain a ; (semicolon) character: $NAME" 1>&2
echo 1>&2
echo "$USAGE" 1>&2
exit 3
;;
*=*)
echo "$0: ERROR: in -s token=value, the token may not contain an = (equal) character: $NAME" 1>&2
echo 1>&2
echo "$USAGE" 1>&2
exit 3
;;
*%*)
echo "$0: ERROR: in -s token=value, the token may not contain a % (percent) character: $NAME" 1>&2
echo 1>&2
echo "$USAGE" 1>&2
exit 3
;;
*) ;;
esac
#
case "$VALUE" in
*\;*)
echo "$0: ERROR: in -s token=value, the value may not contain a ; (semicolon) character: $NAME" 1>&2
echo 1>&2
echo "$USAGE" 1>&2
exit 3
;;
*\&*)
echo "$0: ERROR: in -s token=value, the value may not contain an & (ampersand) character: $NAME" 1>&2
echo 1>&2
echo "$USAGE" 1>&2
exit 3
;;
*) ;;
esac
#
# set %%token%% value
#
TOKEN[$NAME]="$VALUE"
@@ -916,7 +889,7 @@ function append_html_phase
# parse args
#
if [[ $# -ne 6 ]]; then
echo "$0: ERROR: append_html_phase requires 2 args, found: $#" 1>&2
echo "$0: ERROR: append_html_phase requires 6 args, found: $#" 1>&2
# We have to return non-zero but we don't have the args to know STARTING_EXIT_CODE.
# We might as well use 7 since that is an HTML phase exit code
return 7
@@ -1600,7 +1573,7 @@ fi
#
if [[ $V_FLAG -ge 7 ]]; then
for n in "${!TOKEN[@]}"; do
echo "$0: debug[7]: -s token replacement: sed -e s;%%$n%%;${TOKEN[$n]};g" 1>&2
echo "$0: debug[7]: -s token replacement: sed -e s|%%$n%%|${TOKEN[$n]}|g" 1>&2
done
fi
@@ -1644,7 +1617,7 @@ if [[ -z $NOOP ]]; then
# load the sed script with sed commands from any "-s token=value"
#
for n in "${!TOKEN[@]}"; do
echo "s;%%$n%%;${TOKEN[$n]};g" >> "$TMP_SED_SCRIPT"
echo "s|%%$n%%|${TOKEN[$n]}|g" >> "$TMP_SED_SCRIPT"
done
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: temporary sed script starts below: $TMP_SED_SCRIPT" 1>&2
@@ -1655,7 +1628,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, temporary sed script is not formed: $TMP_SED_SCRIPT" 1>&2
echo "$0: debug[3]: the temporary sed script that would have been written starts below: $TMP_SED_SCRIPT" 1>&2
for n in "${!TOKEN[@]}"; do
echo "s;%%$n%%;${TOKEN[$n]};g" 1>&2
echo "s|%%$n%%|${TOKEN[$n]}|g" 1>&2
done
echo "$0: debug[3]: the temporary sed script that would have been written ends above: $TMP_SED_SCRIPT" 1>&2
fi
@@ -1799,7 +1772,7 @@ if [[ -z $NOOP ]]; then
sed -E -e 's/^```[[:space:]]<!---[^-][^-]*-->/```/' -f "$TMP_SED_SCRIPT" "$INPUT_MD" >> "$TMP_STRIPPED_MD"
status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: token substation and strip code block command language from $INPUT_MD into file:" \
echo "$0: ERROR: token substitution and strip code block command language from $INPUT_MD into file:" \
"$TMP_INPUT_MD failed, error code: $status" 1>&2
exit 25
fi