From 6fa0f7b69a988758313cfd3594447fd2239eda86 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:37:51 -0800 Subject: [PATCH] Additional fixes to the html.sed script It now translates the characters '|' (pipe), '=' (equals) and '%' (percent). Checks were added in md2html.sh in the -s token=value so that token cannot contain an = (equal), | (pipe) or a % (percent) and the value cannot contain a | (pipe). The reason that we cannot disallow a ';' or '&' is because the html entities use those characters so if the sed script were to translate the problematic characters it would cause a problem in the script. Ran make www which updated 1988/robison/index.html and 1990/theorem/index.html. 1986/bright/README.md was fixed with the number of blank lines between sections. --- 1986/bright/README.md | 1 - 1988/robison/index.html | 2 +- 1990/theorem/index.html | 2 +- bin/html.sed | 11 +++++---- bin/md2html.sh | 48 ++++++++++++++++++++++++++++++++++------ bin/subst.entry-index.sh | 2 +- 6 files changed, 51 insertions(+), 15 deletions(-) diff --git a/1986/bright/README.md b/1986/bright/README.md index 4f16c2b25..608d53228 100644 --- a/1986/bright/README.md +++ b/1986/bright/README.md @@ -29,7 +29,6 @@ program. This gives you a small example of what it is like to maintain the Bourne shell! :-} - ## Author's remarks: No remarks were provided by the author. diff --git a/1988/robison/index.html b/1988/robison/index.html index e1c5f6b10..8ec05b952 100644 --- a/1988/robison/index.html +++ b/1988/robison/index.html @@ -406,7 +406,7 @@

The International Obfuscated C Code Contest

1988/robison - Best abuse of C constructs

-

print e in any base using only -- >= and while()

+

print e in any base using only -- >= and while()

diff --git a/1990/theorem/index.html b/1990/theorem/index.html index aeaaed803..57ec28743 100644 --- a/1990/theorem/index.html +++ b/1990/theorem/index.html @@ -406,7 +406,7 @@

The International Obfuscated C Code Contest

1990/theorem - Best of Show

-

numerically solves the equation y'=f(x y)

+

numerically solves the equation y'=f(x y)

diff --git a/bin/html.sed b/bin/html.sed index b6caaa991..f54c80bde 100644 --- a/bin/html.sed +++ b/bin/html.sed @@ -1,6 +1,6 @@ #!/usr/bin/env sed # -# bin/html.sed - translate certain characters to HTML & entities +# html.sed - translate certain characters to HTML & entities # # This script was written in 2024 November by: # @@ -11,10 +11,10 @@ # "Because sometimes even the IOCCC Judges need some help." :-) # # This script will take certain characters, for instance '<', and convert them -# to their respective html entity, for instance '<', so that html lints do +# to their respective HTML entity, for instance '<', so that HTML lints do # not complain. # -# For a list of the other html entities, should others be needed, see: +# For a list of the other HTML entities, should others be needed, see: # # https://www.w3schools.com/html/html_entities.asp # @@ -26,7 +26,7 @@ # # sed -i -f bin/html.sed file # -# VERSION="1.0 2024-11-04" +# VERSION="1.1 2024-11-07" # IMPORTANT NOTE: the '&' substitution MUST come first! This is because the # other substitutions have '&'s in them and if the '&' came after it would @@ -34,3 +34,6 @@ s/&/\\\&/g s//\\\>/g +s/|/\\\|/g +s/=/\\\=/g +s/%/\\\%/g diff --git a/bin/md2html.sh b/bin/md2html.sh index d849f2042..02ec16d8d 100755 --- a/bin/md2html.sh +++ b/bin/md2html.sh @@ -7,7 +7,7 @@ # # chongo (Landon Curt Noll, http://www.isthe.com/chongo/index.html) /\oo/\ # -# with important improvements by: +# with useful improvements by: # # @xexyl # https://xexyl.net Cody Boone Ferguson @@ -158,7 +158,7 @@ shopt -s lastpipe # run last command of a pipeline not executed in the backgroun # set variables referenced in the usage message # -export VERSION="1.7 2024-09-27" +export VERSION="1.8 2024-11-07" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -228,9 +228,12 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N] -a tool run 'after tool' during HTML phase number 20 (def: do not output after pandoc wrapper tool) -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: 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 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 an = (equal), | (pipe) or a % (percent) symbol. + NOTE: The 'value' string may not contain a | (pipe) symbol + 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) -o tool use 'output tool' to generate option lines (def: do not) @@ -564,7 +567,7 @@ function parse_command_line fi ;; s) # parse: -s token=value - case "$OPTARG" in + case "$OPTARG" in *=*) # parse name=value NAME=${OPTARG%%=*} VALUE=${OPTARG#*=} @@ -576,7 +579,38 @@ function parse_command_line ;; esac # - + case "$NAME" in + *=*) + 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 | (pipe) 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 | (pipe) character: $NAME" 1>&2 + echo 1>&2 + echo "$USAGE" 1>&2 + exit 3 + ;; + *) ;; + esac + # # set %%token%% value # TOKEN[$NAME]="$VALUE" diff --git a/bin/subst.entry-index.sh b/bin/subst.entry-index.sh index 9322b98ef..9b5e8d32c 100755 --- a/bin/subst.entry-index.sh +++ b/bin/subst.entry-index.sh @@ -6,7 +6,7 @@ # # chongo (Landon Curt Noll, http://www.isthe.com/chongo/index.html) /\oo/\ # -# with important improvements by: +# with useful improvements by: # # @xexyl # https://xexyl.net Cody Boone Ferguson