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.
This commit is contained in:
Cody Boone Ferguson committed 2024-11-07 10:37:51 -08:00
1 parent 9787cc3a12
commit 6fa0f7b69a
6 files changed
+51 -15

No files matched your search

-1
View File
@@ -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.
+1 -1
View File
@@ -406,7 +406,7 @@
</a>
<h1>The International Obfuscated C Code Contest</h1>
<h2>1988/robison - Best abuse of C constructs</h2>
<h3>print e in any base using only -- &gt;= and while()</h3>
<h3>print e in any base using only -- &gt;&equals; and while()</h3>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
+1 -1
View File
@@ -406,7 +406,7 @@
</a>
<h1>The International Obfuscated C Code Contest</h1>
<h2>1990/theorem - Best of Show</h2>
<h3>numerically solves the equation y'=f(x y)</h3>
<h3>numerically solves the equation y'&equals;f(x y)</h3>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
+7 -4
View File
@@ -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 '&lt;', so that html lints do
# to their respective HTML entity, for instance '&lt;', 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 '&amp;' substitution MUST come first! This is because the
# other substitutions have '&'s in them and if the '&amp;' came after it would
@@ -34,3 +34,6 @@
s/&/\\\&amp;/g
s/</\\\&lt;/g
s/>/\\\&gt;/g
s/|/\\\&verbar;/g
s/=/\\\&equals;/g
s/%/\\\&percnt;/g
+41 -7
View File
@@ -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"
+1 -1
View File
@@ -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