gtml-3.5.4/0000744000175000001440000000000010140456071013122 5ustar andrexusers00000000000000gtml-3.5.4/src/0000755000175000001440000000000010140452771013716 5ustar andrexusers00000000000000gtml-3.5.4/src/tags0000644000175000001440000000227410140450747014605 0ustar andrexusers00000000000000// $Id: tags,v 1.1 1999/09/02 02:54:22 beaufils Exp $ // // Redefinition of my own *HTML* tag. // definechar é é definechar ß ß definechar © definechar <>   // I use those nasty tricks to cheat my emacs html-helper-mode, and // font-lock-mode. // If some good elisp guy wants to write a GTML mode for emacs, let me know, // and I will integrate it into the GTML distribution, and stop doing those // *unpretty* things ;-) definechar

[[h2]] definechar

[[/h2]] definechar

[[h3]] definechar

[[/h3]] definechar

[[h4]] definechar

[[/h4]] definechar [[ext]] definechar [[/ext]] definechar [[car]] definechar [[/car]] definechar [[file]] definechar [[/file]] definechar [[cmd]] definechar [[/cmd]] definechar )]] definechar [[url( definechar )]] definechar [[surl( definechar )]] definechar [[mail( definechar )]] // End of tags gtml-3.5.4/src/CREDITS.gtm0000644000175000001440000000464206767031632015543 0ustar andrexusers00000000000000#define TITLE GTML Credits #include "header"

I would like to thank some people who helped, and contributed in the development of _gtml_.

First of all I'd like to thank Gihan Perera, who is the initial author of _gtml_, and who did a really great job, and who authorized me to take over _gtml_ since it seems he does not have time to enhance it, and a more important thing, authorized me to distribute it under the GPL terms. He is the guy to thanks, the real author of _gtml_.

Then I would like to thank people who helped me correct, or enhance _gtml_:

I hope I forgot nobody.

Do not hesitate to correct me if needed, and to send bug reports, or documentation mistakes (from typo errors, to bad English construction) reports. #include "footer" gtml-3.5.4/src/sitemap.gtm0000644000175000001440000000010606763357036016104 0ustar andrexusers00000000000000#define TITLE GTML sitemap #include "header" #toc #include "footer" gtml-3.5.4/src/NEWS.gtm0000644000175000001440000001046110140452124015175 0ustar andrexusers00000000000000#define TITLE GTML Revision history #include "header" [[ul]] [[vl]]1.0 [[dl]]8-Jun-1996 [[r1]]First release. [[/vl]] [[vl]]1.01 [[dl]]14-Jun-1996 [[r1]]Added #newdefine. [[ri]]Allow undefined constants. [[/vl]] [[vl]]1.02 [[dl]]14-Jul-1996 [[r1]]Support path names in project file. [[/vl]] [[vl]]1.03 [[dl]]1-Sep-1996 [[r1]]No quotation marks in #include file name is OK. [[ri]]Allow ../ to higher levels than starting directory. [[/vl]] [[vl]]2.0 [[dl]]24-Nov-1996 [[r1]]Added lots of new features. [[/vl]] [[vl]]2.01 [[dl]]30-Nov-1996 [[r1]]Commands can be inside comments. [[ri]]User-specified substitute delimiters. [[/vl]] [[vl]]2.02 [[dl]]10-Feb-1997 [[r1]]Fixed #ifdef nesting. (Alan B. Chamberlin) [[/vl]] [[vl]]2.1 [[dl]]23-Jul-1997 [[r1]]Allow subs in #include. [[ri]]Don't downshift file names. (Suggestions from Mike Sendall). [[/vl]] [[vl]]2.2 [[dl]]15-Aug-1997 [[r1]]"allsource" command in project file. [[/vl]] [[vl]]2.21 [[dl]]2-Feb-1998 [[r1]]Simplified auto-generated navigation links. [[/vl]] [[vl]]2.22 [[dl]]25-Jul-1998 [[r1]]Handles years past 2000. [[/vl]] [[vl]]2.3 [[dl]]19-Feb-1999 [[r1]] Enhanced #define (Wim Niemans Ri). [[/vl]] [[vl]]3.0 [[dl]]22-Jun-1999 [[r1]]Added mtimestamp. [[ri]]Added usage of "LANGUAGE". [[ri]]Added usage of "EXTENSION". [[ri]]Added filename alias definitions. [[ri]]Fixed a bug with links and subdir. [[ri]]Fixed a bug with entities. [[/vl]] [[vl]]3.1 [[dl]]1-Jul-1999 [[r1]]Added definitions of all environment variables. [[ri]]Added substitution at definition time for OUTPUT_DIR, INCLUDE_PATH and EXTENSION. [[/vl]] [[vl]]3.2 [[dl]]4-Jul-1999 [[r1]]Added usage of "FAST_GENERATION" to process only files which sources are newer than output. [[/vl]] [[vl]]3.3 [[dl]]7-Jul-1999 [[r1]]Fixed a bug with directory creation, thanks to Magog. [[ri]]Added undefined constants in project file, a PhM request. [[ri]]Added the -F command line argument, to process only single file, enabling the use of make (On a suggestion from PhM). [[ri]]Added the GNU -h, --help and --version command line arguments. [[/vl]] [[vl]]3.31 [[dl]]7-Jul-1999 [[r1]]Added Norwegian language support. [[/vl]] [[vl]]3.32 [[dl]]8-Jul-1999 [[r1]]Fixed a bug with filename aliases. [[ri]]Added Italian and Swedish support. [[/vl]] [[vl]]3.33 [[dl]]9-Jul-1999 [[r1]]Fixed a serious bug with filename aliases (thank's to Jens). [[/vl]] [[vl]]3.34 [[dl]]10-Jul-1999 [[r1]]Added Dutch support. [[/vl]] [[vl]]3.3.5 [[dl]]13-Jul-1999 [[r1]]Fixed another bug with filename aliases. [[/vl]] [[vl]]3.3.6 [[dl]]14-Jul-1999 [[r1]]Added German support. [[/vl]] [[vl]]3.5.0 [[dl]]2-Sep-1999 [[r1]]Fixed a lot of bugs, while rewritting the code. [[ri]]Added makefile generation. [[ri]]Enhanced timestamp support. [[ri]]Added customizable sitemap generation. [[ri]]Modified ouput file extension setting. [[ri]]Added characters translation. [[ri]]Added embedded Perl code possibility. [[ri]]Added embedded shell command output possibility. [[ri]]Documented output compression. [[ri]]Updated documentation. [[ri]]Added some new predefined constants. [[ri]]Added macro with arguments. [[ri]]Enhanced conditionals. [[ri]]Enhanced inclusion in project files. [[ri]]Enhanced timestamps support. [[/vl]] [[vl]]3.5.1 [[dl]]2-Sep-1999 [[r1]]Fixed a bug with PATHNAME creation, and thus included file searching. [[/vl]] [[vl]]3.5.2 [[dl]]8-Sep-1999 [[r1]]Fixed a bug with conditional output (if/elsif). [[ri]]Added irish support. [[ri]]Remove include file name report. [[ri]]All documentations has been corrected thanks to Ken Guest. [[/vl]] [[vl]]3.5.3 [[dl]]13-Sep-1999 [[r1]]Fixed a bug with compression. [[ri]]Better $ddth (english) computation. [[ri]]Exit status changed (0 for warnings and OK, 1 for errors). [[/vl]] [[vl]]3.5.4 [[dl]]29-Oct-2004 [[r1]]Fixed several 'if'-related bugs:

[[ri]]Macros in INCLUDE_PATH are now resolved. [[/vl]] [[/ul]] #include "footer" gtml-3.5.4/src/commands0000644000175000001440000000202610140452766015446 0ustar andrexusers00000000000000// $Id: commands,v 1.1 1999/09/02 02:17:01 beaufils Exp $ // // Definition of some macros used in GTML documentation. // define h2

define /h2

define h3

define /h3

define h4

define /h4

