| This is the reference page for the HTML pre-processor GTML. It describes
all theGTMLfeatures and commands in detail. For more information about
gettingGTML, see  the mainGTMLpage. GTMLfeatures fall into four main areas, and we'll look at them
in this order:
 CommandsThe original syntax of GTMLwas stolen shamelessly from the C
language pre-processor, and has been adapted to suit Web site
management. It supports the following commands: Command syntaxThere are two ways of writing commands:
 The first method is simpler, and is the recommended way of writing GTML, if possible. However, if you're using an HTML authoring tool which complains
aboutGTMLcommands, you can use the second method to hide theGTMLcommands from the tool. #includeIf you have some common text which you want inserted in more than one Web
page, put it in a separate file - say, common.txt.
Then, at the place where you want the text in each file, put the following
line: 
#include "common.txt"
 GTMLreplaces this line with the entire contents of the filecommon.txt.
 The name of the file can be defined in a named constant, as described next.
 The directories in which the file may be looked for can be defined in a
special named constant.
 #defineThis is a simple way to create shorthand definitions - what we call
named constants, or macros - for your frequently-used
text. For some text which you use often - say, an e-mail address - include a
line like this: 
 
#define MY_EMAIL gihan@pobox.com
 This defines a named constant MY_EMAIL and its
value gihan@pobox.com. The value can be any text, 
including spaces and HTML markup (leading spaces and tabs are ignored), as
long as it's all on one line or it's all on
multiple consecutives lines with a trailing `\' at the end of each
lines, except the last. To use this named constant, whenever you want your e-mail address, 
specify it like this:
 
     <<MY_EMAIL>>
The double angle-brackets tell GTMLto substitute this with its
definition (You can
specify your own choice of delimiters
instead of the double-angle brackets). There are a few other things you should know about #define: 
  Named constants can be set from the command line
      when you run GTML.Nested definition valuesThe value of a named constant can itself contain other named constants, 
      like this:
 
#define MAILTO <a href="mailto:<<MY_EMAIL>>">
 GTMLwill happily do both substitutions.Note: Definitions are evaluated at time of use, not time of
      definition. This allows you to change the nested value to get a
      different result. To get definitions body evaluated at time of
      definition, you must use the
 #define!command.
Nested definition namesIf you want the name of a named constant to contain other named
      constants, use
 #define!instead of#define. For example, this sets the named constant
      A to fred:
#define BLAH  A
#define! <<BLAH>> fred
 (This doesn't achieve much here, but typically the second line is in
      a separate file, which is included by the file with the first line). 
  
  Added valuesIf you want to add something to the definition of a named constant, use
 #define+. For example, this sets the named constant
      A to foobar:
#define A foo
#define+ A bar
Undefined valuesIf a named constant is not defined before it's used, its value is a
      blank string.
Re-defining valuesIt's perfectly OK to have more than one
 #definefor the
      same named constant. You can use this to change the value of a named
      constant part-way through the processing.Pre-defined values
 GTMLcreates some named constants
      for you automatically, such as the file name and links to the previous
      and next files.Variables valuesSometimes the frequently-used text you want to shorthand may embed some
      variable pieces.
 GTMLallows you to specify what the pieces are which
      may vary, the same way the C language preprocessor does for macros with
      arguments. Parameters are enclosed in parenthesis and seperated by a 
      comma. For instance, this creates a shortand to make HTML links:
#define url(x,y) <a href="mailto:x">y</a>
 Now the use of
      
      <<url(<<MY_EMAIL>>,Gihan)>>
       will give: 
 
<a href="mailto:gigan@pobox.com">Gihan</a>
Added variables valuesIf you add a variable valued definition with
 #define+, then
      you add the parameter to the initial constant. For
      instance, this adds a third parameter to the url macro:
#define+ url(x) <a href="http://x">Perera</a>
 Now guess what the following line will give:
 
  <<url(<<MY_EMAIL>>,Gihan,www.pobox.com/~gihan)>>
 Yeah, you find:
 
  <a href="mailto:gigan@pobox.com">Gihan</a><a href="http://www.pobox.com/~gihan">Perera</a>
 If you want to use commas in your arguments you just have to
      quote the complete argument with single or double
      quotes.      
 #newdefineThis is identical to #define, except that the
definition applies only if the named constant has not been defined already. If
it has been defined, the old definition is unchanged.#newdefine!is identical to#define!with the same exception. #undefUse this to remove the definition of a named constant:
 
 If the named constant didn't exist previously, this does nothing.
 #if, #ifdef, #ifndef, #elsif, #elsifdef, #elsifndef, #else, #endifThese commands are used together for conditional output:
 
  #if <<FRED>> == fooProcess the following lines only if after substitution, the left and
      right values are equal. Here if value of named constant
      FRED is equal to foo.
#if foo != <<FRED>> Process the following lines only if after substitution, the left and
      right values are different. Here if value of named constant
      FRED is different from foo.
#ifdef FREDProcess the following lines only if the named constant FRED
      is defined.
#ifndef FREDProcess the following lines only if the named constant FRED
      is not defined.
#elsif <<FRED>> == fooIf previous lines were not processed, then process the following lines
      only if after substitution, the left and right values are equal.
#elsif <<FRED>> != fooIf previous lines were not processed, then process the following lines
      only if after substitution, the left and right values are different.
#elsifdef FREDIf previous lines were not processed, then process the following lines
      only if the named constant FRED is defined.
#elsifndef FREDIf previous lines were not processed, then process the following lines
      only if the named constant FRED is not defined.
#elseThe opposite effect of the most recent matching
 #if,#ifdef,#ifndef,#elsif,#elsifdefor#elsifndef.#endifEnd a block of conditional output. Every
 #if,#ifdefor#ifndefmust have a matching#endif Conditional blocks can be nested.
 #timestampThe special named constant TIMESTAMP evaluates to the current
date and time. But to use it, you must tell GTMLwhat format to use to print
the date/time. The format string is specified in the #timestampstatement
like this: 
 
#timestamp   $dd/$MM/$yy at $hh:$mm:$ss
 The value of <<TIMESTAMP>> will then be: 
8/06/96 at 11:45:03.
 As you can see, certain strings (like $dd) are replaced with
values. The full set of substitution strings is as follows (everything else is
left unchanged in the format string): 
 
  | $hh | Hour (00 to 23) |  | $mm | Minute (00 to 59) |  | $ss | Seconds (00 to 59) |  | $Day | Full weekday name (Sunday to Saturday) |  | $Ddd | Short weekday name (Sun to Sat) |  | $dd | Day of the month (1 to 31) |  | $ddth | Day of the month with ordinal extension (1st to 31th) |  | $MM | Month number (1 to 12) |  | $Month | Full month name (January to December) |  | $Mmm | Short month name (Jan to Dec) |  | $yyyy | Year (e.g. 1996) |  | $yy | Short year (e.g. 96) |  Monthnames are output in English by default; but they can be output in
other languages, according to the LANGUAGE special definition.
 #mtimestampThis is identical to timestamp, except that
the time used is not the current one, but the time the file was last modified. #literalThe command #literal ONtellsGTMLto stop interpreting lines
beginning with `#' asGTMLcommands, until the next#literal
OFFline. Defined constants are still substituted, and
entities are translated if desired. For example, this is useful for bracketing blocks of C code, which might
have lines beginning with `#'. #entitiesThe command #entities ONtellsGTMLto convert the
characters `<', `>' and `&' into HTML
entities so they aren't treated as part of HTML commands. Use#entities
OFFto turn off 
this conversion. This is useful for bracketing blocks of program code, which often contain
these characters.
 #definecharBasic HTML authorized characters may only be ASCII characters. Accentuated
characters are coded in HTML in a certain way. For instance the `é'
character is coded `é'. You may want to input `é'
in your source file, and have the right code used in your HTML file. This
character's translation may be defined with the#definecharcommand, like in this example: 
#definechar é é
 Sometimes you might want to input special characters that are not available 
