In our last episode,
<39dth2F5un24nU1@individual.net>,
the lovely and talented Frances Del Rio
broadcast on comp.infosystems.
www.authoring.html:
[color=blue]
> (what is a preprocessor?)[/color]
A preprocessor is a program which takes a source document
(usually some kind of text - remember html is a kind of text
document) using includes, variables, conditional statements, and
function calls and produces an output document suitable for a
particular purpose (in this case, an html document that can be
served as-is). Many preprocessors were developed to make it
easier to write computer programs - but can be used for many
kinds of text. Some have been developed especially for the
needs of html.
Here, for example, is the template for one of my pages:
#include header.chml
#include help.rbar
<DIV>%getimage(banner,&pagereg)</DIV>\
<br class="clearl">
#include index.lbar
#include help.body
#include footer.chml
Well, of course, you know what includes are, and you could do
most of this SSI. However, there is a function in the DIV
which will insert the markup for my banner image - and this
function will get the path right because in header.chml I
have set a variable to say which directory this document is
going to be in. The function will also look up the photo credit
for the banner image and write snips of markup that will be
included in the footer here and in my copyright page to ensure
the photo credit gets enter both places.
Here is a snip from help.rbar:
<li>%getlink(%<location>,links-tour,%'Links tour.')</li>
<li>%getlink(%<location>,works-tour,%'My works here.')</li>
<li>%getlink(%<location>,writerndx,%'Writers\' resources.')</li>
<li>%getlink(%<location>,coursestart,%'Online Writing Course.')</li>
These are functions calls which will produce links to various
of my other pages in various directories. Again these links
will always be right, because I have set the variable for the
location of this page back in header.chml.
here is what those line produce here:
<li><a href="links/links_index.html#tour" title=
"Links Navigation Page: Guided Tour" type="text/html" charset=
"ISO-8859-1" lang="en-us">Links tour.</a></li>
<li><a href="lars_works_here.html#tour" title=
"Lars Eighner's Works at This Site: Guided Tour" type="text/html"
charset="ISO-8859-1" lang="en-us">My works here.</a></li>
<li><a href="wrtrmain.html" title=
"Lars Eighner's Writers' Main Index" type="text/html" charset=
"ISO-8859-1" lang="en-us">Writers' resources.</a></li>
<li><a href="writing_course/index.html" title=
"Lars Eighner's Online Writing Course" type="text/html" charset=
"ISO-8859-1" lang="en-us">Online Writing Course.</a></li>
Perhaps you have seen the kind of menu in which when the current
page is a menu item, that item is grayed or omitted (so you
won't/can't select a link to the current page). This sort of
thing is very easily done with a preprocess. The source
document has a variable that says what page it is, so the
preprocessor function doesn't put A HREF around references to
that page. You can do that by hand, but that entails changing
the menu by hand on each page that is a menu item.
This is for a preprocessor called chpp. It is something of a
pain to work with - although, of course, way ahead of generating
the markup by hand. As I have said, there are may preprocessors
available. Almost every platform will have a preprocessor for
the C programming language. It isn't ideal, but you can use it
for html. I use chpp to generate my stylesheets, even though
chpp is supposedly especially meant for html. Many
wordprocessors and editors have some (possibly crude)
preprocessor functions (which are typically used for things like
form letters or other documents with a lot of boilerplate and a
few variables).
--
Lars Eighner
eighner@io.com http://www.io.com/~eighner/
Dynamic linking error: Your mistake is now everywhere.