From 9787cc3a120b0212ab609b3ed4d4bb41e4c22877 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 6 Nov 2024 10:11:50 -0800 Subject: [PATCH 1/2] 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. --- 1986/bright/README.md | 1 + 1986/bright/index.html | 2 +- 1987/wall/index.html | 2 +- 1988/robison/index.html | 2 +- 1992/albert/index.html | 2 +- 2018/burton2/index.html | 4 +-- bin/README.md | 36 +++++++++++++++++++---- bin/html.sed | 10 +++++-- bin/index.html | 28 ++++++++++++++---- bin/md2html.sh | 63 ++++++++++++---------------------------- bin/subst.entry-index.sh | 45 ++++++++++++++++++++++++---- 11 files changed, 123 insertions(+), 72 deletions(-) diff --git a/1986/bright/README.md b/1986/bright/README.md index 608d53228..4f16c2b25 100644 --- a/1986/bright/README.md +++ b/1986/bright/README.md @@ -29,6 +29,7 @@ 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/1986/bright/index.html b/1986/bright/index.html index 3a57d90d9..de2611548 100644 --- a/1986/bright/index.html +++ b/1986/bright/index.html @@ -406,7 +406,7 @@

The International Obfuscated C Code Contest

1986/bright - Most useful obfuscation

-

hex dump with cpp compressed that uses lots of << for constants

+

hex dump with cpp compressed that uses lots of << for constants

diff --git a/1987/wall/index.html b/1987/wall/index.html index d152f5592..67ed60a26 100644 --- a/1987/wall/index.html +++ b/1987/wall/index.html @@ -406,7 +406,7 @@

The International Obfuscated C Code Contest

1987/wall - Most useful obfuscation

-

roman numeral -> decimal and vice versa conversion

+

roman numeral -> decimal and vice versa conversion

diff --git a/1988/robison/index.html b/1988/robison/index.html index 42f9ee988..e1c5f6b10 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/1992/albert/index.html b/1992/albert/index.html index c44e9d713..5cfa9a41e 100644 --- a/1992/albert/index.html +++ b/1992/albert/index.html @@ -406,7 +406,7 @@

The International Obfuscated C Code Contest

1992/albert - Most useful program

-

factors multi-precision numbers with factors < MAX_LONG

+

factors multi-precision numbers with factors < MAX_LONG

diff --git a/2018/burton2/index.html b/2018/burton2/index.html index f55bfed7b..d0241d28c 100644 --- a/2018/burton2/index.html +++ b/2018/burton2/index.html @@ -817,8 +817,8 @@ are not recognised when written as -rs in prose).

  • c++98 - reserved words for C++98 standard
  • c99 - reserved words for C99 standard
  • java8 - reserved words for Java v8
  • -
  • kandr2 - reserved words for K&R2 C
  • -
  • kandr - reserved words for K&R C
  • +
  • kandr2 - reserved words for K&amp;R2 C
  • +
  • kandr - reserved words for K&amp;R C
  • patch - author supplied patch to fix iocccsize.c source
  • results - results without -k
  • runtest.sh - test suite
  • diff --git a/bin/README.md b/bin/README.md index 1e2d35c0e..feb6dc90c 100644 --- a/bin/README.md +++ b/bin/README.md @@ -14,10 +14,12 @@ files and other content from the [IOCCC GitHub repo](https://github.com/ioccc-src/temp-test-ioccc). -## [bin/](index.html) tools +## [bin/](index.html) tools options + +With the exception of the `awk(1)` and `sed(1)` scripts, all the tools in this +directory support a number of options that can be used to get help, diagnose +problems, see progress etc. These options are described below. -All tools in this directory support a number of options that can be used to get -help, diagnose problems, see progress etc. These options are as follows: ### Get help / usage string of a tool @@ -35,9 +37,9 @@ from the root directory (of the repo/website), you would do: ### Set verbosity level of a tool -If you want verbosity, say for debugging purposes or to see what is -going on more, you should use the `-v level` option. For instance if you wish to -see what is going on with the +If you want verbosity, say for debugging purposes or to see what is going on +more (than the default), you should use the `-v level` option. For instance if +you wish to see what is going on with the [quick-readme2index.sh](index.html#quick-readme2index) tool, you might do: @@ -412,6 +414,28 @@ Usage: In this case the command will list all the files of the [2020/ferguson1](../2020/ferguson1/index.html) winning entry. +
    +### [html.sed](%%REPO_URL%%/bin/html.sed) +
    + +Translates certain characters in their corresponding HTML entities. For example +`<` is converted to `<` and `>` is converted to `>`. This is important to +satisfy html lints. + +This script is used in [md2html.sh](#md2html) via +[output-index-inventory.sh](#output-index-inventory) and +[subst.entry-index.sh](#subst-entry-index). + +Usage: + +``` + cmd | sed -f bin/html.sed + + sed -f bin/html.sed file > output + + sed -i -f bin/html.sed file +``` + 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