Add html.sed to translate certain characters

The script, for now, translates the following characters to their html
entity:

    &, <, >

An important note that is in a comment is that the & MUST come first as
otherwise the & in the others will be corrupted.

One script uses this but in order to make sure it is okay make www will
have to be run first. Another script, the one that needs it even more,
has a problem that has to be discussed, before it can be used.
Nonetheless the html.sed file is at least added for the scripts once
things are tested okay.
This commit is contained in:
Cody Boone Ferguson committed 2024-11-04 06:59:51 -08:00
1 parent 5931934d8c
commit ad90b88317
1 file changed
+32
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env sed
#
# bin/html.sed - translate certain characters to HTML & entities
#
# This script was written in 2024 November by:
#
# @xexyl
# https://xexyl.net Cody Boone Ferguson
# https://ioccc.xexyl.net
#
# "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
# not complain.
#
# usage:
#
# cmd | sed -f bin/html.sed
#
# sed -f bin/html.sed file > output
#
# sed -i -f bin/html.sed file
#
# VERSION="1.0 2024-11-04"
# 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
# corrupt the '&'s in the string.
s/&/\&amp;/g
s/</\&lt;/g
s/>/\&gt;/g