Top of this screen document.
The Design principles (3.3), described in the previous section, have been realized with a number of tools, that are all available as public domain or freeware software on the Internet. To convert WordPerfect documents (and Word), the very handy conversion program Wp2Html was used, that is not public domain, but costs only a few (English) pounds. This program was used to do the bulk of the primary conversion of the CCCEE document (which was in Word originally and converted via WP 5.1 DOS format).
A number of home brew scripts are used for various tasks. We provide partial listings for a number of them.
This C shell script renames '.htm' files to '.html':
#!/bin/csh # htm2html.csh: rename .htm file(s) to .html in current directory. echo '.htm -> .html' foreach f ( *.htm ) echo "/bin/mv -f ${f:r}.htm ${f:r}.html" /bin/mv -f ${f:r}.htm ${f:r}.html end
The next C shell script replaces a number of patterns in html files. An extension of this could e.g. uppercase tags. Perl [7] is the tool most suitable for this kind of thing. However, Perl is not a part of the standard set of system programs as provided by most Unix vendors.
#!/bin/csh # replhtml.csh: replace some patterns in all html file(s) in the # ------------ current directory and below (recurse). foreach f ( `find . -name '*.htm' -print` ) echo -n " ${f}" if ( ! -w ${f} ) then echo error: can not replace ${f} exit 1 endif cat < /dev/null > ${f}.$$ if ( ! -f ${f}.$$ ) then echo error: can not write ${f}.$$ exit 1 endif sed -e 's/http:\/\/internal.machine.name/http:\/\/www.rgd.nl/g' \ $f > ${f}.$$ /bin/mv -f ${f}.$$ $f echo '' end
This Bourne shell script converts an ascii file to HTML, taking care of special characters as ">". En passant a DOS ascii file is also converted. Warning: the ^M en ^Z in this script must be the real control characters!
#!/bin/sh # # ascii2html.sh: Bourne shell script. # Converts ascii file(s) to HTML. # ALERT!! Replaces the ascii file with the HTML file. # # Features: # 1. Converts the file to an IETF HTML 2.0 file. # 2. All ascii text is put in a <PRE> formatted block. # 3. The special characters '&', '<' and '>' are converted to # &', '<' and '>' respectively. # 4. Strip decimal 127 and higher from files by replacing it with a space; # this is not a bug, we're converting _ascii_, right ;-]. # 5. Replace carriage return and control-Z with nothing (effectively # converts a DOS file to Unix newline conventions). # # All this is done in a special order, so even Dos files turn out right # under Unix. Tested under Linux 2.0 only. # # Eric Maryniak, e.maryniak@rgd.nl # 1996-10-25 # # Other users than me should change "webmaster@rgd.nl" to an appropiate # e-mail address. Btw, a LINK makes weblint happy ;-) # Hi there ! echo 'Ascii to HTML converter - Eric Maryniak' # Internal checks. MV="/bin/mv" if [ ! -f /bin/mv ]; then echo 'Help, /bin/mv does not exist !' exit 1 fi # If no arguments given, quit. if [ $# -eq 0 ]; then echo 'Usage: ascii2html.sh file1 [ file2 ... ]' exit 1 fi # Verify existence of files. for f in $* ; do if [ ! -f $f ]; then echo Error: file \`$f\' does not exist. exit 1 fi if [ ! -w $f ]; then echo Error: file \`$f\' is not writable \(cannot convert it\). exit 1 fi done TEMPIE=ascii2html.sh.$$ for f in $* ; do echo -n "Processing \`$f' ..." cat <<EOHEAD1 > $TEMPIE <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML> <HEAD> <LINK REV=MADE HREF="mailto:webmaster@rgd.nl"> EOHEAD1 echo "<TITLE>$f: converted from ascii to html</TITLE>" >> $TEMPIE echo "<!-- On ISO 8601:1988 date/time: `date '+%Y-%m-%d %H:%M:%S'` -->" >> $TEMPIE echo "<!-- By ascii2html.sh, (c) Eric Maryniak, e.maryniak@rgd.nl -->" >> $TEMPIE echo "<!-- Conforms to weblint 1.017 and sgmls 1.1.91 -->" >> $TEMPIE cat <<EOHEAD2 >> $TEMPIE </HEAD> <BODY> <PRE> EOHEAD2 # En passant convert a DOS type file as well. # Note that the "^M" and "^Z" are control characters! # In vi you can insert control characters with ^V (in insert mode). # Also replace 8-bit characters with a space (_ascii_ to html!). sed -e 's/^M//' -e 's/^Z//' -e 's/&/&/g' $f | \ sed -e 's/</\</g' -e 's/>/\>/g' | \ tr '\177-\377' ' ' >> $TEMPIE cat <<EOBODY >> $TEMPIE </PRE> </BODY> </HTML> EOBODY if [ ! -f $TEMPIE ]; then echo Error: cannot write temporary file in current directory. exit 1 fi $MV $TEMPIE $f echo ' done' done echo All files done\! exit 0
Keyword search in this handbook