define ext define /ext define car ` define /car ' define file define /file define cmd define /cmd define label(arg) define url(url,text) text define surl(url) url define mail(add) add define ul

define vl define /ul
define dl   define r1
  • define ri
  • define /vl
// End of commands. gtml-3.5.4/src/footer0000644000175000001440000000274110140450133015131 0ustar andrexusers00000000000000 #ifndef TEXT_ONLY

This page has been accessed times since . #ifdef LINK_PREV [[LINK_PREV]],<< [[TITLE_PREV]] #endif   [[SITEMAP]],Sitemap   #ifdef LINK_NEXT [[LINK_NEXT]],[[TITLE_NEXT]] >> #endif
#endif

#ifndef TEXT_ONLY _www_,GTML home page
#endif [[MTIMESTAMP]]
Copyright 1996-1999 http://www.pobox.com/~gihan,Gihan Perera  (gihan@pobox.com)
Copyright 1999 http://www.lifl.fr/~beaufils,Bruno Beaufils  (beaufils@lifl.fr)
Copyright 2004 http://home.comcast.net/~andrex,Andrew E. Schulman  (schulman@users.sourceforge.net)
gtml-3.5.4/src/header0000644000175000001440000000354510140450747015101 0ustar andrexusers00000000000000 [[TITLE]] #ifndef TEXT_ONLY #ifdef LINK_NEXT #endif #ifdef LINK_PREV #endif #endif
#ifndef TEXT_ONLY #endif #ifndef TEXT_ONLY #endif
#ifdef LINK_PREV << #endif   [[TITLE]]   #ifdef LINK_NEXT >> #endif
gtml-3.5.4/src/gtml.css..gtm0000644000175000001440000000127306763357036016260 0ustar andrexusers00000000000000/* $Id: gtml.css..gtm,v 1.1 1999/09/02 02:17:01 beaufils Exp $ */ /* Style for GTML documentation. */ /* I do not use them as far as I want until Netscape is so bugged. Nobody will be able to render the pages properly. :-((( */ BODY { background : #ffffff; color : #000033; } A:link, A:visited { font-weight : bold; color : #990000; text-decoration : none; } H2 { font-family : sans-serif; background : #ffffcc; color : #000066; width : 100%; padding : 5; border : thin; font-size : large; } H3 { font-family : sans-serif; color : #000066; } H4 { font-family : sans-serif; color : #000066; } /* Local Variables: */ /* mode: html-helper-mode */ /* End: */ gtml-3.5.4/src/gtml.gtm0000644000175000001440000002705606767035334015420 0ustar andrexusers00000000000000#define TITLE GTML - an HTML pre-processor #include "header"

  • #intro,Introduction
  • #how,How does _gtml_ work ?
  • #you,Is _gtml_ for you ?
  • #features,_gtml_ features.
  • #download,Downloading _gtml_
  • #running,Running _gtml_
  • #other,Other HTML pre-processors
  • #license,Terms of license
  • #history,A little bit of _gtml_ history


HTML is a powerful markup language for individual Web pages, but it has some serious limitations for maintaining entire Web sites (i.e. a collection of Web pages which needs to be kept consistent).

_gtml_ is an HTML pre-processor which adds some extra features specially designed for maintaining multiple Web pages.

How does it work?

You embed _gtml_ commands among the HTML in your source files. _gtml_ reads and processes the _gtml_ commands, but leaves the rest of the text unchanged (so it will work straight away on your existing Web pages).

HTML files generated by _gtml_ are just like any other HTML files. Because _gtml_ doesn't attempt to interpret your HTML commands in any way, it's fully compatible with all versions of HTML, and doesn't require any specific browser or server.

Is _gtml_ for you?

If you write the HTML in your Web pages by hand using a simple text editor, then you'll find _gtml_ useful. If, on the other hand, you use a sophisticated graphical tool to generate your HTML, you probably won't be able to use _gtml_. There are three reasons for this:

  • Your sophisticated tool won't understand the _gtml_ commands, and might even complain violently about them.
  • _gtml_ operates in a command-line batch mode, and your sophisticated tool probably operates from a graphical environment.
  • The source for _gtml_ is in files ending in .gtm (or .gtml), and it generates the .html files. Your sophisticated tool probably generates the .html files itself.

Features

Here are some of the things you can do with _gtml_:

  • Create a project file with the names of all your Web pages, so you can update them all with one simple click or command.
  • Process only files which sources have changed directly, or with the help of makefiles.
  • Generate a makefile to control the process of your Web pages, based on their dependencies. _new_
  • Give a specific alias to a filename, useable as constants, so that it is easy to move files and have links preserved.
  • Specify a tree-like hierarchy of Web pages, so you can add Next, Previous and Up links automatically to your site.
  • Automatically generate a map of your site, with the possibility of customizing the way this table of contents will look like. _new_
  • Use named constants for HTML fragments to save typing, ensure consistency and make changes easily.
  • Use environment variables as named constants.
  • Include header, footer and other common files into all your HTML files. This doesn't require Server-Side Includes.
  • Include timestamps (in any format you like) to show the time of last process, or of last modification.
  • Use conditional commands to create different versions of the output under different circumstances.
  • Generate output to different directories to generate different versions of your site (for example, a Frames version and a non-Frames version).
  • Change extensions of output files from .html to whatever you want, so that you may, for instance, use MultiViews options of Apache server, or create non-HTML files. _new_
  • Guard special characters `<', `>' and `&' in normal text so that they don't get confused with HTML commands.
  • Define your own characters translations, so that you may easily input your non-ASCII characters into _gtml_ source. _new_
  • Embed Perl or shell code into your source, so that you may easily generate pages with computed information. _new_
  • Generate pages with all superfluous HTML code removed, so that readers retrieve them faster and may save bandwidth. _new_

All the _gtml_ features and commands are described on the [[REF]],_gtml_ Reference page.

Downloading _gtml_

_gtml_ is written in Perl. If you don't have Perl, it's easy to http://www.perl.com/pace/pub/perldocs/latest.html,obtain it on http://www.perl.com,perl.com.

There are two methods to download _gtml_:

  • gtml,Download _gtml_ Perl script, and save it to a file called gtml.pl. If you're running this under UNIX, edit the first line to point to the location of your version of Perl, and give the execute right to the file.
  • Download _gtml_ archives containing Perl script as well as documentations. Archives are available in _ftp_gtml.zip,zip format or _ftp_gtml.tar.gz,gzipped tar format.

The home page of _gtml_ is at _www_, and archives may be found at _ftp_.

Running _gtml_

_gtml_ source files end in .gtm (or .gtml), not .html. If you're using _gtml_ on existing HTML files, simply rename them with the ending .gtm (or .gtml).

_gtml_ is run from the command line, like this:

     perl gtml.pl fred.gtm harry.gtm bill.gtm

(The UNIX version won't need the Perl at the front, so long as the script is executable.)

The output of this command will be in fred.html, harry.html and bill.html.

If you have a [[REF]]#project,_gtml_ project file, you include this on the command line. In this case, it's not necessary to list any of the files in the project as well.

Remember that you [[REF]]#optiond,can use -D on the command line to create named constants. You can have as many -D options as you like. Make sure they appear before the file names to which they apply. For example, if you say:

     perl gtml.pl -DNAME=Fred fred.gtm harry.gtm -DTYPE=car bill.gtm
then NAME is defined for all three files and TYPE is defined for bill.gtm only.

By default, _gtml_ will try to process some [[REF]]#project,project file. It will look at these configuration files in this order:

  • $HOME/.gtmlrc
  • $HOME/gtml.conf
  • .gtmlrc
  • gtml.conf

Thoses files, if they exist, are parsed before command line is processed.

You may have a look at the source of the documentation pages of _gtml_ in the src,source directory. The project file is called src/gtml.gtp,gtml.gtp.

Other HTML pre-processors

Here is a list of other HTML pre-processors that I know of, in case _gtml_ will not satisfy your needs:

  • http://chakotay.ist.org,Chpp
  • http://frontier.userland.com,Frontier
  • http://www.metahtml.com,Meta-HTML
  • http://www.php.net,PHP
  • http://www.qml.org/,QML
  • http://artho.com/webtools,Webtools
  • http://www.engelschall.com/sw/wml/,WML
  • http://www.geocities.com/Tokyo/1474/wpp,Wpp

Licensing

_gtml_ is distributed under the COPYING,GNU General Public License (GPL).

Copyright 1996-1999 http://www.pobox.com/~gihan,Gihan Perera (gihan@pobox.com)

Copyright 1999 http://www.lifl.fr/~beaufils,Bruno Beaufils (beaufils@lifl.fr)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the http://www.gnu.org/copyleft/gpl.html,GNU General Public License for more details.

Some history

For a long time I was looking for a way of maintaining some of the sites that I set up for the research team which I am member of. I wanted to get a tool which would enable me to easily change the look and feel of all pages of a site, and easily move pages of a site from one location to another.

I then used all my favourite search engines on the web, and found some pages, describing such tools. I tried some. They all missed something, from ease of use, to important features. When I tried _gtml_, from Gihan, I found it was pretty cool, but lacking some important features that I needed.

I wrote to Gihan asking him to add those features which I needed, since I had no Perl programming skill. He told me that he doesn't have time to do that in the near future. So I decided to read his code, and to learn Perl with his script.

The script was pretty well written and I learnt Perl, or at least understand how _gtml_ worked very fast. It was then easy to add the features that I needed in it. I then asked Gihan if he would mind if I distribute _gtml_ under the GNU General Public License, since his license policy was not as open as GPL, and he accepted.

Then I just updated some of the docs, prepared an archive, in the http://www.gnu.org,GNU spirit, and that was it.

My biggest question was to understand where the name of the tool come from, and after some reflexions I got two possible answers:

  • G is the letter just before H, and _gtml_ source production comes just before HTML file one.
  • G is the first letter of Gihan's first name.

Well this is not a question anymore, Gihan told me the truth. Guess what? I found it: the first of my two previous hypotheses is the right one. (Well I hope that as time goes by it will be interpreted as GNU :-)

After I distributed it on my web pages, and after announcing it only on http://www.freshmeat.net,Freshmeat, I got some feedback from users coming from all around the world. I added some features which were asked of me, but realized that the source of the script needed some reorganization, and that there were some bugs in _gtml_.

I have done this source reorganization, and so have been able to fix bugs, and add a lot of fancy features. So now I'm waiting for users' feedback, in order to verify that I did not add bugs :-), and that _gtml_ is now sufficiently stable.

In one month or so I hope to be able to say that it does. So I really need your help for that, please give me some feedback!.

I will not add any features, before the next stable release.

I hope my version of _gtml_ will help you as it helps me.

--Bruno, 31 August 1999 #include "footer" gtml-3.5.4/src/gtml.gtp0000644000175000001440000000205610140455132015372 0ustar andrexusers00000000000000// $Id: gtml.gtp,v 1.11 1999/09/09 00:06:34 beaufils Exp $ // // Project file to construct GTML documentations. // define OPEN_DELIMITER [[ define CLOSE_DELIMITER ]] // // Basic shortcuts // definechar _gtml_ GTML definechar _new_ [** NEW **] definechar _ftp_ http://sourceforge.net/project/showfiles.php?group_id=100737 definechar _www_ http://sourceforge.net/projects/gtml/ define __VERSION__ 3.5.4 // // Process control // define OUTPUT_DIR .. mtimestamp Last modification: $yyyy/$MM/$dd at $hh:$mm include "tags" include "commands" // // Source files. // filename MAIN gtml.gtm filename REF gtml_ref.gtm filename NEWS NEWS.gtm filename CREDITS CREDITS.gtm filename SITEMAP sitemap.gtm filename STYLE gtml.css..gtm // // Documentation hierarchy // [[MAIN]] 1 Home [[REF]] 1 Reference [[NEWS]] 1 Revision history [[CREDITS]] 1 Credits [[SITEMAP]] [[STYLE]] //hierarchy //define EXTENSION .txt.html //define TEXT_ONLY //hierarchy // End of gtml.gtp. gtml-3.5.4/src/gtml_ref.gtm0000644000175000001440000010464506767030126016246 0ustar andrexusers00000000000000#define TITLE GTML Reference Page #include "header"

This is the reference page for the HTML pre-processor _gtml_. It describes all the _gtml_ features and commands in detail. For more information about getting _gtml_, see [[MAIN]], the main _gtml_ page.

_gtml_ features fall into four main areas, and we'll look at them in this order:

  • #commands, _gtml_ commands embedded among HTML text.
  • The optional #project, _gtml_ project file, which allows you to manage a set of Web pages together.
  • #special,Special named constants generated or used by _gtml_.
  • #cmdline,Command-line options.

Commands

The original syntax of _gtml_ was stolen shamelessly from the C language pre-processor, and has been adapted to suit Web site management. It supports the following commands:

  • #include,include - Include the contents of another file.
  • #define,define and #newdefine, newdefine - Create named constants which can be used as shorthand definitions of frequently-used HTML segments.
  • #undef,undef - Remove a named constant.
  • #timestamp,timestamp and #mtimestamp, mtimestamp - Insert a formatted date/time stamp.
  • #literal,literal - Turn off _gtml_ processing.
  • #definechar,definechar - Define characters (or strings) translations.
  • #entities,entities - Convert special characters to HTML entities.
  • #if,"if, ifdef, ifndef, elsif, elsifdef, elsifndef, else, endif" - Select sections of the source based on certain conditions.
  • #compress,compress - Turn on file compression, eliminating HTML useless segments.
  • #sitemap,sitemap and #sitemap,toc - Insert a map of all your site.

Command syntax

There are two ways of writing commands:

  • You can insert the commands directly, in which case they are preceded by #, and must appear at the start of a separate line (no preceeding spaces). Here's an example:
    #literal ON
    #include "header.txt"
    
    #literal OFF
  • The other method is to embed the command inside an HTML comment. In this case, the line must begin with <!-- ### followed by the command name, followed by the close-comment tag -->. Here's the same example in this format:
    <!-- ###include "header.txt" -->
    

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 about _gtml_ commands, you can use the second method to hide the _gtml_ commands from the tool.

#include

If 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:

#literal on
#include "common.txt"
#literal off

_gtml_ replaces this line with the entire contents of the file common.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 #searchpath,special named constant.

#define

This 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:

#literal on
#define MY_EMAIL gihan@pobox.com
#literal off

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:

#entities ON
     <>
#entities OFF

The double angle-brackets tell _gtml_ to substitute this with its definition (You can #delimiters,specify your own choice of delimiters instead of the double-angle brackets).

There are a few other things you should know about #define:

#newdefine

This is identical to #define,#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.

#undef

Use this to remove the definition of a named constant:

#undef MY_EMAIL

If the named constant didn't exist previously, this does nothing.

#if, #ifdef, #ifndef, #elsif, #elsifdef, #elsifndef, #else, #endif

These commands are used together for conditional output:

  • #if <<FRED>> == foo
    Process 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 FRED
    Process the following lines only if the named constant FRED is defined.
  • #ifndef FRED
    Process the following lines only if the named constant FRED is not defined.
  • #elsif <<FRED>> == foo
    If previous lines were not processed, then process the following lines only if after substitution, the left and right values are equal.
  • #elsif <<FRED>> != foo
    If previous lines were not processed, then process the following lines only if after substitution, the left and right values are different.
  • #elsifdef FRED
    If previous lines were not processed, then process the following lines only if the named constant FRED is defined.
  • #elsifndef FRED
    If previous lines were not processed, then process the following lines only if the named constant FRED is not defined.
  • #else
    The opposite effect of the most recent matching #if, #ifdef, #ifndef, #elsif, #elsifdef or #elsifndef.
  • #endif
    End a block of conditional output. Every #if, #ifdef or #ifndef must have a matching #endif

Conditional blocks can be nested.

#timestamp

The special named constant TIMESTAMP evaluates to the current date and time. But to use it, you must tell _gtml_ what format to use to print the date/time.

The format string is specified in the #timestamp statement like this:

#literal on
#timestamp   $dd/$MM/$yy at $hh:$mm:$ss
#literal off

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,LANGUAGE special definition.

#mtimestamp

This is identical to #timestamp,timestamp, except that the time used is not the current one, but the time the file was last modified.

#literal

The command #literal ON tells _gtml_ to stop interpreting lines beginning with # as _gtml_ commands, until the next #literal OFF line. Defined constants are still substituted, and #entities,entities are translated if desired.

For example, this is useful for bracketing blocks of C code, which might have lines beginning with #.

#entities

The command #entities ON tells _gtml_ to convert the characters <, > and & into HTML entities so they aren't treated as part of HTML commands. Use #entities OFF to turn off this conversion.

This is useful for bracketing blocks of program code, which often contain these characters.

#definechar

Basic HTML authorized characters may only be ASCII characters. Accentuated characters are coded in HTML in a certain way. For instance the é character is coded &eacute;. 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 #definechar command, like in this example:

#literal on
#definechar é &eacute;
#literal off

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 #definechar command:

#literal on
#definechar ss &szlig;
#literal off

#compress

The command #compress ON tells _gtml_ to 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, #toc

When you specify a #hierarchy, hierarchy of pages in your #project,project file you may insert a table of contents, or site map, of those pages, using the command #sitemap, or #toc.

See #hierarchy,Document hierarchy specifications for more information on how the list is created.

_gtml_ project files

Because _gtml_ is most useful for managing multiple files, it's quite common to change something in a #include'd file, and then run _gtml_ on all the .gtm files which use it.

To make this procedure easier, _gtml_ supports a concept of a project file. This is a simple text file with the extension .gtp. It can contain:

  • define ...
    As for #define,#define in a source file.
  • define! ...
    As for #define!,#define! in a source file.
  • define+ ...
    As for #define+,#define+ in a source file.
  • newdefine ...
    As for #newdefine,#newdefine in a source file.
  • newdefine! ...
    As for #newdefine!,#newdefine! in a source file.
  • undef ...
    As for #undef,#undef in a source file.
  • timestamp ...
    As for #timestamp,#timestamp in a source file.
  • mtimestamp ...
    As for #mtimestamp,#mtimestamp in a source file.
  • if ...
    ifdef ...
    ifndef ...
    elsif ...
    elsifdef ...
    elsifndef ...
    else
    endif
    As for #if,"#if, #ifdef, #ifndef, #elsif, #elsifdef, #elsifndef, #else, #endif" in a source file.
  • definechar ...
    As for #definechar,#definechar in a source file.
  • compress ...
    As for #compress,#compress in a source file.
  • include ...
    As for #include,#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.
  • allsource
    This is a shorthand way of specifying all source files from the current directory and sub-directories (recursively).
  • filename alias file
    This 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. _gtml_ will compute the right relative path to the file in each source file. This way you may move your files wherever you want, _gtml_ will be able to recreate your pages without having to modify the source files.
  • filename.gtm
    All other lines are names of source files, which are processed by _gtml_ in 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
    #entities ON
       <>
    #entities OFF
    

    The file name can be followed by a level number and a title, to be used in #hierarchy,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).

  • hierarchy
    This 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 _gtml_ with the project file as a command-line argument, it will process all the source files in the project file. They will all inherit the define, definechar and timestamp values, if any, in the project file. The mtimestamp value 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 #optionf, -F command line argument.

Note that #define, #newdefine and #undef commands 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 hierarchy

_gtml_ allows 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 - _gtml_ generates only those that apply to each page.

Describing the hierarchy

You describe the document hierarchy to _gtml_ by 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 _gtml_ processes a file, it defines special named constants which can be used in exactly the same way as #define,other named constants.

For each file, _gtml_ generates 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.

Example

Here's an extract from a hypothetical _gtml_ project 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.gtm will have LINK_NEXT set to sec22.html (and TITLE_NEXT set to Recent Findings) and LINK_UP set to chapter2.html (and TITLE_UP set to Historical Evidence). LINK_PREV and TITLE_PREV will be undefined.

Using the links

The 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 #include it into each _gtml_ source file. The _gtml_ #ifdef command can be used to exclude links which don't apply to a particular file.

Here's a simple example:

#entities on
#literal ON
#ifdef LINK_NEXT
   

Next document: <> #endif #ifdef LINK_PREV

Previous document: <>; #endif #ifdef LINK_UP

Up one level: <>; #endif #literal OFF #entities off

Creation of table of contents

When you have described a document hierarchy, and you use a #sitemap, #toc or #sitemap command into your source file, _gtml_ includes 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:

#entities on
<<__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')>>
    ')>>
  ')>>
')>>
#entities off

__TOC_#__(x), and __TOC_#_ITEM__(x,y) have the following default values:

#entities on
#literal on
#define __TOC_#__(x)        
    x
#define __TOC_#_ITEM__(x,y)
  • y #literal off #entities off
  • You may redefine this constant to whatever you want as long as you respect the number of variables.

    Special definitions

    Environment

    All environment variables are defined as named constants by _gtml_.

    Current file names

    The 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 files

    _gtml_ always searches for include files in the directory of the processed source file first, then the current directory (where the _gtml_ command is executed).

    In addition, if you define the named constant INCLUDE_PATH, _gtml_ will 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 directory

    By default, _gtml_ writes 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. _gtml_ will create the same directory hierarchy for the output files as for the input files (It creates sub-directories as required).

    Output suffix

    By 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,project file or on the #cmdline,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 in gtml.css.

    Fast generation

    _gtml_ only 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 way make works.

    To enable this feature you just have to define the special constant FAST_GENERATION. The use of this constant will work only in #project,_gtml_ project files or on the #cmdline,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 make tool in conjunction with the #optionf,-F and #optionm,-M command line arguments.

    Language localisation

    By 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:

    • fr for French ;
    • de for German ;
    • ie for Irish ;
    • it for Italian ;
    • nl for Dutch ;
    • no for Norvegian ;
    • se for 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 delimiters

    The 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:

    #literal ON
    #define OPEN_DELIMITER {{
    #define CLOSE_DELIMTER }}
    
    #define MY_EMAIL  gihan@pobox.com
    #literal OFF
    

    then GTML substitutes MY_EMAIL when it finds the text {{MY_EMAIL}} instead of the default <<MY_EMAIL>>.

    Document hierarchy links

    As described above, _gtml_ #hierarchy,defines several named constants for links between documents.

    Embedded Perl code

    You may embed Perl code into your _gtml_ source 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:

    #entities on
    <<__PERL__(return (stat(<><>.".gtm"))[7];)>>
    #entities off
    

    Embedded system command code

    You may embed system command output into your _gtml_ source file, with the help of the one argument macro __SYSTEM__.

    Here is an example inserting the list of files in the current directory:

    #entities on
    <<__SYSTEM__(dir)>>
    #entities off
    

    Command-line arguments

    -D

    When you run _gtml_ from 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.

    -F

    When you run _gtml_ from 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 with make for page regeneration based on complex files dependencies (induced by #include commands).

    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.html file your command line will be:

    perl gtml -Fbar.gtm foo.gtp
    

    List of files to processed is cleared after each project file treatment.

    -M

    When you run _gtml_ with the -M command line argument, _gtml_ process project and source files, but do not produce ouput files. _gtml_ generates a makefile ready to create output files.

    If you do not specify a filename, the generated makefile is created under the GNUmakefile name.

    To specify a filename, just add it after the -M argument, with a colon between the option and the file name.

    -h, --help

    To get a small command line usage description you can use the -h, or --help command line argument.

    --silent

    If you specify the --silent command line argument, _gtml_ will produce no processing information during its work.

    --version

    To get the version number of the _gtml_ you are currently using you can use the --version command line argument. #include "footer" gtml-3.5.4/gtml0000755000175000001440000016441410140444373014031 0ustar andrexusers00000000000000#!/usr/bin/perl # # Program: gtml # # Version: 3.5.4 (See NEWS file for revision history) # # Description: gtml is a program to manage groups of HTML files with # similar properties. # # Authors: versions 1.0 to 2.3 # Gihan Perera , First Step Communications # versions 3.0 to 3.5.3 # Bruno Beaufils # version 3.5.4 # Andrew E. Schulman # (see CREDITS file for complete list of contributors) # # Documentation and updates for this program are available at: # # http://sourceforge.net/projects/gtml # # Copying and Distribution: # # Copyright (C) 1996-1999 Gihan Perera # Copyright (C) 1999 Bruno Beaufils # Copyright (C) 2004 Andrew E. Schulman # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 59 Temple # Place, Suite 330, Boston, MA 02111-1307 USA # # ---------------------------------------------------------------------------- # # Here comes lists of global variables with their utility. # # Firstly comes variables which may not be changed by gtml or its user: # # @configurationFiles gtml default configuration file list # @extProject project file suffix list # @extSource gtml source file suffix list # # Then comes variables which may be modified by gtml user: # # $argsep argument separator # $beSilent to produce processing info output or not # $compression to produce compressed output or not # $debug print debug informations when developping or not # $delim1 opening macro delimiter # $delim2 closing macro delimiter # $entities to convert HTML entities or not # $extTarget output file suffix # $generateMakefiles generate Makefiles or process files (MAKE_GEN) # $literal to not interpret GTML command or to do # $makefileName name of the makefile to generate (MAKE_GEN) # $mstamp string containing format of file timestamp # $outputDir directory where files will be created # $stamp string containing format of basic timestamp # %characters hash table of characters and their translation # %defines hash table of macro and their definitions # %fileAliases hash table of file alias and their real names # @fileToProcess table of files to process within project file # @pfile list of file names of the pages structure # @plevel list of file level of the pages structure # @ptitle list of file title of the pages structure # # Finally comes variables which may be modified only by gtml itself: # # $current index in @supress of the current ignoring state # $exitStatus gtml exit status # $filenum file handler of read file, must be >= 5 # $ifLevel depth of current if-command # $hierarchyRead has a hierarchy command been read # $nbError number of processing errors # %dependencies hash table of dependencies for each file (MAKE_GEN) # @extensions list of all output extensions used (MAKE_GEN) # @lines list of ouput lines stored when compressing is asked # @outputFiles list of all generated files (MAKE_GEN) # @suppress list of line-ignoring state coming from if/ifdef # @wasTrue list of whether we've seen a true condition yet in # an if...elsif... sequence # @wasElse list of whether we've seen an 'else' yet # ---------------------------------------------------------------------------- # ============================================================================ @extProject = (".gtp"); @extSource = (".gtm", ".gtml"); $extTarget = ".html"; @configurationFiles = (".gtmlrc", "gtml.conf"); @extensions = ($extTarget); $delim1 = "<<"; $delim2 = ">>"; $argsep = ','; $entities = 0; $literal = 0; $beSilent = 0; $compression = 0; $generateMakefiles = 0; $makefileName = "GNUmakefile"; @suppress = (0); $current = 0; $ifLevel = 0; $exitStatus = 0; $initialFilenum = 5; $filenum = $initialFilenum; $nbError = 0; $debug = 0; # ---------------------------------------------------------------------------- # Process the command line for informative opions. foreach $i ( @ARGV ) { # # Show help message. # if ( $i =~ /^-h/ || $i =~ /^--help/ ) { &ShowHelp(); exit(0); } # # Show version # elsif ( $i =~ /^--version/ ) { &ShowVersion(); exit(0); } # # Do not output informations during process time. # elsif ( $i =~ /^--silent/ ) { $i =~ s/^--silent//; $beSilent = 1; } } # ---------------------------------------------------------------------------- # Add all environment variables as defined macros. foreach $key ( keys %ENV ) { &Define($key, $ENV{$key}); } # ---------------------------------------------------------------------------- # Parse default configuration project file if present. foreach $i ( @configurationFiles ) { my $confFile = $ENV{"HOME"} . "/" . $i; &ProcessProjectFile($confFile) if ( -r $confFile ); } foreach $i ( @configurationFiles ) { &ProcessProjectFile($i) if ( -r $i ); } # ---------------------------------------------------------------------------- # Process the command line. foreach $i ( @ARGV ) { # # Define a macro. # if ( $i =~ /^-D/ ) { $i =~ s/^-D//; ($key, $value) = split(/=/, $i, 2); &Define($key, $value); } # # Generate a makefile. # elsif ( $i =~ /^-M/ ) { if ( $i =~ /^-M([^- \t]+)/ ) { $makefileName = $1; } $generateMakefiles = 1; } # # Specify which file to process in the next project file. # elsif ( $i =~ /^-F/ ) { $i =~ s/^-F//; push(@fileToProcess, $i); } # # Process files. # else { if ( &isProjectFile($i) ) { &ProcessProjectFile($i, 1); } elsif ( &isSourceFile($i) ) { &ProcessSourceFile($i, ""); } else { &Warning("Skipping `$i' (unknown file type)"); } } } if ($generateMakefiles) { &GenerateMakefile(); } &Notice("\n$nbError errors occured during process.\n") if ( $nbError != 0); exit($exitStatus); # ============================================================================ # ---------------------------------------------------------------------------- # Add a macro in the definition list. sub Define { local ($key, $value) = @_; # # Special macros. # if ( $key eq "__PERL__" || $key eq "__SYSTEM__" || $key eq "__NEWLINE__" || $key eq "__TAB__") { &Warning("system macros unmodifiable `$key'"); return } @includePath = split(/:/, $value) if ( $key eq "INCLUDE_PATH" ); $outputDir = $value if ( $key eq "OUTPUT_DIR" ); $delim1 = $value if ( $key eq "OPEN_DELIMITER" ); $delim2 = $value if ( $key eq "CLOSE_DELIMITER" ); $argsep = $value if ( $key eq "ARGUMENT_SEPARATOR" ); $extTarget = $value if ( $key eq "EXTENSION" ); push(@extensions, $value) if ( $key eq "EXTENSION" ); $debug = 1 if ( $key eq "DEBUG" ); &SetTimestamps() if ( $key eq "LANGUAGE" ); $value = "(((BLANK)))" if ( $value eq ""); $defines{"$key"} = $value; } # ---------------------------------------------------------------------------- # Add a file alias in the hash table of filename aliases. sub DefineFilename { local ($key, $value) = @_; if ( $value =~ /^\// ) { &Error("no absolute file references allowed: $value"); return; } $fileAliases{"$key"} = $value; &Define($key, $value); } # ---------------------------------------------------------------------------- # Define the value of each filename aliases as macros. sub SetFileReferences { foreach $key ( keys(%fileAliases) ) { if ( &GetValue("ROOT_PATH") eq "(((BLANK)))" ) { $value = $fileAliases{$key}; } else { $value = &GetValue("ROOT_PATH") . $fileAliases{$key}; } $value = &ChangeExtension($value); &Define($key, $value); } } # ---------------------------------------------------------------------------- # Get the value of a specified macro. sub GetValue { local ($key) = @_; return $defines{"$key"}; } # ---------------------------------------------------------------------------- # Remove a specified macro from the list of macros. sub Undefine { local ($key) = @_; delete($defines{ $key }); delete($characters{$key}); } # ---------------------------------------------------------------------------- # Mark up a given definition in order to outline argument of a definition. sub Markup { local ($key, $value) = @_; my (@args, $arg, $pos, $len); local ($start, $oldvalue); if ( $key =~ /(.+)\((.+)\)/ ) { # # Tag has parens: MACRO(x,y) ....x....y.... # $key = $1; $arg = $2; @args = split($argsep, $arg); $start = 0; # # Verify if key is not yet defined, if yes find last argument. # $oldvalue = &GetValue($key); if ( ! $oldvalue eq "" ) { my $s = substr($oldvalue, rindex($oldvalue, "(((MARKER")); if ( $s =~ /^\(\(\(MARKER([0-9])+\)\)\).*$/ ) { $start = $1 + 1; } } # # Markup argument # for ($i = 0; $i <= $#args; $i++) { $pos = index($value, $args[$i]); $len = length($args[$i]); while ($pos >= 0 && $len > 0) { $j = $i + $start; substr($value, $pos, $len) = "(((MARKER$j)))"; $pos = index($value, $args[$i]); $len = length($args[$i]); } } } return ($key, $value); } # ---------------------------------------------------------------------------- # Substitute all macros in the current line. sub Substitute { local (@args) = (); local ($key, $value, $arg); local ($ii); # # HTML entities may be converted. # if ($entities == 1) { # # The default case: substitute '<', '&', and '>'. # s/&/&/g; s//>/g; } # # User-defined characters has to be converted. # foreach $car ( keys %characters ) { $ii = index($_, $car); while ( $ii != ($[-1) ) { substr($_, $ii, length($car)) = $characters{$car}; $ii = index($_, $car); } } # # Macros has to be replaced by their values. # __NEWLINE__ and __TAB__ are substitute after all others. # $special = $delim1."__NEWLINE__".$delim2; $ii = index($_, $special); while ( $ii != ($[-1) ) { substr($_, $ii, length($special)) = "__NEWLINE__"; $ii = index($_, $special); } $special = $delim1."__TAB__".$delim2; $ii = index($_, $special); while ( $ii != ($[-1) ) { substr($_, $ii, length($special)) = "__TAB__"; $ii = index($_, $special); } $l1 = length($delim1); $l2 = length($delim2); my $more = 1; while ($more) { $p2 = index($_, $delim2); $p1 = rindex($_, $delim1, $p2); if ( $p2 >= $l1 ) { $key = substr($_, $p1+$l1, $p2-$p1-$l2); if ( $key =~ /^[^ \t]+[ \t]*\(.*\)$/ ) { # # Tag contains a keyword and arguments. # ($key, $arg) = split(/\(/, $key, 2); $arg =~ s/\)$//g; @args = &SplitArgs($arg); } if ( $key eq "__PERL__" ) { $value = eval($args[0]); } elsif ( $key eq "__SYSTEM__" ) { $value = qx{$args[0]}; } else { $value = $defines{$key}; for ($i = 0; $i <= $#args; $i++) { # # Argument substitution. # $marker = "(((MARKER$i)))"; $q = index($value, $marker); while ($q >= 0) { # # Substitution template contains a replacement marker. # $l = length($marker); substr($value, $q, $l) = $args[$i]; $q = index($value, $marker); } } } # # Make some verifications. # if ( $value eq "" && ! ($key eq "__PERL__" || $key eq "__SYSTEM__") ) { &Warning("undefined name `$key'"); } if ( $value =~ /\(\(\(MARKER([0-9])+\)\)\)/ ) { &Error("missing argument $1"); } # # Straightforward substitution. # $value = "" if ( $value eq "(((BLANK)))" ); substr($_, $p1, $p2-$p1+$l2) = $value; } else { $value = "" if ( $value eq "(((BLANK)))" ); $more = 0; } } s/__NEWLINE__/\n/g; s/__TAB__/\t/g; } # ---------------------------------------------------------------------------- # Split a string containing arguments into an array of argument and returns # this array. Take care of quoted arguments, in order to allow the use of # argument separator in argument. sub SplitArgs { local ($in) = @_; local (@temp) = split($argsep, $in); local (@args) = (); local ($_); while ($#temp >= 0) { $_ = shift(@temp); if (/^"/) #" { # # Start of "quoted arg" detected, look for end, and add argument. # while ( ! /(^"[^"]*")/ ) #" { $_ .= $argsep . shift(@temp); } s/^"([^"]*)"/$1/; #" push(@args, $_); } elsif (/^'/) #' { # # Start of 'quoted arg' detected, look for end, and add argument. # while (! /(^'[^']*')/) #' { $_ .= $argsep . shift(@temp); } s/^'([^']*)'/$1/; #' push(@args, $_); } else { push(@args, $_); } } return @args; } # ---------------------------------------------------------------------------- # Return 1 if given filename may be a project file, 0 else. sub isProjectFile { local ($filename) = @_; foreach $ext ( @extProject ) { return 1 if ( $filename =~ /$ext$/i ); } return 0; } # ---------------------------------------------------------------------------- # Return 1 if given filename may be a source file, 0 else. sub isSourceFile { local ($filename) = @_; foreach $ext ( @extSource ) { return 1 if ( $filename =~ /$ext$/i ); } return 0; } # ---------------------------------------------------------------------------- # Return the given source filename with extension changed according to # $extTartget. sub ChangeExtension { local ($file) = @_; foreach $ext (@extSource) { $file =~ s/\.$ext$// if ( $file =~ /\.$ext/ ); $file =~ s/$ext$/$extTarget/ if ( $file =~ /$ext$/i ); } return $file; } # ---------------------------------------------------------------------------- # Get the pathname of a given file. # Always ends with a `/' if non-null. sub GetPathname { local ($name) = @_; $name =~ s/\\/\//g; # "\" -> "/" $n = rindex($name, "/"); if ( $n > $[-1 ) { $name = substr($name, 0, $n+1); } else { $name = ""; # DEBUG ./ } return $name; } # ---------------------------------------------------------------------------- # Get the basename of a given output file. sub GetOutputBasename { local ($name) = @_; $name =~ s/\\/\//g; # "\" -> "/" $n = rindex($name, "/"); $baseName = substr($name, $n+1); $baseName =~ s/$extTarget$//; return $baseName; } # ---------------------------------------------------------------------------- # Returns a list of all source files under the `.' directory. sub AllSourceFiles { my @files = (); my @dirs = ("."); my $dir = pop(@dirs); while ( $dir ) { opendir(DIR, $dir) || die("Can't open $dir"); if ( $dir eq "." ) { $dir = ""; } else { $dir .= "/"; } my $file; foreach $file ( grep(!/\.$/, readdir(DIR)) ) # from { if ( &isSourceFile($file) == 1 ) { push(@files, "$dir$file"); } elsif ( -d "$dir$file" ) { push(@dirs, "$dir$file"); } } $dir = pop(@dirs); } return @files; } # ---------------------------------------------------------------------------- # Get the path to the root directory of the project from a given a file name. # Always end with a `/' if non-null. sub GetPathToRoot { local ($name) = @_; local ($basename) = $name; $basename =~ s/\\/\//g; # "\" -> "/" $n = rindex($basename, "/"); $basename = substr($basename, $n+1) if ( $n != $[-1 ); local ($pathToRoot) = $name; $pathToRoot =~ s/$basename//g; $pathToRoot =~ s/[^\/\.]+\//\.\.\//g; # DEBUG ./ $pathToRoot = "./" if ( $pathToRoot eq "" ); return $pathToRoot; } # ---------------------------------------------------------------------------- # Returns the complete name of a file which may be stored anywhere in the # @includePath. sub ResolveIncludeFile { local ($name) = @_; $file = &GetValue("PATHNAME") . $name; $file =~ s/\/\//\//g; $file = $name if ( &GetValue("PATHNAME") eq "(((BLANK)))" ); if ( -r $file ) { return $file; } elsif ( -r $name ) { return $name; } local ($_) = @includePath; Substitute; foreach $dir ($_) { $file = $dir . "/" . $name; $file =~ s/\/\//\//g; return $file if ( -r $file ); } &Error("no include file `$name' in `" . &GetValue("INCLUDE_PATH") . "'"); return ""; } # ---------------------------------------------------------------------------- # Print the gtml version on the standard ouptut. sub ShowHelp { print ( "Usage: gtml [OPTIONS...] file... OPTIONS: -M[:file] Do not produce ouput files but generate a makefile ready to create them with gtml. If no is given the generated file will be called `GNUmakefile'. -Dmacro[=definition] Define constant eventually defined by . -Ffile Do not process all files in the next project, but . --silent Do not produce any output informations during file processing. -h, --help Show this help message. --version Show gtml current version. NOTES: Before processing command line arguments, gtml try to process project files `\${HOME}/.gtmlrc', `\${HOME}/gtml.conf', `./.gtmlrc' and `./gtml.conf' in this order, allowing one to add/modify default behavior of gtml. Exit status is 1 if errors have been encountered, and 0 if all was OK. Report bugs at http://sourceforge.net/projects/gtml/. "); } # ---------------------------------------------------------------------------- # Print the gtml version on the standard ouptut. sub ShowVersion { print ( "GTML version 3.5.4, Copyright (C) 1996-1999 Gihan Perera Copyright (C) 1999 Bruno Beaufils Copyright (C) 2004 Andrew E. Schulman GTML comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redristribute it under the conditions defined in the GNU General Public License; See the README or COPYING file for details. "); #' } # ---------------------------------------------------------------------------- # Print a given message, as is, on the standard output if allowed. sub Notice { local ($message) = @_; print($message) if ( $beSilent == 0 ); } # ---------------------------------------------------------------------------- # Print a debug information. sub Debug { local ($message) = @_; print("########### " . $message) if ( $debug == 1 ); } # ---------------------------------------------------------------------------- # Notice a given warning. sub Warning { local ($message) = @_; &Notice(" !!! Warning: lines $.: $message.\n") if ( ! ($. eq "") ); &Notice(" !!! Warning: $message.\n") if ( ($. eq "") ); } # ---------------------------------------------------------------------------- # Notice a given error. sub Error { local ($message) = @_; &Notice(" *** Error: line $.: $message.\n") if ( ! ($. eq "") ); &Notice(" *** Error: $message.\n") if ( $. eq "" ); $exitStatus |= 2; $nbError += 1; } # ---------------------------------------------------------------------------- # Split a given time into the following global printable values: # # $sec Seconds, 00 - 59 # $min Minutes, 00 - 59 # $hour Hours, 00 - 23 # $wday Day of the week, Sunday - Saturday # $shortwday First three letters of month name, Sun - Sat # $mday Day of the month, 1 - 31 # $mdayth Day of the month with particuliar extension, 1st - 31th # $mon Month number, 1 - 12 # $monthname Full month name, January - December # $shortmon First three letters of month name, Jan - Dec # $year Full year (e.g. 1996) # $syear Last two digits of year (e.g. 96) sub SplitTime { ($sec, $min, $hour, $mday, $mon, $syear, $wday, $yday, $isdst) = @_; # # Month and Weekdays are defined differently in each language. # if ( &GetValue("LANGUAGE") eq "fr" ) { @Month = ( "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre" ); @WeekDay = ( "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" ); $mdayth = $mday; $mdayth = "1er" if ($mday == 1); } # "no" thanks to Helmers, Jens Bloch elsif ( &GetValue("LANGUAGE") eq "no" ) { @Month = ( "januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember" ); @WeekDay = ( "Søndag", "Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag" ); $mdayth = $mday . "."; } # "se" thanks to magog, elsif ( &GetValue("LANGUAGE") eq "se" ) { @Month = ( "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december" ); @WeekDay = ( "Söndag", "Måndag", "Tisdag","Onsdag", "Torsdag", "Fredag", "Lördag" ); $mdayth = $mday; # XXX: Not verified } # "it" thanks to Pioppo, elsif ( &GetValue("LANGUAGE") eq "it" ) { @Month = ( "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" ); @WeekDay = ( "Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato" ); $mdayth = $mday; } # "nl" thanks to Gert-Jan Brink elsif ( &GetValue("LANGUAGE") eq "nl" ) { @Month = ( "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december" ); @WeekDay = ( "zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag" ); $mdayth = $mday; } # "de" thanks to Uwe Arzt elsif ( &GetValue("LANGUAGE") eq "de" ) { @Month = ( "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember" ); @WeekDay = ( "Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag" ); $mdayth = $mday; } # "ie" thanks to Ken Guest elsif ( &GetValue("LANGUAGE") eq "ie" ) { @Month = ( "Enáir", "Feabhra", "Márta", "Bealtaine", "Aibreán", "Meitheamh", "Lúil", "Lúnasa", "Méan Fomhair", "Deireadh Fomhair", "Samhain", "Mí na Nollaig" ); @WeekDay = ( "Domhnach", "Luan", "Máirt", "Céadaoin", "Déardaoin", "Aoine", "Satharn" ); $mdayth = $mday . "."; } # default is english. else { @Month = ( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ); @WeekDay = ( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ); $mdayth = $mday . "th"; # from $mdayth = $mday . "st" if ($mday == 1 || $mday == 21 || $mday == 31); $mdayth = $mday . "nd" if ($mday == 2 || $mday == 22); $mdayth = $mday . "rd" if ($mday == 3 || $mday == 23); } $sec = sprintf("%02d", $sec); $min = sprintf("%02d", $min); $hour = sprintf("%02d", $hour); $wday = $WeekDay[$wday]; # from $shortwday = substr($wday, 0, 3); $monthname = $Month[$mon]; $shortmon = substr($monthname, 0, 3); $year = $syear + 1900; $syear = substr($year, -2, 2); $mon++; # Because it starts from 0 } # ---------------------------------------------------------------------------- # Returns a printable time/date string based on a given format string. # # The format string is passed in the variable $stamp, and the following # substitutions are made in it: # # $ss -> seconds # $mm -> minutes # $hh -> hour # $Ddd -> Short weekday name (Sun - Sat) # $Day -> full weekday name # $dd -> day of the month # $ddth -> day of the month with th extension # $MM -> month number (1 - 12) # $Mmm -> short month name (Jan - Dec) # $Month -> full month name # $yyyy -> full year (e.g. 1996) # $yy -> short year (e.g. 96) # # Make sure you call "SplitTime" first to initialise time global variables, # i.e time to format. sub FormatTimestamp { local ($stamp) = @_; $stamp =~ s/\$ss/$sec/g; $stamp =~ s/\$mm/$min/g; $stamp =~ s/\$hh/$hour/g; $stamp =~ s/\$Ddd/$shortwday/g; $stamp =~ s/\$Day/$wday/g; $stamp =~ s/\$ddth/$mdayth/g; $stamp =~ s/\$dd/$mday/g; $stamp =~ s/\$MM/$mon/g; $stamp =~ s/\$Month/$monthname/g; $stamp =~ s/\$Mmm/$shortmon/g; $stamp =~ s/\$yyyy/$year/g; $stamp =~ s/\$yy/$syear/g; return $stamp; } # ---------------------------------------------------------------------------- # Defines eventual timestamps macros. sub SetTimestamps { local($name) = @_; if ( ! $stamp eq "" ) { &SplitTime(localtime); &Define("TIMESTAMP", &FormatTimestamp($stamp)); } if ( ! $mstamp eq "" && ! $name eq "" ) { &SplitTime(localtime((stat($name))[9])); &Define("MTIMESTAMP", &FormatTimestamp($mstamp)); } } # ---------------------------------------------------------------------------- # Read a source line into a given file. Source lines may be written on # multiple lines via `\' character at the end. sub ReadLine { local ($file) = @_; local ($line); # # Read a line from input file. # $_ = <$file>; while ( /\\\n$/ ) { # # We are on multilines, so remove last `\'. # s/\\\n$//g; # # Read a new line from input file. # $_ .= <$file>; } return $_ ; } # ---------------------------------------------------------------------------- # What to do with a given project file. If second argument is 0 then source # files will not be processed (i.e. means the routine is called for an # included project file). sub ProcessProjectFile { local ($name, $process) = @_; local ($file); local ($STREAM); local ($hierarchyRead) = 0; my @suppress = (0); my @wasTrue = (0); my @wasElse = (0); my $current = 0; my $ifLevel = 0; if ( $process ) { &Notice("=== Project file $name ===\n"); $STREAM = 3; } else { &Notice ("--- Included project file $name ---\n"); $STREAM = 4; } open($STREAM, $name); while ( &ReadLine($STREAM) ) { # # Skip blank and comment lines. # next if ( /^\/\// ); next if ( /^[ \t]*$/ ); # # Next process if(def)/elsif/else/endif to decide if we want to # suppress any lines. # if ( /^if/ || /^elsif/ ) { chop; my ($wasIf, $match, $var, $condl, $comp, $value); if ( /^if/ ) { $ifLevel += 1; $wasIf = 1; } else { s/^els//; $wasIf = 0; } Substitute(); if ( /^ifdef/ || /^ifndef/ ) { ( $dummy, $var ) = split(/[ \t]+/, $_); $match = ( &GetValue($var) ne "" ); $match = ! $match if ( /^ifndef/ ); } else { ( $condl, $var, $comp, $value ) = split(" ", $_, 4); if ( $comp eq "==" ) { $match = ( $var eq $value ); } elsif ( $comp eq "!=" ) { $match = ( $var ne $value ); } else { Error("unknown comparator `$comp'"); $match = 0; } } if ( $wasIf ) { push(@suppress, ! $match); push(@wasTrue, $match); push(@wasElse, 0); $current = $ifLevel if ( ! $suppress[$current] ); } else { if ( $ifLevel == 0 ) { $condl =~ s/^/els/; Error("$condl with no preceding if"); } elsif ( $wasTrue[$ifLevel] ) { $suppress[$ifLevel] = 1; } else { $suppress[$ifLevel] = ! $match; $wasTrue[$ifLevel] = $match; } } next; } elsif ( /^else/ ) { if ( $ifLevel == 0 ) { Error("else with no preceding if"); } elsif ( $wasElse[$ifLevel] ) { Error("multiple 'else's"); } else { $suppress[$ifLevel] = $wasTrue[$ifLevel]; $wasElse[$ifLevel] = 1; } next; } elsif ( /^endif/ ) { if ( $ifLevel == 0 ) { Error("unmatched endif"); } else { pop(@suppress); pop(@wasTrue); pop(@wasElse); $current -= 1 if ( $current == $ifLevel ); $ifLevel -= 1; } next; } # # Skip lines if current ignoring state says so. # next if ( $suppress[$current] ); # # Characters translation can be defined here. # if ( /^definechar[ \t]/ ) { chop; ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); $characters{$key} = $value; } # # Macros can be defined here. # elsif ( /^define[ \t]/ ) { chop; ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); if ( $key =~ /(.+)\((.+)\)/ ) { &Undefine($1); } ( $key, $value ) = &Markup($key, $value); &Define($key, $value); } elsif ( /^newdefine[ \t]/ ) { chop; ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); if ( ! &GetValue($key) eq "" ) { next; } ( $key, $value ) = &Markup($key, $value); &Define($key, $value); } elsif ( /^define\!/ ) { chop; &Substitute(); ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); if ( $key =~ /(.+)\((.+)\)/ ) { &Undefine($1); } ( $key, $value ) = &Markup($key, $value); &Define($key, $value); } elsif ( /^newdefine!/ ) { chop; &Substitute(); ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); if ( ! &GetValue($key) eq "" ) { next; } ( $key, $value ) = &Markup($key, $value); &Define($key, $value); } elsif ( /^define\+/ ) { chop; ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); ( $key, $value ) = &Markup($key, $value); &Define($key, &GetValue($key) . $value); } elsif ( /^undef[ \t]/ ) { chop; ( $dummy, $key ) = split ( /[ \t]+/, $_); &Undefine($key); } # # Saving bandwidth file compression eliminates anything not necessary # for correct display of content on the client browser. # elsif ( /^compress/ ) { chop; ( $dummy, $switch ) = split(/[ \t]+/, $_); if ( $switch =~ /^ON$/i ) { $compression = 1; } elsif ( $switch =~ /^OFF$/i ) { $compression = 0; } else { &Error("expecting compress as `ON' or `OFF'"); } } # # Timestamp format can be defined here. # elsif ( /^timestamp[ \t]/ ) { chop; ( $dummy, $stamp ) = split(/[ \t]/, $_, 2); } elsif ( /^mtimestamp[ \t]/ ) { chop; ( $dummy, $mstamp ) = split(/[ \t]/, $_, 2); } # # Filenames aliases can be defined here. # elsif ( /^filename[ \t]/ ) { chop; &Substitute(); ( $dummy, $key, $value ) = split(/[ \t]+/, $_, 3); &DefineFilename($key, $value); } # # Included files. # elsif ( /^include[ \t]/ ) { chop; &Substitute(); s/^include[ \t]*"//; s/".*$//; #" $file = $_; $file = &ResolveIncludeFile($file); $dependencies{$name} .= "$file "; &ProcessProjectFile($file, 0); } # # They can ask for all source files here. # elsif ( /^allsource/ ) { foreach $file ( &AllSourceFiles() ) { &ProcessSourceFile($file, $name); } } # # They can ask for hierarchy files process. # elsif ( /^hierarchy/ ) { for ( $ii = 0; $ii <= $#pfile; $ii += 1) { &SetLinks(); &ProcessSourceFile($pfile[$ii], $name, " ($plevel[$ii])"); } $hierarchyRead = 1; } # # Everything else must be a source file name. # else { chop; &Substitute(); s/\s+/ /g; ( $file, $level, $title ) = split(/\s/, $_, 3); $file = $fileAliases{$file} if ( defined($fileAliases{$file}) ); if ( $file =~ /^\// ) { &Error("no absolute file references allowed: $file"); next; } if ( &isSourceFile($file) ) { if ( $level eq "" ) { &ProcessSourceFile($file, $name); } else { $lkey = "__TOC_" . $level . "__"; if ( ! defined($defines{$lkey}) ) { &Define($lkey, "

      (((MARKER0)))
    "); } $lkey = "__TOC_" . $level . "_ITEM__"; if ( ! defined($defines{$lkey}) ) { &Define($lkey, "
  • (((MARKER1)))"); } push(@pfile, $file); push(@plevel, $level); push(@ptitle, $title); } } else { &Warning("Skipping `$_' (unknown file type)"); } } } # # Process files with links to others. # if ( ! $hierarchyRead ) { for ( $ii = 0; $ii <= $#pfile; $ii += 1) { &SetLinks(); &ProcessSourceFile($pfile[$ii], $name, " ($plevel[$ii])"); } } # # Clean up a bit. # if ($process) { undef(@fileToProcess); undef(@pfile); undef(@plevel); undef(@ptitle); } close $STREAM; } # ---------------------------------------------------------------------------- # Add macros used for link to other pages for files with links to others. sub SetLinks { # # Be sure that there is nothing defined. # &Undefine("TITLE_CURRENT"); &Undefine("TITLE_UP"); &Undefine("TITLE_NEXT"); &Undefine("TITLE_PREV"); &Undefine("LINK_UP"); &Undefine("LINK_NEXT"); &Undefine("LINK_PREV"); # # All links are relative to the root directory. # local ($pathToRoot) = &GetPathToRoot($pfile[$ii]); &Define("TITLE_CURRENT", $ptitle[$ii]); # # Go up one level. # my $up_file; $i = $ii - 1; while ($i >= 0 && $plevel[$i] >= $plevel[$ii]) { --$i; } if ($i >= 0 && $plevel[$i] < $plevel[$ii]) { if ( $pfile[$i] =~ /^\// ) { &Define("LINK_UP", &ChangeExtension("$pfile[$i]")); } else { &Define("LINK_UP", &ChangeExtension("$pathToRoot$pfile[$i]")); } &Define("TITLE_UP", $ptitle[$i]); $up_file = $pfile[$i]; } else { &Undefine("LINK_UP"); &Undefine("TITLE_UP"); } # # Previous document. # $i = $ii - 1; if ($i >= 0 && $pfile[$i] && $pfile[$i] ne $up_file) { if ( $pfile[$i] =~ /^\// ) { &Define("LINK_PREV", &ChangeExtension("$pfile[$i]")); } else { &Define("LINK_PREV", &ChangeExtension("$pathToRoot$pfile[$i]")); } &Define("TITLE_PREV", $ptitle[$i]); } else { &Undefine("LINK_PREV"); &Undefine("TITLE_PREV"); } # # Next document. # $i = $ii + 1; if ($pfile[$i]) { if ( $pfile[$i] =~ /^\// ) { &Define("LINK_NEXT", &ChangeExtension("$pfile[$i]")); } else { &Define("LINK_NEXT", &ChangeExtension("$pathToRoot$pfile[$i]")); } &Define("TITLE_NEXT", $ptitle[$i]); } else { &Undefine("LINK_NEXT"); &Undefine("TITLE_NEXT"); } } # ---------------------------------------------------------------------------- # Generate a complete SiteMap using predefined macros __TOC_x__, and # __TOC_x_ITEM__. Almost all ideas and code comes from , # and . sub GenSiteMap { $levelold = 0; $_ = ""; for ( $xx = 0; $xx <= $#pfile; ++$xx ) { $f = $pfile[$xx]; $f = &ChangeExtension($f); if($levelold < $plevel[$xx]) { $_ .= (" " x (($plevel[$xx]-1) * 2)) . $delim1."__TOC_".$plevel[$xx]."__(\'" . $delim1."__NEWLINE__".$delim2; $_ .= (" " x (($plevel[$xx]-1) * 2 + 2)) . $delim1."__TOC_".$plevel[$xx] . "_ITEM__(\'".$f."\'".$argsep."\'".$ptitle[$xx]."\')" . $delim2.$delim1."__NEWLINE__".$delim2; } if($levelold == $plevel[$xx]) { $_ .= (" " x (($plevel[$xx]-1) * 2 + 2)) . $delim1."__TOC_".$plevel[$xx] . "_ITEM__(\'".$f."\'".$argsep."\'".$ptitle[$xx]."\')" . $delim2.$delim1."__NEWLINE__".$delim2; } if ($levelold > $plevel[$xx]) { $_ .= (" " x ($plevel[$xx] * 2)) . "\')".$delim2.$delim1."__NEWLINE__".$delim2; $_ .= (" " x (($plevel[$xx]-1) * 2 + 2)) . $delim1."__TOC_".$plevel[$xx] . "_ITEM__(\'".$f."\'".$argsep."\'".$ptitle[$xx]."\')" . $delim2.$delim1."__NEWLINE__".$delim2; } $levelold = $plevel[$xx]; } for($xx = $levelold; $xx > 0; --$xx) { $_ .= (" " x (($plevel[$xx]-2) * 2)) . "\')".$delim2.$delim1."__NEWLINE__".$delim2; } &Substitute(); } # ---------------------------------------------------------------------------- # Returns the output name of a given source filename. sub ResolveOutputName { local ($file) = @_; $file = &ChangeExtension($file); $file = "$outputDir/$file" if ( $outputDir ne "" && $file !~ /^\// ); # # Make sure the directory exists for the output file. # $n = 0; while ( $n != ($[-1) ) { $n = index($file, "/", $n); $n = 1 if ( $n == 0 ); if ( $n != ($[-1) ) { $dir = substr($file, 0, $n); mkdir($dir, 0755) if ( ! -d $dir ); # from ++$n; } } return $file; } # ---------------------------------------------------------------------------- # Return 1 if a given string is a member of a given list 0 else. sub Member { local ($elt, @list) = @_; foreach $val (@list) { return 1 if ( $val eq $elt ); } return 0; } # ---------------------------------------------------------------------------- # What to do with a given source file. The level of the page in the document # may be given. sub ProcessSourceFile { local ($name, $parent, $level) = @_; local ($oname); @lines = (); %saveDefines = %defines; %saveCharacters = %characters; # # Process source files only if asked. # if ( defined(@fileToProcess) && ! (&Member($name, @fileToProcess)) ) { return; } &Notice("--- $name$level ---\n"); if ( ! -r $name ) { &Error("`$name' unreadable"); } else { $oname = &ResolveOutputName($name); &Define("ROOT_PATH", &GetPathToRoot($name)); &Define("BASENAME", &GetOutputBasename($oname)); &Define("FILENAME", "$baseName$extTarget"); &Define("PATHNAME", &GetPathname($name)); if ( $name eq $oname ) { &Error("source `$name' same as target `$oname'"); } else { $dependencies{$oname} .= "$parent $name"; push(@outputFiles, $oname); # # if FAST_GENERATION process files only if newer than output. # if ( !defined($defines{"FAST_GENERATION"}) || ((stat($name))[9] > (stat($oname))[9])) { &SetFileReferences(); &SetTimestamps($name); open(OUTFILE, ">$oname") if (!$generateMakefiles); &ProcessLines($name); close OUTFILE if (!$generateMakefiles); } else { &Warning("output more recent than input, nothing done"); } } } %defines = %saveDefines; %characters = %saveCharacters; } # ---------------------------------------------------------------------------- # Compresses all lines, removing all thing not necessary for a browser. sub CompressLines { local ($_) = join(' ', @lines); @lines = (); # # Translate tabs and linefeed into spaces. # tr/\t\n/ /; # # Discard all comments. # $del1 = ''; $len2 = length( $del2 ); while (1) { $p1 = index($_, $del1); $p2 = index($_, $del2); if ( $p1 >= 0 && $p2 >= 0 && $p2 > $p1 ) { substr($_, $p1, $p2-$p1+$len2) = ''; } else { last; } } # # Squeeze all multiple spaces. Terminate the compressed sequence by \n # tr/ / /s; if ( substr($_, length($_), 1) eq ' ' ) { chop; } return $_ . "\n"; } # ---------------------------------------------------------------------------- # Process lines of a source file. sub ProcessLines { local ($iname) = @_; local ($INFILE) = $filenum++; my @suppress = (0); my @wasTrue = (0); my @wasElse = (0); my $current = 0; my $ifLevel = 0; if ( ! -r $iname ) { &Error("`$iname' unreadable"); return; } open($INFILE, $iname); while ( &ReadLine($INFILE) ) { # # Allow GTML commands inside HTML comments. # if ( /.*$//; s/\s*-->.*$//; } # # Parse '#literal' command because if literal processing is ON, # we simply print the line and continue to the next line. # if ( /^#literal/ ) { chop; ( $dummy, $switch ) = split(/[ \t]+/, $_); if ( $switch =~ /^ON$/i ) { $literal = 1; } elsif ( $switch =~ /^OFF$/i ) { $literal = 0; } else { &Error("expecting \#literal as `ON' or `OFF'"); } next; } if ( $literal ) { if ( $compression ) { print(OUTFILE &CompressLines); } &Substitute(); print(OUTFILE $_); next; } # # Next parse the if(def)/elsif/else/endif to decide if we want to # suppress any lines. # # $ifLevel = current level of nested ifs. # $current = operative level of nested ifs. This is less than $ifLevel # when an outer 'if' condition is false. # @suppress = vector of suppression indicators at the different nesting levels. # @wasTrue = vector of indicators for whether at least one condition in a sequence # of if...elsif...elsif...else has already been true. In that case the rest of # the conditions in the sequence are ignored. # @wasElse = vector of indicators of whether an 'else' condition has already been # seen. # if ( /^#if/ || /^#elsif/ ) { chop; my ($wasIf, $match, $var, $condl, $comp, $value); if ( /^#if/ ) { $ifLevel += 1; $wasIf = 1; } else { s/^#els/#/; $wasIf = 0; } Substitute(); if ( /^#ifdef/ || /^#ifndef/ ) { ( $dummy, $var ) = split(/[ \t]+/, $_); $match = ( &GetValue($var) ne "" ); $match = ! $match if ( /^#ifndef/ ); } else { ( $condl, $var, $comp, $value ) = split(" ", $_, 4); if ( $comp eq "==" ) { $match = ( $var eq $value ); } elsif ( $comp eq "!=" ) { $match = ! ( $var eq $value ); } else { Error("unknown comparator `$comp'"); $match = 0; } } if ( $wasIf ) { push(@suppress, ! $match); push(@wasTrue, $match); push(@wasElse, 0); $current = $ifLevel if ( ! $suppress[$current] ); } else { if ( $ifLevel == 0 ) { $condl =~ s/^#/#els/; Error("$condl with no preceding #if"); } elsif ( $wasTrue[$ifLevel] ) { $suppress[$ifLevel] = 1; } else { $suppress[$ifLevel] = ! $match; $wasTrue[$ifLevel] = $match; } } next; } elsif ( /^#else/ ) { if ( $ifLevel == 0 ) { Error("#else with no preceding #if"); } elsif ( $wasElse[$ifLevel] ) { Error("multiple '#else's"); } else { $suppress[$ifLevel] = $wasTrue[$ifLevel]; $wasElse[$ifLevel] = 1; } next; } elsif ( /^#endif/ ) { if ( $ifLevel == 0 ) { Error("unmatched #endif"); } else { pop(@suppress); pop(@wasTrue); pop(@wasElse); $current-- if ( $current == $ifLevel ); $ifLevel--; } next; } # # Skip lines if current ignoring state says so. # next if ( $suppress[$current] ); # # Now do others commands. # if ( /^#entities/ ) { chop; ( $dummy, $switch ) = split(/[ \t]+/, $_); if ( $switch =~ /^ON$/i ) { $entities = 1; } elsif ( $switch =~ /^OFF$/i ) { $entities = 0; } else { &Error("expecting \#entities as `ON' or `OFF'"); } next; } # # Included files. # elsif ( /^#include/ ) { chop; if ( $compression ) { print(OUTFILE &CompressLines); } &Substitute(); s/^#include[ \t]*"//; s/".*$//; #" $file = $_; $file = &ResolveIncludeFile($file); $dependencies{$iname} .= "$file "; if ( $file ne "" ) { # TODO # &Notice(" --- $file\n"); &ProcessLines($file); } next; } # # Characters translation can be defined here. # if ( /^#definechar[ \t]/ ) { chop; ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); $characters{$key} = $value; } # # Macros can be defined here. # elsif ( /^#define[ \t]/ ) { chop; ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); if ( $key =~ /(.+)\((.+)\)/ ) { &Undefine($1); } ( $key, $value ) = &Markup($key, $value); &Define($key, $value); } elsif ( /^#newdefine[ \t]/ ) { chop; ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); if ( ! &GetValue($key) eq "" ) { next; } ( $key, $value ) = &Markup($key, $value); &Define($key, $value); } elsif ( /^#define\!/ ) { chop; &Substitute(); ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); if ( $key =~ /(.+)\((.+)\)/ ) { &Undefine($1); } ( $key, $value ) = &Markup($key, $value); &Define($key, $value); } elsif ( /^#newdefine!/ ) { chop; &Substitute(); ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); if ( ! &GetValue($key) eq "" ) { next; } ( $key, $value ) = &Markup($key, $value); &Define($key, $value); } elsif ( /^#define\+/ ) { chop; ( $dummy, $key, $value ) = split( /[ \t]+/, $_, 3 ); ( $key, $value ) = &Markup($key, $value); &Define($key, &GetValue($key) . $value); } elsif ( /^#undef[ \t]/ ) { chop; ( $dummy, $key ) = split ( /[ \t]+/, $_); &Undefine($key); } # # Saving bandwidth file compression eliminates anything not necessary # for correct display of content on the client browser. # elsif ( /^#compress/ ) { chop; ( $dummy, $switch ) = split(/[ \t]+/, $_); if ( $switch =~ /^ON$/i ) { $compression = 1; } elsif ( $switch =~ /^OFF$/i ) { print(OUTFILE &CompressLines) if ( $compression ); $compression = 0; } else { &Error("expecting \#compress as `ON' or `OFF'"); } } # # Table of contents can be used here. # elsif ( /^#toc/ || /^#sitemap/ ) { &GenSiteMap(); if ( $compression ) { push(@lines, $_); } else { print(OUTFILE $_); } } # # Timestamp format can be defined here. # elsif ( /^#timestamp[ \t]/ ) { chop; ( $dummy, $stamp ) = split(/[ \t]/, $_, 2); &SetTimestamps( $iname ); } elsif ( /^#mtimestamp[ \t]/ ) { chop; ( $dummy, $mstamp ) = split(/[ \t]/, $_, 2); &SetTimestamps( $iname ); } # # Normal lines. # elsif ( ! /^#/ ) { &Substitute(); if ( $compression ) { push(@lines, $_); } else { print(OUTFILE $_); } } } if ( $compression ) { print(OUTFILE &CompressLines); } close $INFILE; $filenum--; } # ---------------------------------------------------------------------------- # Generate a makefile from dependencies. sub GenerateMakefile { open(OUTFILE, ">$makefileName"); # # makefile basics. # print(OUTFILE "# GTML generated makefile, usable with GNU make.\n"); print(OUTFILE "\n"); print(OUTFILE "GTML = gtml\n"); print(OUTFILE "RM = rm\n"); print(OUTFILE "\n"); print(OUTFILE ".SUFFIXES: " . join(' ', @extProject) . ' ' . join(' ', @extSource) . ' ' . join(' ', @extensions)); print(OUTFILE "\n"); print(OUTFILE ".PHONY: clean\n"); print(OUTFILE "\n"); # # Generated files list. # print(OUTFILE "##############\n"); print(OUTFILE "# Files list #\n"); print(OUTFILE "##############\n"); print(OUTFILE "\n"); print (OUTFILE "OUTPUT_FILES = \\\n"); for ($i = 0; $i < $#outputFiles; $i++) { print(OUTFILE "\t$outputFiles[$i] \\\n"); } print(OUTFILE "\t$outputFiles[$#outputFiles]\n"); print(OUTFILE "\n"); # # Rules. # print(OUTFILE "#####################\n"); print(OUTFILE "# Processsing rules #\n"); print(OUTFILE "#####################\n"); print(OUTFILE "\n"); print(OUTFILE "all: \$(OUTPUT_FILES)\n"); print(OUTFILE "\n"); print(OUTFILE "clean:\n"); print(OUTFILE "\t-\$(RM) \$(OUTPUT_FILES)\n"); print(OUTFILE "\t-\$(RM) *~\n"); print(OUTFILE "\n"); $outputDir .= "/" if ( ! ($outputDir eq "") ); $outputDir =~ s/\/\//\//g; foreach $ext ( @extSource ) { foreach $ext2 ( @extensions ) { print(OUTFILE "$outputDir\%$ext2: \%$ext\n"); print(OUTFILE "\t\$(GTML) -F\$< \$(word 1, \$(word 2, \$^) \$<)\n"); print(OUTFILE "\n"); } } # # Dependencies. # print(OUTFILE "#####################\n"); print(OUTFILE "# File dependencies #\n"); print(OUTFILE "#####################\n"); print(OUTFILE "\n"); foreach $file ( keys(%dependencies) ) { $dependencies{$file} =~ s/^ //; print(OUTFILE "$file: $dependencies{$file}\n"); if ( ! &Member($file, @outputFiles) ) { print(OUTFILE "\ttouch \$\@\n"); } elsif ( ! ($file =~ /$extTarget$/) ) { print(OUTFILE "\t\$(GTML) -F\$(word 2, \$^) \$(word 1, \$^)\n"); } } print(OUTFILE "\n"); print(OUTFILE "# End of makefile.\n"); close(OUTFILE); } # ---------------------------------------------------------------------------- # Well you may ask why sometimes I add some stupid comments like #' or #", the # answer is simple: I use emacs, and color syntaxing with font-lock-mode and # when it does not find matching, i.e closing, " or ' it color the text as # string until a closing one, which is really not pleasant. Giving it what it # looks for is the simplest trick I found to correct that. # -Bruno # ---------------------------------------------------------------------------- gtml-3.5.4/CREDITS.html0000644000175000001440000001277710140452127015123 0ustar andrexusers00000000000000 GTML Credits
    <<   GTML Credits  

    I would like to thank some people who helped, and contributed in the development of GTML.

    First of all I'd like to thank Gihan Perera, who is the initial author of GTML, and who did a really great job, and who authorized me to take over GTML since it seems he does not have time to enhance it, and a more important thing, authorized me to distribute it under the GPL terms. He is the guy to thanks, the real author of GTML.

    Then I would like to thank people who helped me correct, or enhance GTML:

    • Magog, helped me fixed a bug on directory creation, sent me Swedish support, and helped me grow my TODO list ;-) ;
    • Philippe Marquet (aka PhM), gave me a very impressive list of features to add, with some advices on how to do it. Almost all of what he asked has been added, so far, as least makefile support, and sitemap generation. He also sent me some of bug reports.
    • Jens Bloch Helmers, sent me Norwegian support, a bug report on filename aliases, and an idea for my TODO list ;
    • Simone Piunno (aka Pioppo), sent me Italian support ;
    • Gert-Jan Brink, sent me Dutch support ;
    • Uwe Arzt, sent me German support, as well as the base of sitemap generation code ;
    • Harald Drangmeister, sent me bug reports, and asked me about the TITLE_CURRENT macro ;
    • Michael M Slusarz, sent me a patch to add embedded Perl code, which gave me the idea of the embedded system command ;
    • Wim Niemans Ri, sent me a lot of features that he added to his own GTML, from #define+ to extensions selections ideas, via warning and error reports ;
    • Ken Guest, asked me for the $ddth feature in timestamps, sent me irish support, asked me about a better report verbosity control, and corrected english in the web pages (which was a great idea, hope I did not introduce too new mistakes since :) ;
    • Andrew Greig, sent me the weekday patch, and corrected the $ddth english computation ;
    • Bob Ham, sent me bug report about warning report format ;
    • Frank Boehme, sent me bug report about compression.

    I hope I forgot nobody.

    Do not hesitate to correct me if needed, and to send bug reports, or documentation mistakes (from typo errors, to bad English construction) reports.

    This page has been accessed times since . << Revision history   Sitemap  

    GTML home page
    Last modification: 1999/9/12 at 19:13
    Copyright © 1996-1999 Gihan Perera  (gihan@pobox.com)
    Copyright © 1999 Bruno Beaufils  (beaufils@lifl.fr)
    Copyright © 2004 Andrew E. Schulman  (schulman@users.sourceforge.net)
    gtml-3.5.4/NEWS.html0000644000175000001440000002221410140452127014565 0ustar andrexusers00000000000000 GTML Revision history
    <<   GTML Revision history   >>

    1.0  8-Jun-1996
    • First release.
    1.01  14-Jun-1996
    • Added #newdefine.
    • Allow undefined constants.
    1.02  14-Jul-1996
    • Support path names in project file.
    1.03  1-Sep-1996
    • No quotation marks in #include file name is OK.
    • Allow ../ to higher levels than starting directory.
    2.0  24-Nov-1996
    • Added lots of new features.
    2.01  30-Nov-1996
    • Commands can be inside comments.
    • User-specified substitute delimiters.
    2.02  10-Feb-1997
    • Fixed #ifdef nesting. (Alan B. Chamberlin)
    2.1  23-Jul-1997
    • Allow subs in #include.
    • Don't downshift file names. (Suggestions from Mike Sendall).
    2.2  15-Aug-1997
    • "allsource" command in project file.
    2.21  2-Feb-1998
    • Simplified auto-generated navigation links.
    2.22  25-Jul-1998
    • Handles years past 2000.
    2.3  19-Feb-1999
    • Enhanced #define (Wim Niemans Ri).
    3.0  22-Jun-1999
    • Added mtimestamp.
    • Added usage of "LANGUAGE".
    • Added usage of "EXTENSION".
    • Added filename alias definitions.
    • Fixed a bug with links and subdir.
    • Fixed a bug with entities.
    3.1  1-Jul-1999
    • Added definitions of all environment variables.
    • Added substitution at definition time for OUTPUT_DIR, INCLUDE_PATH and EXTENSION.
    3.2  4-Jul-1999
    • Added usage of "FAST_GENERATION" to process only files which sources are newer than output.
    3.3  7-Jul-1999
    • Fixed a bug with directory creation, thanks to Magog.
    • Added undefined constants in project file, a PhM request.
    • Added the -F command line argument, to process only single file, enabling the use of make (On a suggestion from PhM).
    • Added the GNU -h, --help and --version command line arguments.
    3.31  7-Jul-1999
    • Added Norwegian language support.
    3.32  8-Jul-1999
    • Fixed a bug with filename aliases.
    • Added Italian and Swedish support.
    3.33  9-Jul-1999
    • Fixed a serious bug with filename aliases (thank's to Jens).
    3.34  10-Jul-1999
    • Added Dutch support.
    3.3.5  13-Jul-1999
    • Fixed another bug with filename aliases.
    3.3.6  14-Jul-1999
    • Added German support.
    3.5.0  2-Sep-1999
    • Fixed a lot of bugs, while rewritting the code.
    • Added makefile generation.
    • Enhanced timestamp support.
    • Added customizable sitemap generation.
    • Modified ouput file extension setting.
    • Added characters translation.
    • Added embedded Perl code possibility.
    • Added embedded shell command output possibility.
    • Documented output compression.
    • Updated documentation.
    • Added some new predefined constants.
    • Added macro with arguments.
    • Enhanced conditionals.
    • Enhanced inclusion in project files.
    • Enhanced timestamps support.
    3.5.1  2-Sep-1999
    • Fixed a bug with PATHNAME creation, and thus included file searching.
    3.5.2  8-Sep-1999
    • Fixed a bug with conditional output (if/elsif).
    • Added irish support.
    • Remove include file name report.
    • All documentations has been corrected thanks to Ken Guest.
    3.5.3  13-Sep-1999
    • Fixed a bug with compression.
    • Better $ddth (english) computation.
    • Exit status changed (0 for warnings and OK, 1 for errors).
    3.5.4  29-Oct-2004
    • Fixed several 'if'-related bugs:
      • In nested #if's, when the outer condition was false the first #endif would end the whole set of #if's.
      • #if true ... #elsif false ... #else would execute the #else clause.
      • There was no error checking for missing #if's, multiple #else's, or missing #endif's.
    • Macros in INCLUDE_PATH are now resolved.

    This page has been accessed times since . << Reference   Sitemap   Credits >>

    GTML home page
    Last modification: 2004/10/29 at 10:31
    Copyright © 1996-1999 Gihan Perera  (gihan@pobox.com)
    Copyright © 1999 Bruno Beaufils  (beaufils@lifl.fr)
    Copyright © 2004 Andrew E. Schulman  (schulman@users.sourceforge.net)
    gtml-3.5.4/README0000644000175000001440000002444010140454565014016 0ustar andrexusers00000000000000 GTML - an HTML pre-processor * Introduction * How does GTML work ? * Is GTML for you ? * GTML features. * Downloading GTML * Running GTML * Other HTML pre-processors * Terms of license * A little bit of GTML history _________________________________________________________________ HTML is a powerful markup language for individual Web pages, but it has some serious limitations for maintaining entire Web sites (i.e. a collection of Web pages which needs to be kept consistent). GTML is an HTML pre-processor which adds some extra features specially designed for maintaining multiple Web pages. How does it work? You embed GTML commands among the HTML in your source files. GTML reads and processes the GTML commands, but leaves the rest of the text unchanged (so it will work straight away on your existing Web pages). HTML files generated by GTML are just like any other HTML files. Because GTML doesn't attempt to interpret your HTML commands in any way, it's fully compatible with all versions of HTML, and doesn't require any specific browser or server. Is GTML for you? If you write the HTML in your Web pages by hand using a simple text editor, then you'll find GTML useful. If, on the other hand, you use a sophisticated graphical tool to generate your HTML, you probably won't be able to use GTML. There are three reasons for this: * Your sophisticated tool won't understand the GTML commands, and might even complain violently about them. * GTML operates in a command-line batch mode, and your sophisticated tool probably operates from a graphical environment. * The source for GTML is in files ending in .gtm (or .gtml), and it generates the .html files. Your sophisticated tool probably generates the .html files itself. Features Here are some of the things you can do with GTML: * Create a project file with the names of all your Web pages, so you can update them all with one simple click or command. * Process only files which sources have changed directly, or with the help of makefiles. * Generate a makefile to control the process of your Web pages, based on their dependencies. [** NEW **] * Give a specific alias to a filename, useable as constants, so that it is easy to move files and have links preserved. * Specify a tree-like hierarchy of Web pages, so you can add Next, Previous and Up links automatically to your site. * Automatically generate a map of your site, with the possibility of customizing the way this table of contents will look like. [** NEW **] * Use named constants for HTML fragments to save typing, ensure consistency and make changes easily. * Use environment variables as named constants. * Include header, footer and other common files into all your HTML files. This doesn't require Server-Side Includes. * Include timestamps (in any format you like) to show the time of last process, or of last modification. * Use conditional commands to create different versions of the output under different circumstances. * Generate output to different directories to generate different versions of your site (for example, a Frames version and a non-Frames version). * Change extensions of output files from .html to whatever you want, so that you may, for instance, use MultiViews options of Apache server, or create non-HTML files. [** NEW **] * Guard special characters `<', `>' and `&' in normal text so that they don't get confused with HTML commands. * Define your own characters translations, so that you may easily input your non-ASCII characters into GTML source. [** NEW **] * Embed Perl or shell code into your source, so that you may easily generate pages with computed information. [** NEW **] * Generate pages with all superfluous HTML code removed, so that readers retrieve them faster and may save bandwidth. [** NEW **] All the GTML features and commands are described on the GTML Reference page. Downloading GTML GTML is written in Perl. If you don't have Perl, it's easy to obtain it on perl.com. There are two methods to download GTML: * Download GTML Perl script, and save it to a file called gtml.pl. If you're running this under UNIX, edit the first line to point to the location of your version of Perl, and give the execute right to the file. * Download GTML archives containing Perl script as well as documentations. Archives are available in zip format or gzipped tar format. The home page of GTML is at http://sourceforge.net/projects/gtml/, and archives may be found at http://sourceforge.net/project/showfiles.php?group_id=100737. Running GTML GTML source files end in .gtm (or .gtml), not .html. If you're using GTML on existing HTML files, simply rename them with the ending .gtm (or .gtml). GTML is run from the command line, like this: perl gtml.pl fred.gtm harry.gtm bill.gtm (The UNIX version won't need the Perl at the front, so long as the script is executable.) The output of this command will be in fred.html, harry.html and bill.html. If you have a GTML project file, you include this on the command line. In this case, it's not necessary to list any of the files in the project as well. Remember that you can use -D on the command line to create named constants. You can have as many -D options as you like. Make sure they appear before the file names to which they apply. For example, if you say: perl gtml.pl -DNAME=Fred fred.gtm harry.gtm -DTYPE=car bill.gtm then NAME is defined for all three files and TYPE is defined for bill.gtm only. By default, GTML will try to process some project file. It will look at these configuration files in this order: * $HOME/.gtmlrc * $HOME/gtml.conf * .gtmlrc * gtml.conf Thoses files, if they exist, are parsed before command line is processed. You may have a look at the source of the documentation pages of GTML in the source directory. The project file is called gtml.gtp. Other HTML pre-processors Here is a list of other HTML pre-processors that I know of, in case GTML will not satisfy your needs: * Chpp * Frontier * Meta-HTML * PHP * QML * Webtools * WML * Wpp Licensing GTML is distributed under the GNU General Public License (GPL). Copyright © 1996-1999 Gihan Perera (gihan@pobox.com) Copyright © 1999 Bruno Beaufils (beaufils@lifl.fr) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Some history For a long time I was looking for a way of maintaining some of the sites that I set up for the research team which I am member of. I wanted to get a tool which would enable me to easily change the look and feel of all pages of a site, and easily move pages of a site from one location to another. I then used all my favourite search engines on the web, and found some pages, describing such tools. I tried some. They all missed something, from ease of use, to important features. When I tried GTML, from Gihan, I found it was pretty cool, but lacking some important features that I needed. I wrote to Gihan asking him to add those features which I needed, since I had no Perl programming skill. He told me that he doesn't have time to do that in the near future. So I decided to read his code, and to learn Perl with his script. The script was pretty well written and I learnt Perl, or at least understand how GTML worked very fast. It was then easy to add the features that I needed in it. I then asked Gihan if he would mind if I distribute GTML under the GNU General Public License, since his license policy was not as open as GPL, and he accepted. Then I just updated some of the docs, prepared an archive, in the GNU spirit, and that was it. My biggest question was to understand where the name of the tool come from, and after some reflexions I got two possible answers: * `G' is the letter just before H, and GTML source production comes just before HTML file one. * `G' is the first letter of Gihan's first name. Well this is not a question anymore, Gihan told me the truth. Guess what? I found it: the first of my two previous hypotheses is the right one. (Well I hope that as time goes by it will be interpreted as GNU :-) After I distributed it on my web pages, and after announcing it only on Freshmeat, I got some feedback from users coming from all around the world. I added some features which were asked of me, but realized that the source of the script needed some reorganization, and that there were some bugs in GTML. I have done this source reorganization, and so have been able to fix bugs, and add a lot of fancy features. So now I'm waiting for users' feedback, in order to verify that I did not add bugs :-), and that GTML is now sufficiently stable. In one month or so I hope to be able to say that it does. So I really need your help for that, please give me some feedback!. I will not add any features, before the next stable release. I hope my version of GTML will help you as it helps me. --Bruno, 31 August 1999 Sitemap Reference >> ______________________________________________________________________ Last modification: 1999/9/13 at 01:44 Copyright © 1996-1999 Gihan Perera (gihan@pobox.com) Copyright © 1999 Bruno Beaufils (beaufils@lifl.fr) gtml-3.5.4/index.html0000777000175000001440000000000010140455247016753 2gtml.htmlustar andrexusers00000000000000gtml-3.5.4/gtml.html0000644000175000001440000003774010140452127014766 0ustar andrexusers00000000000000 GTML - an HTML pre-processor
      GTML - an HTML pre-processor   >>


    HTML is a powerful markup language for individual Web pages, but it has some serious limitations for maintaining entire Web sites (i.e. a collection of Web pages which needs to be kept consistent).

    GTML is an HTML pre-processor which adds some extra features specially designed for maintaining multiple Web pages.

    How does it work?

    You embed GTML commands among the HTML in your source files. GTML reads and processes the GTML commands, but leaves the rest of the text unchanged (so it will work straight away on your existing Web pages).

    HTML files generated by GTML are just like any other HTML files. Because GTML doesn't attempt to interpret your HTML commands in any way, it's fully compatible with all versions of HTML, and doesn't require any specific browser or server.

    Is GTML for you?

    If you write the HTML in your Web pages by hand using a simple text editor, then you'll find GTML useful. If, on the other hand, you use a sophisticated graphical tool to generate your HTML, you probably won't be able to use GTML. There are three reasons for this:

    • Your sophisticated tool won't understand the GTML commands, and might even complain violently about them.
    • GTML operates in a command-line batch mode, and your sophisticated tool probably operates from a graphical environment.
    • The source for GTML is in files ending in .gtm (or .gtml), and it generates the .html files. Your sophisticated tool probably generates the .html files itself.

    Features

    Here are some of the things you can do with GTML:

    • Create a project file with the names of all your Web pages, so you can update them all with one simple click or command.
    • Process only files which sources have changed directly, or with the help of makefiles.
    • Generate a makefile to control the process of your Web pages, based on their dependencies. [** NEW **]
    • Give a specific alias to a filename, useable as constants, so that it is easy to move files and have links preserved.
    • Specify a tree-like hierarchy of Web pages, so you can add Next, Previous and Up links automatically to your site.
    • Automatically generate a map of your site, with the possibility of customizing the way this table of contents will look like. [** NEW **]
    • Use named constants for HTML fragments to save typing, ensure consistency and make changes easily.
    • Use environment variables as named constants.
    • Include header, footer and other common files into all your HTML files. This doesn't require Server-Side Includes.
    • Include timestamps (in any format you like) to show the time of last process, or of last modification.
    • Use conditional commands to create different versions of the output under different circumstances.
    • Generate output to different directories to generate different versions of your site (for example, a Frames version and a non-Frames version).
    • Change extensions of output files from .html to whatever you want, so that you may, for instance, use MultiViews options of Apache server, or create non-HTML files. [** NEW **]
    • Guard special characters `<', `>' and `&' in normal text so that they don't get confused with HTML commands.
    • Define your own characters translations, so that you may easily input your non-ASCII characters into GTML source. [** NEW **]
    • Embed Perl or shell code into your source, so that you may easily generate pages with computed information. [** NEW **]
    • Generate pages with all superfluous HTML code removed, so that readers retrieve them faster and may save bandwidth. [** NEW **]

    All the GTML features and commands are described on the GTML Reference page.

    Downloading GTML

    GTML is written in Perl. If you don't have Perl, it's easy to obtain it on perl.com.

    There are two methods to download GTML:

    • Download GTML Perl script, and save it to a file called gtml.pl. If you're running this under UNIX, edit the first line to point to the location of your version of Perl, and give the execute right to the file.
    • Download GTML archives containing Perl script as well as documentations. Archives are available in zip format or gzipped tar format.

    The home page of GTML is at http://sourceforge.net/projects/gtml/, and archives may be found at ftp://ftp.lifl.fr/pub/users/beaufils/gtml/.

    Running GTML

    GTML source files end in .gtm (or .gtml), not .html. If you're using GTML on existing HTML files, simply rename them with the ending .gtm (or .gtml).

    GTML is run from the command line, like this:

         perl gtml.pl fred.gtm harry.gtm bill.gtm
    

    (The UNIX version won't need the Perl at the front, so long as the script is executable.)

    The output of this command will be in fred.html, harry.html and bill.html.

    If you have a GTML project file, you include this on the command line. In this case, it's not necessary to list any of the files in the project as well.

    Remember that you can use -D on the command line to create named constants. You can have as many -D options as you like. Make sure they appear before the file names to which they apply. For example, if you say:

         perl gtml.pl -DNAME=Fred fred.gtm harry.gtm -DTYPE=car bill.gtm
    
    then NAME is defined for all three files and TYPE is defined for bill.gtm only.

    By default, GTML will try to process some project file. It will look at these configuration files in this order:

    • $HOME/.gtmlrc
    • $HOME/gtml.conf
    • .gtmlrc
    • gtml.conf

    Thoses files, if they exist, are parsed before command line is processed.

    You may have a look at the source of the documentation pages of GTML in the source directory. The project file is called gtml.gtp.

    Other HTML pre-processors

    Here is a list of other HTML pre-processors that I know of, in case GTML will not satisfy your needs:

    Licensing

    GTML is distributed under the GNU General Public License (GPL).

    Copyright © 1996-1999 Gihan Perera (gihan@pobox.com)

    Copyright © 1999 Bruno Beaufils (beaufils@lifl.fr)

    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    Some history

    For a long time I was looking for a way of maintaining some of the sites that I set up for the research team which I am member of. I wanted to get a tool which would enable me to easily change the look and feel of all pages of a site, and easily move pages of a site from one location to another.

    I then used all my favourite search engines on the web, and found some pages, describing such tools. I tried some. They all missed something, from ease of use, to important features. When I tried GTML, from Gihan, I found it was pretty cool, but lacking some important features that I needed.

    I wrote to Gihan asking him to add those features which I needed, since I had no Perl programming skill. He told me that he doesn't have time to do that in the near future. So I decided to read his code, and to learn Perl with his script.

    The script was pretty well written and I learnt Perl, or at least understand how GTML worked very fast. It was then easy to add the features that I needed in it. I then asked Gihan if he would mind if I distribute GTML under the GNU General Public License, since his license policy was not as open as GPL, and he accepted.

    Then I just updated some of the docs, prepared an archive, in the GNU spirit, and that was it.

    My biggest question was to understand where the name of the tool come from, and after some reflexions I got two possible answers:

    • `G' is the letter just before H, and GTML source production comes just before HTML file one.
    • `G' is the first letter of Gihan's first name.

    Well this is not a question anymore, Gihan told me the truth. Guess what? I found it: the first of my two previous hypotheses is the right one. (Well I hope that as time goes by it will be interpreted as GNU :-)

    After I distributed it on my web pages, and after announcing it only on Freshmeat, I got some feedback from users coming from all around the world. I added some features which were asked of me, but realized that the source of the script needed some reorganization, and that there were some bugs in GTML.

    I have done this source reorganization, and so have been able to fix bugs, and add a lot of fancy features. So now I'm waiting for users' feedback, in order to verify that I did not add bugs :-), and that GTML is now sufficiently stable.

    In one month or so I hope to be able to say that it does. So I really need your help for that, please give me some feedback!.

    I will not add any features, before the next stable release.

    I hope my version of GTML will help you as it helps me.

    --Bruno, 31 August 1999

    This page has been accessed times since .   Sitemap   Reference >>

    GTML home page
    Last modification: 1999/9/12 at 19:44
    Copyright © 1996-1999 Gihan Perera  (gihan@pobox.com)
    Copyright © 1999 Bruno Beaufils  (beaufils@lifl.fr)
    Copyright © 2004 Andrew E. Schulman  (schulman@users.sourceforge.net)
    gtml-3.5.4/new.gif0000644000175000001440000000026006736021215014406 0ustar andrexusers00000000000000GIF89a ³ÿÿÿÿÿþþýý*ûû4ÿÿÿ!ù, @]°È) µ´‘»ÜŒ¢aŠ!9nÞ$˜*ªŽ)×n`€¯;Ûž & LÀàçç°˜­Œ€ð¤Ú~,MTH+R]]²óJy‡ÆPö6Óf¢5¹'îÙqQм0Ž ;gtml-3.5.4/sitemap.html0000644000175000001440000000621310140452126015453 0ustar andrexusers00000000000000 GTML sitemap
      GTML sitemap  
    This page has been accessed times since .   Sitemap  

    GTML home page
    Last modification: 1999/9/1 at 22:17
    Copyright © 1996-1999 Gihan Perera  (gihan@pobox.com)
    Copyright © 1999 Bruno Beaufils  (beaufils@lifl.fr)
    Copyright © 2004 Andrew E. Schulman  (schulman@users.sourceforge.net)
    gtml-3.5.4/gtml_ref.html0000644000175000001440000011627210140452127015620 0ustar andrexusers00000000000000 GTML Reference Page
    <<   GTML Reference Page   >>

    This is the reference page for the HTML pre-processor GTML. It describes all the GTML features and commands in detail. For more information about getting GTML, see the main GTML page.

    GTML features fall into four main areas, and we'll look at them in this order:

    Commands

    The original syntax of GTML was stolen shamelessly from the C language pre-processor, and has been adapted to suit Web site management. It supports the following commands:

    Command syntax

    There are two ways of writing commands:

    • You can insert the commands directly, in which case they are preceded by `#', and must appear at the start of a separate line (no preceeding spaces). Here's an example:
      #include "header.txt"
      
    • The other method is to embed the command inside an HTML comment. In this case, the line must begin with `<!-- ###' followed by the command name, followed by the close-comment tag `-->'. Here's the same example in this format:
      <!-- ###include "header.txt" -->
      

    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 about GTML commands, you can use the second method to hide the GTML commands from the tool.

    #include

    If 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"
    

    GTML replaces this line with the entire contents of the file common.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.

    #define

    This 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 GTML to 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 values
      The value of a named constant can itself contain other named constants, like this:
      #define MAILTO <a href="mailto:<<MY_EMAIL>>">
      

      GTML will 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 names
      If 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 values
      If 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 values
      If a named constant is not defined before it's used, its value is a blank string.
    • Re-defining values
      It's perfectly OK to have more than one #define for the same named constant. You can use this to change the value of a named constant part-way through the processing.
    • Pre-defined values
      GTML creates some named constants for you automatically, such as the file name and links to the previous and next files.
    • Variables values
      Sometimes the frequently-used text you want to shorthand may embed some variable pieces. GTML allows 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 values
      If 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.

    #newdefine

    This 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.

    #undef

    Use 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, #endif

    These commands are used together for conditional output:

    • #if <<FRED>> == foo
      Process 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 FRED
      Process the following lines only if the named constant FRED is defined.
    • #ifndef FRED
      Process the following lines only if the named constant FRED is not defined.
    • #elsif <<FRED>> == foo
      If previous lines were not processed, then process the following lines only if after substitution, the left and right values are equal.
    • #elsif <<FRED>> != foo
      If previous lines were not processed, then process the following lines only if after substitution, the left and right values are different.
    • #elsifdef FRED
      If previous lines were not processed, then process the following lines only if the named constant FRED is defined.
    • #elsifndef FRED
      If previous lines were not processed, then process the following lines only if the named constant FRED is not defined.
    • #else
      The opposite effect of the most recent matching #if, #ifdef, #ifndef, #elsif, #elsifdef or #elsifndef.
    • #endif
      End a block of conditional output. Every #if, #ifdef or #ifndef must have a matching #endif

    Conditional blocks can be nested.

    #timestamp

    The special named constant TIMESTAMP evaluates to the current date and time. But to use it, you must tell GTML what format to use to print the date/time.

    The format string is specified in the #timestamp statement 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.

    #mtimestamp

    This is identical to timestamp, except that the time used is not the current one, but the time the file was last modified.

    #literal

    The command #literal ON tells GTML to stop interpreting lines beginning with `#' as GTML commands, until the next #literal OFF line. 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 `#'.

    #entities

    The command #entities ON tells GTML to convert the characters `<', `>' and `&' into HTML entities so they aren't treated as part of HTML commands. Use #entities OFF to turn off this conversion.

    This is useful for bracketing blocks of program code, which often contain these characters.

    #definechar

    Basic HTML authorized characters may only be ASCII characters. Accentuated characters are coded in HTML in a certain way. For instance the `é' character is coded `&eacute;'. 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 #definechar command, like in this example:

    #definechar é &eacute;
    

    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 #definechar command:

    #definechar ss &szlig;
    

    #compress

    The command #compress ON tells GTML to 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, #toc

    When 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.

    GTML project files

    Because GTML is most useful for managing multiple files, it's quite common to change something in a #include'd file, and then run GTML on all the `.gtm' files which use it.

    To make this procedure easier, GTML supports a concept of a project file. This is a simple text file with the extension `.gtp'. It can contain:

    • define ...
      As for #define in a source file.
    • define! ...
      As for #define! in a source file.
    • define+ ...
      As for #define+ in a source file.
    • newdefine ...
      As for #newdefine in a source file.
    • newdefine! ...
      As for #newdefine! in a source file.
    • undef ...
      As for #undef in a source file.
    • timestamp ...
      As for #timestamp in a source file.
    • mtimestamp ...
      As for #mtimestamp in a source file.
    • if ...
      ifdef ...
      ifndef ...
      elsif ...
      elsifdef ...
      elsifndef ...
      else
      endif
      As for #if, #ifdef, #ifndef, #elsif, #elsifdef, #elsifndef, #else, #endif in 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.
    • allsource
      This is a shorthand way of specifying all source files from the current directory and sub-directories (recursively).
    • filename alias file
      This 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. GTML will compute the right relative path to the file in each source file. This way you may move your files wherever you want, GTML will be able to recreate your pages without having to modify the source files.
    • filename.gtm
      All other lines are names of source files, which are processed by GTML in 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).

    • hierarchy
      This 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 GTML with the project file as a command-line argument, it will process all the source files in the project file. They will all inherit the define, definechar and timestamp values, if any, in the project file. The mtimestamp value 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, #newdefine and #undef commands 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 hierarchy

    GTML allows 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 - GTML generates only those that apply to each page.

    Describing the hierarchy

    You describe the document hierarchy to GTML by 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 GTML processes a file, it defines special named constants which can be used in exactly the same way as other named constants.

    For each file, GTML generates 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.

    Example

    Here's an extract from a hypothetical GTML project 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.gtm will have LINK_NEXT set to sec22.html (and TITLE_NEXT set to Recent Findings) and LINK_UP set to chapter2.html (and TITLE_UP set to Historical Evidence). LINK_PREV and TITLE_PREV will be undefined.

    Using the links

    The 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 #include it into each GTML source file. The GTML #ifdef command 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 contents

    When you have described a document hierarchy, and you use a #toc or #sitemap command into your source file, GTML includes 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 definitions

    Environment

    All environment variables are defined as named constants by GTML.

    Current file names

    The 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 files

    GTML always searches for include files in the directory of the processed source file first, then the current directory (where the GTML command is executed).

    In addition, if you define the named constant INCLUDE_PATH, GTML will 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 directory

    By default, GTML writes 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. GTML will create the same directory hierarchy for the output files as for the input files (It creates sub-directories as required).

    Output suffix

    By 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 in gtml.css.

    Fast generation

    GTML only 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 way make works.

    To enable this feature you just have to define the special constant FAST_GENERATION. The use of this constant will work only in GTML project 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 make tool in conjunction with the `-F' and `-M' command line arguments.

    Language localisation

    By 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:

    • fr for French ;
    • de for German ;
    • ie for Irish ;
    • it for Italian ;
    • nl for Dutch ;
    • no for Norvegian ;
    • se for 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 delimiters

    The 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 links

    As described above, GTML defines several named constants for links between documents.

    Embedded Perl code

    You may embed Perl code into your GTML source 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 code

    You may embed system command output into your GTML source 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

    -D

    When you run GTML from 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.

    -F

    When you run GTML from 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 with make for page regeneration based on complex files dependencies (induced by #include commands).

    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.html file your command line will be:

    perl gtml -Fbar.gtm foo.gtp
    

    List of files to processed is cleared after each project file treatment.

    -M

    When you run GTML with the `-M' command line argument, GTML process project and source files, but do not produce ouput files. GTML generates a makefile ready to create output files.

    If you do not specify a filename, the generated makefile is created under the GNUmakefile name.

    To specify a filename, just add it after the `-M' argument, with a colon between the option and the file name.

    -h, --help

    To get a small command line usage description you can use the `-h', or `--help' command line argument.

    --silent

    If you specify the `--silent' command line argument, GTML will produce no processing information during its work.

    --version

    To get the version number of the GTML you are currently using you can use the `--version' command line argument.

    This page has been accessed times since . << Home   Sitemap   Revision history >>

    GTML home page
    Last modification: 1999/9/12 at 18:59
    Copyright © 1996-1999 Gihan Perera  (gihan@pobox.com)
    Copyright © 1999 Bruno Beaufils  (beaufils@lifl.fr)
    Copyright © 2004 Andrew E. Schulman  (schulman@users.sourceforge.net)
    gtml-3.5.4/gtml.css0000644000175000001440000000127310140452126014601 0ustar andrexusers00000000000000/* $Id: gtml.css..gtm,v 1.1 1999/09/02 02:17:01 beaufils Exp $ */ /* Style for GTML documentation. */ /* I do not use them as far as I want until Netscape is so bugged. Nobody will be able to render the pages properly. :-((( */ BODY { background : #ffffff; color : #000033; } A:link, A:visited { font-weight : bold; color : #990000; text-decoration : none; } H2 { font-family : sans-serif; background : #ffffcc; color : #000066; width : 100%; padding : 5; border : thin; font-size : large; } H3 { font-family : sans-serif; color : #000066; } H4 { font-family : sans-serif; color : #000066; } /* Local Variables: */ /* mode: html-helper-mode */ /* End: */ gtml-3.5.4/COPYING0000644000175000001440000004440706734056344014205 0ustar andrexusers00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.