How to generate 150 HTML files easily
The posting of the transparencies for the one-day cosmology
meeting was done with over 150 HTML files containing well over
1000 links. Even with an HTML editor that reduces each link to
the click of a mouse, it would have been a lot of work to produce
these files manually.
While an effective solution to this problem may already
exist, my style is to write my own programs to do what I want
done. The program I wrote is reasonably flexible, so I am
including it here in case it can be of use to someone else. The
program is written in PowerBasic, which runs only under DOS.
The HTML is generated from a source code written in a
language that I will dub GML, which looks a lot like TeX. It
allows the definition of macros almost exactly like TeX, except
that the arguments must be delineated by curly brackets. It also
allows conditionals, using \newif as in TeX, or using numerical if
statements of the form
\ifnum{expression 1}{operator}{expression 2} true-text \else false-text \fi.
Here "expression 1" and "expression 2" can be numbers or macros
that expand to numbers, and the operator can be =, >, <, <>, <=,
or >=. The language also allows loops, defined by the form
\do{variable name}{start}{end}{step}{text of loop}.
I have used the anti-TeX convention that spaces following a macro
name are not ignored, but the primitive \igfs (ignore following
space) is defined to allow macros to be expanded without a
following space. The primitive \sbr creates a linebreak in the
HTML file.
To allow output to a number of files (in sequence), the
primitive \file{dos-name}{unix-name} is used to open a file
called dos-name (which can include a path). The unix-name is the
name that the file is intended to have when used on a unix
server, and it is used by the program to determine relative
addresses. For example, if the unix-name is
/www/oneday/odmt/odmt1.html, and the file /www/oneday/speaker.gif
is used as an inline image, the reference will automatically be
changed to ../speaker.gif.
I have not written a manual, but it might be useful to say
that the primitives defined so far include the following. Words
written in all caps are variables. More documentation can be
found in the comments in the program's source file.
- \file{DOS-NAME}{UNIX-NAME} [described above]
- \input FILENAME [inputs another dos file]
- \def\MACRO_NAME{TEXT} [defines \MACRO_NAME to be TEXT]
- \def\MACRO_NAME#1#2{TEXT(#1,#2)} [as in TeX, defines
\MACRO_NAME{ARG1}{ARG2} to be TEXT(ARG1,ARG2). There can be any
number of arguments.]
- \edef\MACRO_NAME{TEXT} [as in TeX, expands TEXT first and
then defines \MACRO_NAME to be the result. Arguments are
allowed.]
- \image{imagesrc={FILENAME} ETC} [Inline image. ETC refers
to other constructions of the form KEYWORD={VALUE}, where the
supported keywords are alt, border, align, vspace, hspace]
- \anchor{ETC} [Like \image, but creates an anchor to a link.
Supported keywords are name, file, imagesrc, alt, border, align,
text, vspace, hspace]
- \longdate [Current date, in format Saturday, May 28, 1994
5:01 pm]
- \# [#]
- \sbr [linebreak in HTML file]
- \igfs [ignore following spaces]
- \counter{ARG} [expands to numerical value of counter ARG.
ARG can be an integer from 0 to 255, or the name of a counter
created with \newcount.]
- \setcounter{ARG}{EXPRESSION}
- \advance_counter{ARG}{EXPRESSION}
- \newcount\COUNTER_NAME
- \do{\VARNAME}{FROM}{TO}{STEP}{TEXT}
- \iffalse
- \iftrue
- \else
- \fi
- \newif\IFNAME [As in TeX. For example, \newif\ifnuts allows
one to use \ifnuts TRUE-TEXT \else FALSE-TEXT \fi. The macros
\nutstrue and \nutsfalse set the value of \ifnuts to true or
false.]
- \ifnum{EXPRESSION_1}{REL}{EXPRESSION_2} [REL can be =, > , <
, >= (greater than or equal to), <= (less than or equal to), or
<> (not equal to).]
- \relname2{FILENAME_1}{FILENAME_2} [Access 1st name from file
of 2nd name. Both names are full paths: /xx/xxx.xx]
- \webname [The UNIX-NAME of the most recent \file statement]
- \dosname [The DOS-NAME of the most recent \file statement]
- \enter_file_descript{FILE}{TEXT} [Sorry, this one won't do
you much good. It implants TEXT as a description of FILE in
a file called descript.mss. My modified DOS system displays this
information as part of the directory listing.]
- \mid{TEXT}{START}{LENGTH} [Equivalent to Basic mid$()
function. It extracts characters from TEXT, starting with
character START (START=1 means the first character) and
continuing for LENGTH characters.]
- \to_upper{TEXT}
- \to_lower{TEXT}
The following files may be of interest. The system is still
under development, so use it at your own risk.
- ONEDAY.GML: The GML file used to
create the HTML files for the one day cosmology meeting.
- PLAIN1.GML: Standard GML input file,
version 1.
- GMLHTML.PB: The PowerBasic source
file for the program that creates HTML files from GML input.
- REDIR1.PB: A file of utility
subroutines used by GMLHTML.PB.
- FILES1.PB: Another file of utility
subroutines used by GMLHTML.PB.
- GMLHTML.EXE: An MSDOS executable
file for GMLHTML.PB.
Send comments or questions to Alan Guth, guth@ctp.mit.edu.
Last modified: Monday, November 8, 1999 11:19 am