on your keyboard, but do not want to input its HTML code (Think of the German
`ß' on an English keyboard). For instance if you want all occurrances 
of `ss' in your source file to be translated into `ß', you 
can use the#definecharcommand: 
#definechar ss ß
 #compressThe command #compress ONtellsGTMLto begin producing
compressed HTML code, i.e. stripping multiple spaces, removing newlines, HTML
comments, and all other stuff useless for an HTML browser to render a
page. This compression is done on the output file until the next#compress
OFF. #sitemap, #tocWhen you specify a  hierarchy of pages in your
project file you may insert a table of contents, or site map,
of those pages, using the command #sitemap, or#toc. See Document hierarchy specifications for more
information on how the list is created.
 GTMLproject files
Because GTMLis most useful for managing multiple files, it's quite
common to change something in a #include'd file, and then runGTMLon all
the `.gtm' files which use it. To make this procedure easier, GTMLsupports a concept of a project
file. This is a simple text file with the extension `.gtp'. It
can contain: 
  define ...As for
 #definein a source file.define! ...As for
 #define!in a source file.define+ ...As for
 #define+in a source file.newdefine ...As for
 #newdefinein a source file.newdefine! ...As for
 #newdefine!in a source file.undef ...As for
 #undefin a source file.timestamp ...As for
 #timestampin a source file.mtimestamp ...As for
 #mtimestampin a source file.if ...
 ifdef ...
 ifndef ...
 elsif ...
 elsifdef ...
 elsifndef ...
 else
 endifAs for
 
      #if, #ifdef, #ifndef, #elsif, #elsifdef, #elsifndef, #else, #endifin a source file.definechar ...As for #definechar in a source file.
compress ...As for #compress in a source file.
include ...As for #include in a source file, but only on project
      files.
// ...Comment lines (the `
 //' must be the first characters on the line), which
      are ignored. Blank lines are also ignored.allsourceThis is a shorthand way of specifying all source files from the current
      directory and sub-directories (recursively).
filename alias fileThis is used to make an alias to a file, so that you may use the alias, 
      as a defined constant, instead of the filename itself in source
      files.
 GTMLwill compute the right relative path to the file in each
      source file. This way you may move your files wherever you want,GTMLwill be able to recreate your pages without having to modify the source
      files.filename.gtmAll other lines are names of source files, which are processed by
 GTMLin turn.These files can be in other directories below the current
      directory. Simply specify the file name relative to the current
      directory (e.g. sub/fred/index.gtm).
       The file can be a defined alias filename. In this case use it as a
      filenamed constant, e.g.
 
   filename FOO bar/foo
   <<FOO>>
 The file name can be followed by a level number and a title, to be
      used in creating a hierarchy of documents. In
      this case the file is processed after the project file has been
      completely read (in order to have the complete document hirearchy).
  hierarchyThis is used to process all files of the declared hierarchy so far, so
      that you may process those files more than once, if you want to change 
      some named constant values between each process. If not used
      files of the hierarchy are processed after the project file has been
      entirely read.
 When you run GTMLwith the project file as a command-line argument, it
will process all the source files in the project file. They will all inherit
thedefine,definecharandtimestampvalues, if any, in the project file. Themtimestampvalue will  
change according to the modification date of the appropriate source file. You may use a project file, but process only selected source files
(declared in the project) with the
 `-F' command line argument. Note that #define,#newdefineand#undefcommands inside a file are local to that file - they don't
carry over to the next file in the project. However, named constants defined
in the project file are inherited by all files in the project. Document hierarchyGTMLallows you to create a hierarchy of Web pages, with links between
them. Each Web page can have a link to the previous page, the next page, or
one level up in the hierarchy. Obviously, some of these links don't apply to
some pages -GTMLgenerates only those that apply to each page.
 Describing the hierarchyYou describe the document hierarchy to GTMLby listing the file names in
the project file in a certain order, with a document level and title for
each. Level 1 is for top-level documents, and 2, 3, 4, and so on are lower
levels. File names without a level have no hierarchical information attached
to them. When GTMLprocesses a file, it defines special named constants which can
be used in exactly the same way as other named constants. For each file, GTMLgenerates the named constants, 
LINK_PREV, 
LINK_NEXT and
LINK_UP. These correspond to the file names of the previous file, 
next file and one level up in the hierarchy. In addition, it also generates
the corresponding named constants 
TITLE_PREV, 
TITLE_NEXT, 
TITLE_UP and
TITLE_CURRENT to be the titles of these files (As stated above, 
the title follows the level number in the project file). Some of these named constants may not be applicable to some files, in which
case the named constant is not defined for that file. 
 ExampleHere's an extract from a hypothetical GTMLproject file: 
    contents.gtm 1 Table of Contents
    chapter1.gtm 2 Introduction
    sec11.gtm    3 What's the Problem
    sec12.gtm    3 Old Approaches
    sec13.gtm    3 New Idea
    chapter2.gtm 2 Historical Evidence
    sec21.gtm    3 Early 1900's
    sec22.gtm    3 Recent Findings
    chapter3.gtm 2 Our Bright Idea
To take a simple case, the file sec21.gtmwill haveLINK_NEXTset tosec22.html(andTITLE_NEXTset to Recent Findings) and LINK_UP set tochapter2.html(and TITLE_UP set to Historical
Evidence). LINK_PREV and TITLE_PREV will be
undefined. Using the linksThe links can be used to create navigation links between the
documents. In other words, each document can have links up the
hierarchy and to the next and previous documents.
 Typically, you would place the navigation information in a common file and
#includeit into eachGTMLsource file. TheGTML#ifdefcommand can be used to exclude links which don't apply to
a particular file. Here's a simple example:
 
#ifdef LINK_NEXT
   <p>Next document: <a href="<<LINK_NEXT>>"><<TITLE_NEXT>></a>
#endif
#ifdef LINK_PREV
   <p>Previous document: <a href="<<LINK_PREV>>"><<TITLE_PREV>></a>;
#endif
#ifdef LINK_UP
   <p>Up one level: <a href="<<LINK_UP>>"><<TITLE_UP>></a>;
#endif
 Creation of table of contentsWhen you have described a document hierarchy, and you use a
 #tocor#sitemapcommand into your
source file,GTMLincludes a sitemap generated as a list with the help of the 
__TOC_#__(x), and __TOC_#_ITEM__(x,y) special named
constants (`#' being a file level). With the previous example it gives:
 
<<__TOC_1__('
  <<__TOC_1_ITEM__('contents.html','Table of Contents')>>
  <<__TOC_2__('
    <<__TOC_2_ITEM__('chapter1.html','Introduction')>>
    <<__TOC_3__('
      <<__TOC_3_ITEM__('sec11.html','What's the Problem')>>
      <<__TOC_3_ITEM__('sec12.html','Old Approaches')>>
      <<__TOC_3_ITEM__('sec13.html','New Idea')>>
    ')>>
    <<__TOC_2_ITEM__('chapter2.html','Historical Evidence')>>
    <<__TOC_3__('
      <<__TOC_3_ITEM__('sec21.html','Early 1900's')>>
      <<__TOC_3_ITEM__('sec22.html','Recent Findings')>>
    ')>>
  ')>>
')>>
__TOC_#__(x), and __TOC_#_ITEM__(x,y) have
the following default values:
 
#define __TOC_#__(x)        <ul>x</ul>
#define __TOC_#_ITEM__(x,y) <li><a href="x">y</a>
 You may redefine this constant to whatever you want as long as you respect
the number of variables.
    
 Special definitionsEnvironmentAll environment variables are defined as named constants by GTML. Current file namesThe special named constants ROOT_PATH, BASENAME, 
FILENAME and PATHNAME are set to the current 
path to root of the project (where the project file resides), output file name
without any extension and excluding any directory path information, output
file name excluding any directory path information, and directory path
information relative to the path to the root of the project. 
 Search path for include filesGTMLalways searches for include files in the directory of the processed
source file first, then the current directory (where theGTMLcommand is
executed).
 In addition, if you define the named constant INCLUDE_PATH, 
GTMLwill interpret it as a list of directories (separated by colons), to
search for include files. Those directories may be absolute, or relative to
the root path of the project. Output directoryBy default, GTMLwrites its output files to the same directory as the
corresponding source file. You can override this by defining the named
constant OUTPUT_DIR as the name of the output directory. If you are doing this with a project file, specify OUTPUT_DIR
as the top-level output directory. GTMLwill create the same directory
hierarchy for the output files as for the input files (It creates
sub-directories as required). Output suffixBy default all created files are created by changing the .gtm, or
.gtml extension of the source file to the .html one.
 You may change this behavior by defining the special constant
EXTENSION to whatever extension you want.
 The definition of this constant does not have sense in a source file, since
the output file is already created the moment GTML starts to parse the source 
file. It makes sense however to define it in the 
project file or on the command line. 
 If the suffix is preceded by two dots as in gtml.css..gtm, then the
source suffix is not replaced, but just removed, as ingtml.css. Fast generationGTMLonly processes files which are younger than the output files which 
they might produce. 
This is very useful, as it increases the generation speed of web
sites with a big number of pages, when only one of them has been changed. Same
kind of the waymakeworks.
 To enable this feature you just have to define the special constant
FAST_GENERATION. The use of this constant will work only in
GTMLproject files or on the command line. This feature does not take into account included files, but only the main
gtml source, and the wanted output. To deal with more complex file
dependencies you may use the maketool in conjunction with the
`-F' and
`-M' command line arguments. Language localisationBy default all timestamps produce monthnames and daynames which are output 
in English. You can output them in other languages by defining the constant 
LANGUAGE to a value corresponding to an available language.
 As of today seven languages are available. The default one is
English. Following is the list of those language with the corresponding value
for LANGUAGE constant:
 
  frfor French ;defor German ;iefor Irish ;itfor Italian ;nlfor Dutch ;nofor Norvegian ;sefor Swedish. If you can send me month and day names in other languages, just do it, I
will integrate it in following versions of GTML. Substitution delimitersThe default delimiters for substituting named constants are
`<<' and `>>'. You can change these to any
other strings by defining the named constants OPEN_DELIMITER and
CLOSE_DELIMITER respectively. For example, if you had the following lines:
 
#define OPEN_DELIMITER {{
#define CLOSE_DELIMTER }}
#define MY_EMAIL  gihan@pobox.com
then GTML substitutes MY_EMAIL when it finds the text
{{MY_EMAIL}} instead of the default
<<MY_EMAIL>>. 
 Document hierarchy linksAs described above, GTMLdefines several named constants for links between documents. Embedded Perl codeYou may embed Perl code into your GTMLsource file, and have the result
of the last evaluated expression inserted in your output file, with the help of
the one argument macro __PERL__. Here is an example inserting the size of the source file:
 
<<__PERL__(return (stat(<<ROOT_PATH>><<BASENAME>>.".gtm"))[7];)>>
 Embedded system command codeYou may embed system command output into your GTMLsource file, with the help of
the one argument macro__SYSTEM__. Here is an example inserting the list of files in the current directory:
 
<<__SYSTEM__(dir)>>
 Command-line arguments-DWhen you run GTMLfrom the command line, you can define named constants 
like this: -DMY_EMAIL=fred
 This is the same as #define MY_EMAIL fred in the file.
 These definitions can occur anywhere within the command-line options, 
but only affect the files after them. For example, if your
command line is:
 
perl gtml.pl fred.gtm -DMY_EMAIL=fred bill.gtm harry.gtm
 then the MY_EMAIL definition doesn't apply to
fred.gtm. -FWhen you run GTMLfrom the command line on a project file you may want
to process only some of the files used in it. This may be very useful in
conjunction withmakefor page regeneration based on complex
files dependencies (induced by#includecommands). To process only one file of a project you can use the `-F'
argument followed by the name of the file to process. File to be processed
must appear, on the command line, before the project file it appears in. Let us suppose we have this project file, called foo.gtp: 
// Beginning of foo.gtp
define MAIL beaufils@lifl.fr
foo.gtm
bar.gtm
// End of foo.gtp
 If you just want to regenerate the bar.htmlfile your command
line will be: 
perl gtml -Fbar.gtm foo.gtp
 List of files to processed is cleared after each project file treatment.
 -MWhen you run GTMLwith the `-M' command line argument,GTMLprocess project and source files, but do not produce ouput files.GTMLgenerates a makefile ready to create output files. If you do not specify a filename, the generated makefile is created under
the GNUmakefilename. To specify a filename, just add it after the `-M' argument, with a
colon between the option and the file name. -h, --helpTo get a small command line usage description you can use the
`-h', or `--help' command line argument. --silentIf you specify the `--silent' command line argument,GTMLwill
produce no processing information during its work. --versionTo get the version number of the GTMLyou are currently using you can
use the `--version' command line argument. |