mem4 - The HTML Macro Processor
mem4 processes macros embedded in HTML files.
SYNOPSIS
java mem4 filename > outfile
DESCRIPTION
mem4 is the HTML Macro Processor written in the Java language.
The filename argument is the name of a file that contains
special mem4 macro directives embedded within HTML.
By default mem4 writes its output to the standard output stream.
To cause mem4 to write an output file instead, redirect its output to a file.
Although mem4 doesn't require it, your input files should have a .mem4 filename
extenstion, and your output files should have a .html filename extension.
MACROS
Defining a Variable
mem4 let's you define and use variables.
To define a variable:
#define VARIABLE value
When defining a variable:
-
#define must appear as the very first thing on a line
-
VARIABLE is a string of any length that contains only alphanumeric characters
-
value is everything else on the line, trimmed of leading and
trailing whitespace.
-
#define is separated from VARIABLE with a space and
VARIABLE is separated from value with a space
Using a Variable Definition
To use a variable:
$VARIABLE
You can use a variable
-
in the value of any definition that occurs after the variable
has been defined.
For example:
#define PATH /some/thing/blah/blah
#define FILE $PATH/filename
defines
PATH = /some/thing/blah/blah
FILE = /some/thing/blah/blah/filename
-
anywhere on a line. For example:
create a directory named $PATH
yields
create a directory named /some/thing/blah/blah
Note: you can redefine a variable simply by defining it again.
Note: if you really want the string $VARIABLE to be in the result
use '\' to escape the variable name. For example:
$\VARIABLE yields $VARIABLE in the output.
Note: if you reference a variable that has not been defined
the variable name is used as its value. For example, if VARIABLE
had not been defined, $VARIABLE would yield VARIABLE
in the output.
Note: you can't concatenate the value of a variable
with regular text. For example, if you use $VARIABLEsometext
mem4 will actually look up VARIABLEsometext in its dictionary,
rather than concatenate the value of VARIABLE and the following text.
In other words the variable name must be followed by
a non-alphanumeric character that separates it from
whatever follows it.
Including Files
mem4 let's you include the contents of other files.
To include a file:
#include filename
When including files:
-
#include must appear as the very first thing on a line.
-
filename is everything else on the line, trimmed of leading and
trailing whitespace.
-
#include is separated from filename with a space.
-
the included file can use variables defined within the current file
and can add definitions to the current dictionary.
-
the filename is either an absolute path, or relative to the
current directory.
BUGS
Need to allow users to concatenate a variable with regular text.
One possibility is to use the '\' character to separate
the variable name from the text, so that:
$VARIABLE\sometext yields valuesometext.
STAY TUNED FOR
#include features
Ability to extract lines from an included file.
Ability to make certain lines from an include file bold.
Ability to make certain lines from an include file italic.
#undefine features
Ability to undefine variables.