FlexHTML - Flexible HTML generation

(C) 2000, 2001 David Rushall


Contents

1 What is FlexHTML?

FlexHTML is a simple OPM to process text files and apply template macros. As a file is processed, special template commands invoke user-written OPL functions to generate a block of output.

It was originally designed to aid the development and maintenance of my web site, where the OPL templates are used to:

All this is from source held in OPL Program editor files for convenience of editing. When the time comes to give the site a new look or a new page is needed on the navigation bars, some changes to the OPL templates can be easily propagated to all pages on the site.

With a little work the module could be applied to other scenarios, such as extracting a database of bookmarks to form an HTML links page or generating both an HTML and Help/Data version of an application's user manual from a single source. Advanced HTML applications can also employ temporary outputs and multiple passes to build a table of contents of automatically numbered sections or float footnotes to the end of the document.

Using FlexHTML requires some effort, basic knowledge of OPL and knowledge of HTML (and any other desired output formats). However, the result is a far more flexible than other HTML generation tools for the EPOC platform and it is easier than editing all your complex but repetitive HTML tagging by hand.

1.1 How does FlexHTML fit with CSS?

You might say that Cascading Style Sheets (CSS) are the best way to control the presentation of HTML documents - and you'd be right! So, if all the presentation information is in the CSS then why do you need a tool to help write the HTML?

A tool like FlexHTML is a compliment and not a competitor to CSS.

1.2 So what's new?

Version 1.2
Text encoding table; Flag to only build if source changed; Source-less, single template files.
Version 1.11
First public release; Minor tweaks.
Version 1.1
Fully recursive include source support.
Version 1.0
Initial version: OPL-based template support from single source files.

2 Installation

To install this software on your machine, just install the main application SIS file:

FlexHTML.sis

The software will be installed on the C: drive, only:

C:\System\OPM\FlexHTML.opm
The FlexHTML OPM module.
C:\System\OPL\FlexHTML.oph
The FlexHTML OPL header file.
C:\System\OPM\FlexHTML.tab
The default FlexHTML text encoding table.
C:\FlexHTML\*
This directory contains example files and this documentation for developers. You may move this folder but you will have to update the examples accordingly, if you wish to use them.

You can test the FlexHTML installation by running the C:\FlexHTML\Runme.opo example file. See below for more details.

Note: Please consult the manuals for your device for details of installing applications packaged in SIS files. You will require a PC or Mac running your EPOC connect software (i.e. PsiWin 2 or equivalent) or the "Add/Remove" icon on the control panel of your EPOC device. Double-clicking on the SIS file either on the EPOC device or on the PC/Mac connected to the EPOC device should do the trick.


3 Getting started

3.1 What is a FlexHTML template?

A FlexHTML template consists of an OPL procedure which is invoked when the FlexHTML processor finds a template invocation in the source file it is processing. The OPL function is responsible for generating any output that will replace the template call in the output file, accessing any global state variables it may require.

Consider the following simple example:

 proc hello$:
   lprint "Hello ";flexGetArg$:(1);"!"
 endp

This template, hello, writes a single line to the output stream; a greeting to the person named by the templates first argument.

To invoke the template, one would include something like the following in the input file:

 ##+hello
 World
 ##-

This would be replaced in the output, by:

 Hello World!

That's pretty much it! Simple but effective, as we shall see...

3.2 Putting it together

In order to use FlexHTML you will need the following:

  • One FlexHTML OPM module (FlexHTML.opm).
  • One FlexHTML OPM header file (FlexHTML.oph).
  • One set of OPL template procedures (e.g. Runme.opl).
  • One controlling OPL procedure (e.g. "build:" in Runme.opl).
  • One or more source files (e.g. Readme.flx).

Mix as follows:

  1. Put your source files in a suitable directory (use C:\FlexHTML\ for now).
  2. Edit the controlling procedure (e.g. "build:" in Runme.opl) to ensure that the path is correct for:
    • The INCLUDE of the FlexHTML.oph header file.
    • The LOADM of the FlexHTML.opm module.
    • Any LOADM for template libraries (not required for Runme.opl example).
    • The source file(s).
    • The output file(s).
  3. Translate and run the program.

If all goes well, an HTML version of the document will have been generated.

The remaining sections of this manual show how it all works. Look at the Runme.opl and Readme.flx files to get some ideas about what you can do.

Note: My use of the ".flx" extension is arbitrary. You may use any file name extension that you wish (e.g. ".txt" or none)

3.3 Source formats

The input to FlexHTML must either be a ASCII text file or an OPL Program source file. In the case of the latter, we're simply misusing the OPL editor as a convenient text editor; removing the requirement for you to export from Word or Program as plain text, or find another text editor.

The input file contains a mixture of text to be copied to the output file and template invocations. When the file is processed, the simple input is copied to the output (unchanged, unless an encoding table is selected) but any template invocations are replaced with their output.

Note: If you wish, the input file may consist entirely of templates. All that would remain of the input file in the output stream would be any blank lines you left between the templates.

Note: You can also use FlexHTML to export OPL Program files to plain text in batches. If the Program file contains no templates the the output will be a simple plain text version of the input.

3.4 FlexHTML template syntax

FlexHTML uses a simple syntax for templates. Any line starting with '##' (i.e. no preceding white space) is a control line, and anything else is pretty much ignored.

The character immediately following the '##' indicates the type of control line.

+ ##+hello
Begin a new template argument. If this the first argument of the template, then the template name follows the '+'.
- ##-
End the last argument of the template.
! ##!footer
Call template without providing arguments (i.e. a short-hand for '##+footer' followed by '##-').
; ##; Comment text
A comment line - the remaining text on the line is ignored and no output is generated. You can also use the ";" character to insert a comment at the end of a control line (e.g. "##+hello ;say hello").

3.5 Writing the control procedure

The main procedure of the control program is responsible for:

  • Defining and initialising any global variables that will be used by the user-written templates (e.g. section counters).
  • LOADMing the FlexHTML.opo module.
  • Checking that the loaded FlexHTML.opo is compatible.
  • LOADMing any template libraries required (when the templates are not contained in the same OPO as the control procedure).
  • Processing one or more input files.

The following functions are provided by FlexHTML.opo for this purpose.

flexVerChk: flexVerChk:(kFlexVersion)
Ensure loaded FlexHTML OPM is compatible with the version required (i.e. the version of the header against which the user-written code has been translated). The constant, kFlexVersion, is provided for this purpose. The function only returns if the OPM is compatible. Otherwise, an error is reported and execution is terminated.
flex: flex:("c:\example.flx", "c:\", "example.htm", kFlexFlags_None&)
Process named file to produce named output on named output path. See below for more information about the arguments to this function.

Note: My use of the ".flx" extension is arbitrary. You may use any file name extension that you wish (e.g. ".txt" or none)

3.6 Using the flex: function

The flex: function is used in the control procedure to direct the generation of one output file. The function has four parameters, as outlined below.

inputSpec$ "c:\example.flx"
Normally, this is absolute path of the input file containing the source for this output. Alternatively, this input specification may be the name of a template, prefixed by "##!", which will be called with empty arguments. For example, the input specification "##!doall" would be equivalent to an input file containing the single line, "##!doall".
outputPath$ "c:\"
The absolute path of the folder in which the output files are to be generated. If output files are to be generated in subdirectories, this is the top directory of the output.
outputFile$ "example.htm"
The name of the output file, relative to the output path. You may include a folder name if the output file is in a subdirectory (using the "\" separator). The value of this parameter can be retrieved within a template implementation, using the flexOutFile$: function.
flags& kFlexFlags_None&
The flags& parameter modifies the behaviour of the flex: processing. Constants for the following flags are included in FlexHTML.oph and they may be ORed together in multiple options are required.
kFlexFlags_None&
No special options required.
kFlexFlags_SourceNewer&
Compare the date stamps of the input and output files and only generate the output if the input file has been updated since the output was last written. If the output file does not already exist or if the input specification is the name of a template (i.e. not a file), the output will be generated.

Note: My use of the ".flx" extension is arbitrary. You may use any file name extension that you wish (e.g. ".txt" or none)


4 Writing template functions

4.1 Template basics

For each template used in the source file, you must provide an OPL procedure for the template. The name of the procedure must be the template name with a '$' suffix (i.e. return a string) and it must have no arguments.

Note: Please do not start template names with the letters 'flex'.

To generate the template's output, simply LPRINT whatever you want. Your LPRINTed text will appear in the output stream where the template invocation appeared in the input stream.

The return string of a template is any error message. If the template is sucessful, you should return an empty string. If a non-empty error message is returned, FlexHTML will display an error report including your message.

Note: You can pass information between templates (e.g. section counters) via OPL global variables, which must be declared by your control program and which must not start with the letters 'flex'.

4.2 Using template arguments

Templates are most useful when they are given arguments. Templates may have up to 8 (kMaxArgs%) arguments of up to 8192 (kMaxArgLength%) characters each. The constants for these values are provided in FlexHTML.oph. Any arguments not supplied in the template invocation in the source file will be empty (i.e. have zero length).

Arguments are numbered from 1 to 8 and can be retrieved by the following functions.

flexArgLen%: flexArgLen%:(arg%)
Returns the length of the numbered argument.
flexGetArg$: flexGetArg$:(arg%)
Returns the contents of the numbered argument, as a string. The argument must be no more than 255 characters in length, in order to fit into an OPL string.
flexInsertArg: flexInsertArg:(arg%)
Copy the numbered argument into the output stream, with no changes. The argument may be of any length (up to the maximum length of 8192 characters) as it does not have to be stored in an OPL string.
flexInsertEncodedArg: flexInsertEncodedArg:(arg%,table$)
Copy the numbered argument into the output stream, using the named text encoding table. The argument may be of any length (up to the maximum length of 8192 characters) as it does not have to be stored in an OPL string.

Note: With the exception of "flexInsertEncodedArg:", all these argument retrieval functions return the values exactly as specified in the template invocation, with no text encoding table applied.

4.3 Embedding further source files

FlexHTML includes the ability to combine multiple source files to form a single output, thus enabling common features such as scripts and navigation areas to be maintained from a single source and embedded on every page.

The processing of embedded inputs is truly recursive; templates in the embedded source will be processed and may embed still further sources, as required.

flexInclude: flexInclude:(includeFileName$)
Process named file and insert output into current output stream.

Note: If you want to declare a global variable to be available for the processing of the single embedded source, declare the global in the OPL procedure that calls the flexInclude: function.

Note: All text encoding table settings active at the point of the include will be inherited by the included file. In addition, any changes to these settings made during the processing of the file will persist and be applied to the remainder of the original file, following the include.

4.4 Other template functions

In addition to the basic functions for processing files and handling template arguments, FlexHTML provides a number of utility functions. These are summarised, below.

flexVer$: flexVer$:
Returns a version string identifing FlexHTML, suitable for inclusion in an HTTP GENERATOR header.
flexInsertBoilerplate: flexInsertBoilerplate:("")
Inserts a standard "made with FlexHTML"-style string into the output stream. If you use FlexHTML, please consider using function as part of your document footer. The argument string to this function is reserved for future use and must be empty for now.
flexOutFile$: flexOutFile$:
Returns the name of the current output file, relative to the top level output directory (as specified in the flex: function). This can be useful to generate correct include document URLs in footers, for example. The file name is returned using the EPOC conventions but can be converted to URL format using an HTTP text encoding table.
flexKeyword$: flexKeyword$:(string$,allowEmpty%)
Analyse supplied string (e.g. a template argument that represents a flag or option) to find a keyword, consisting of alphanumeric and '-' characters. Leading and trailing spaces are removed but other spaces will raise an error. Result is always returned in upper case.
flexError: flexError:(errorCode%,errorMessage$)
Halt document processing with given OPL error code and message. If error code is 0 then no action is taken, allowing this function to be called with an I/O response code without testing for a non-zero value first

See below for a complete listing of FlexHTML.oph with more details of these functions.

4.5 More examples

The manual yor are reading is an example applicatiion of FlexHTML. Take a look at the supplied Runme.opl and Readme.flx files that are used to generate it. For example, see how:

  • The section numbers get inserted automatically.
  • All sections but the first are preceeded with a shorter horizontal rule.
  • The FlexHTML.oph and FlexHTML.tab source files appear in this documentation and how the special HTML characters within them are automatically encoded correctly.
  • All the notes and function tables are formatted with consistent tagging.
  • Where the automatically generated table of contents is put together.
  • And, how I know that the square root of 49 is 7

5 Text encoding

5.1 Text encoding

The text encoding functions allow plain text to be transformed onto a form suitable for a particular output format, ensuring that any special characters are encoded (or "escaped") correctly. This technique is used to encode the source files embedded at the end of this manual.

For example, the string "Black & white" might be encoded to "Black & white" for HTML output. This can be used to transform the arguments of templates, data extracted from databases or even whole texts without having to examine their content.

Another way to use the text encoding functionality is to convert EPOC file names into HTTP URLs. In this case, spaces become the "+" character and other characters may be escaped to hexadecimal codes. For convenience, the EPOC directory separator, "\" might be replaced with the URL one, "/".

The FlexHTML text encoding functions are based on tables, a set of which are loaded from a single table file. Each time an encoding function is used, the name of the required table is supplied as a function parameter.

There are two encoding tables supplied, as summarised in the following table. You can also write your own encoding table files, allowing you to customise the encoding to your needs.

HTTP kEncodeTable_HTTP$
Converts a string to a form suitable for inclusing in an HTTP URL. Also replaces the "\" character with "/", for EPOC to URL directory path conversion. Allows alphanumerics, full-stops (".") and underscores ("_") to pass through, unaltered. Spaces become a plus sign ("+") and the remaining characters are escaped by a percent ("%") character followed by two hexadecimal digits.
HTML kEncodeTable_HTML$
Encodes plain text into a form suitable for inclusion in an HTML document, with special characters (e.g. "<") correctly encoded so they are not interpretted as tags by the browser. Also encodes accented characters and the non-break space character (code 160), using the appropriate tag names. This assumes that the input is in the standard "1252, ISO Latin-1" character set used by most EPOC machines.
No encoding kEncodeTable_None$
Not strictly an encoding table, but all encoding functions understand an empty encoding table name to mean no encoding. Encoding is turned off for the operation and all characters pass unaltered.

5.2 Using text encodings

Text encoding can be applied within your template implementations through the use of the following functions. Each function requires that you specify a valid encoding table name. Constants for the names of the supplied text encodings are included in the header file, and summarised in the previous section.

flexEncode$: flexEncode$:(string$,table$)
Returns the value of an arbitrary string encoded by the named encoding table. The encoded string may be of different length to the original but an error will occur if the result is longer than 255 characters.
flexInsertEncodedString: flexInsertEncodedString:(string$,table$)
Sends the value of an arbitrary string encoded by the named encoding table to the output. The encoded string may be of different length to the original and it does not matter if the result is longer than 255 characters.
flexInsertEncodedArg: flexInsertEncodedArg:(a%,table$)
Sends the value of the specified template argument encoded by the named encoding table to the output. The encoded text may be of different length to the original and it does not matter if the result is longer than 255 characters.
flexSetBaseTextEncoding$: flexSetBaseTextEncoding$:(table$)
Sets an encoding table to be used for the text copied directly from the input to output streams; i.e. text that appears outside of template invocations. This can be used to embed whole passages of text (such as segments of source code) without having to consider whether it contains special characters. The function returns the name of the base encoding in use before the function was called, to allow templates to choose a temporary encoding by saving and later restoring the current one. At the start of processing, no base encoding table is in use. To turn the base text encoding off again, specify an empty table name, using the constant kEncodeTable_None$. Note that this setting has no effect on the values of template arguments; templates access them as they appear in the input stream but can encode them as required using the other text encoding functions.

5.3 Writing user-defined text encoding tables

Whilst the supplied text encoding tables may be sufficient for many purposes, they can be modified to suit other needs.

Text encoding table files are text files that describe up to four independent encodings. FlexHTML can only load one encoding table file at a time, but the current encoding table file can be changed dynamically, using the flexSetEncodingTableFile$: function.

flexSetEncodingTableFile$: flexSetEncodingTableFile$:(file$)
Sets the current text encoding table file to the named file, which will be loaded when the next text encoding operation is performed. The function returns the name of the file in use before the function was called, to allow templates to choose a temporary file by saving and later restoring the current one. All other text encoding settings are cleared.

Note: Changing the current text encoding file causes FlexHTML to clear all current text encoding settings. Any base text encoding is turned off. Frequent changes of the text encoding file will slow performance as it is reloaded each time.

The format of the text encoding file is fairly straightforward. You can use the supplied default text encoding table as a starting point. The file can contain up to four encoding tables, each of which are formatted as follows.

  • Each line in the encoding file contains up to four individial fields, each of which are separated by a tab character (code 9) and may be up to 10 characters long.
  • Comment lines in the file start with a ";" character. These are treated as blank lines and ignored.
  • A new encoding table is started with a declaration line, which contains two fields:
    1. The name of the new table (up to 10 characters long and starting with an uppercase letter).
    2. The rule for the numerical escaping of characters. This is a string pattern containing the escaping syntax with either:
      FF
      The numerical escaping is the pattern, with "FF" replaced by exactly two hexadecimal digits
      999
      The numerical escaping is the pattern, with "999" replaced by exactly three decimal digits, representing an unsigned integer of less that or equal to 255.
    The encoding table ends when another declaration line is encountered (starting the next table) or at the end of the file.
  • Each line in an encoding table contains up to four field that describe how to encode a character, or range of characters:
    1. The lowest character in the range (required). This must be expressed as an integer between 0 and 255 (inclusive) and may use any of the following OPL notations:
      • Decimal integer (e.g. "33").
      • Hexadecimal integer (e.g. "$21").
      • Character integer constant (e.g. "%!").
    2. The highest character in the range (optional), expressed in the same notation as above. If left empty, the range will consist of the single lowest character code.
    3. The encoding rule for this range:
      =
      Characters pass unaltered and will appear in the encoding as they appeared in the input.
      \
      Characters are suppressed; they do not appear in the encoded string
      >
      Replace characters with the string contained in field 4.
    4. The character encoding string, when field 3 contains ">". Otherwise, this field is ignored.
  • Encoding lines are applied to the table sequentially. Where two or more lines encode the same character, the active encoding will be the latest in the file.

6 Notes and limitations

6.1 File formats

Most text-based formats and languages can be contained in the input stream provided that they do not require the use of '##' as the first two characters on a line. However, since FlexHTML replaces blocks of lines with other blocks of lines, it is not possible to insert variables in the middle of a line (as the C macro pre-processor does, for example).

6.2 Text formatting

FlexHTML currently knows nothing (or at least very little) of the data it is handling. This may be a concern if you wish to both target an output stream that can handle word-wrapping (e.g. HTML) and one that cannot (e.g. plain text).

6.3 Escape characters

Another problem with generating multiple output formats lies in the conventions for escape character sequence. For example, if I write '&', this would appear as an ampersand character in formatted HTML/XML/etc, but would appear as the raw escape sequence in a text output.

The text encoding feature, introduced in Version 1.2, can be used to handle this problem. However, care must still be taken to use the correct text encoding at the correct point in your OPL code.


7 Disclaimer and copyright

  1. FlexHTML is freeware and copyright; it is not public domain. The rights to this package remain the property of the author.
  2. You may use this software for your own use, free of charge, for an indefinite period and at no obligation to the author.
  3. Permission is given to publicly distribute this software provided the ownership of the rights to this software is clearly stated and any fee charged is extremely nominal. Distributions of this software must always consist of the the unaltered SIS file distribution.
  4. If you wish to use and distribute this module as part of your own application you may do so provided that you:
    • Contact the author of this module, at the email address below, to inform him of your intentions and to allow him to notify you of any updates.
    • Distribute the module in the original SIS file or correctly embed the original SIS file in your own SIS file. (The UID for FlexHTML is 0x10003934.)
  5. Use of this software is entirely at the user's own risk. The user must accept responsibility for any direct or indirect loss or damage arising from the use (or misuse) of the package. This software is supplied "as-is".

8 Contacting the author

If you have any problems, comments or suggestions about this software, you can contact me at the following email addresses:

  • dave@freepoc.de
  • dave@piecafe.demon.co.uk

This application is distributed in association with FreEPOC:

  • http://www.freepoc.de/

For the latest news of this an my other software, also visit:

  • http://www.piecafe.demon.co.uk/

9 Appendix

9.1 FlexHTML.oph

rem ====================================================
rem = FlexHTML.oph - FlexHTML OPM header file
rem = (C) 2000, 2001 David Rushall
rem = In association with FreEPOC
rem = All rights reserved.
rem = See associated documentation for details of use
rem = --------------------------------------------------
rem = Please consider using standard FlexHTML footer
rem = 'boilerplate' on public HTML pages generated with
rem = this OPM. See "flexInsertBoilerplate:" below.
rem = --------------------------------------------------
rem = Free your plamtop...   Free yourself...    FreEPOC
rem = Web                        http://www.freepoc.org/
rem = Email                             dave@freepoc.org
rem = --------------------------------------------------
rem = Dave Rushall       http://www.piecafe.demon.co.uk/
rem ====================================================

rem ----------------------------------------------------
rem - Constants
rem -
const kMaxArgs%=8         : rem number of template args
const kMaxArgLength%=8192 : rem template argument length
const kMaxLineLength%=255 : rem input line length

const kFlexVersion=1.2    : rem FlexHTML version number
const kFlexHTMLUID&=&10003934 : rem ...and UID

rem - Supplied text encoding tables
const kDefaultEncodingFilename$="C:\System\OPM\FlexHTML.tab"
const kEncodeTable_None$=""     : rem no encoding
const kEncodeTable_HTML$="HTML" : rem for HTML (Latin)
const kEncodeTable_HTTP$="HTTP" : rem for HTTP URLs (Latin)

rem - Flags for flex:() calls
const kFlexFlags_None&=&00        : rem standard operation
const kFlexFlags_SourceNewer&=&01 : rem skip old sources
rem (other flags reseved for future use)

rem ----------------------------------------------------
rem - flexVerChk - Version check
rem -  Args:   version,  header version identifier
rem -  Return: Nothing
rem -  Notes:  Confirms FlexHTML OPM is compatible with
rem -          supplied FlexHTML version number.
rem -          Completes only if compatible (else STOPs)
rem -          Use in main code body thus...
rem -            flexVerChk:(kFlexVersion)
rem -          May be called at any time
external flexVerChk:(version)

rem ----------------------------------------------------
rem - flex - do template processing for a single input
rem -  Args:   inFile$, input file name (inc path)
rem -            or single template name
rem -          outPath$, local output file directory
rem -          outFile$, output file name
rem -          flags&, proceessing flags
rem -  Return: Nothing
rem -  Notes:  Opens input and output files and copies
rem -          input to output, line by line. If a
rem -          template sequence is encountered, the
rem -          arguments are collected (with nothing
rem -          written to output) and the user template
rem -          function called. The template function
rem -          is then free to make calls to other
rem -          library functions and generates required
rem -          output via LPRINT statements.
rem -          Input file may be either plain text file
rem -          or produced with the OPL program editor.
rem -          Alternatively, input may be a template
rem -          name, prefixed by "##!", in which case
rem -          the output is the result of the single
rem -          template invocation (without arguments).
rem -          Output is plain text file.
rem -          See constants above for valid flags.
rem -          Completes only if succesful (i.e. no
rem -          errors were detected or raised by user
rem -          templates)
rem -          May NOT be called within a user template
rem -
external flex:(inFile$,outPath$,outFile$,flags&)

rem ----------------------------------------------------
rem - flexInclude - embed another input in output
rem -  Args:   inFile$, input file name (inc path)
rem -  Return: Nothing
rem -  Notes:  Input file may be either plain text file
rem -          or produced with the OPL program editor,
rem -          and may include templates for processing.
rem -          Completes only if succesful (i.e. no
rem -          errors were detected or raised by user
rem -          templates)
rem -          May ONLY be called within a user template
rem -
external flexInclude:(inFile$)

rem ----------------------------------------------------
rem - flexVer$ - return FlexHTML version string
rem -  Args:   None
rem -  Return: Version string
rem -  Notes:  Output suitable for HTTP 'GENERATOR'
rem -          header, etc.
rem -          May ONLY be called within a user template
rem -
external flexVer$:

rem ----------------------------------------------------
rem - flexArgLen% - get template argument length
rem -  Args:   a%, argument number
rem -  Return: Argument length
rem -  Notes:  Length of indicated template argument
rem -          is returned
rem -          Argument is counted unmodified; no
rem -          text encoding table will be applied.
rem -          May ONLY be called within a user template
rem -
external flexArgLen%:(a%)

rem ----------------------------------------------------
rem - flexGetArg$ - get template argument as string
rem -  Args:   a%, argument number
rem -  Return: Argument sting
rem -  Notes:  Contents of indicated template argument
rem -          is returned as a string. If argument is
rem -          longer than 255 and processing is
rem -          terminated.
rem -          Argument is returned unmodified; no
rem -          text encoding table will be applied.
rem -          May ONLY be called within a user template
rem -
external flexGetArg$:(a%)

rem ----------------------------------------------------
rem - flexInsertArg - send template argument to output
rem -  Args:   a%, argument number
rem -  Return: Nothing
rem -  Notes:  Contents of indicated template argument
rem -          is placed into output stream. Argument
rem -          may be of any length (up to maximum).
rem -          Argument is output unmodified; no
rem -          text encoding table will be applied.
rem -          May ONLY be called within a user template
rem -
external flexInsertArg:(a%)

rem ----------------------------------------------------
rem - flexInsertEncodedArg - output encoded argument
rem -  Args:   a%, argument number
rem -          table$, text encoding table name
rem -  Return: Nothing
rem -  Notes:  Behaves as flexInsertArg: except the
rem -          argument is encoded using the named
rem -          text encoding table, when placed into
rem -          the output stream. Argument may be of
rem -          any length (up to maximum).
rem -          If the table name is the empty string,
rem -          no encoding will be used.
rem -          See constants above for supplied tables.
rem -          May ONLY be called within a user template
rem -
external flexInsertEncodedArg:(a%,table$)

rem ----------------------------------------------------
rem - flexEncode$ - encode string using encoding table
rem -  Args:   string$, string to be encoded
rem -          table$, text encoding table name
rem -  Return: String encoded by named encoding table.
rem -  Notes:  Encodes any string using text encoding
rem -          table.
rem -          Encoded output may be longer then the
rem -          original. An error will be raised if the
rem -          result is longer than 255 characters.
rem -          If the table name is the empty string,
rem -          no encoding will be used.
rem -          See constants above for supplied tables.
rem -          May ONLY be called within a user template
rem -
external flexEncode$:(string$,table$)

rem ----------------------------------------------------
rem - flexInsertEncodedString - output encoded string
rem -  Args:   string$, string to be encoded to output
rem -          table$, text encoding table name
rem -  Return: Nothing
rem -  Notes:  Send any string to ouput, after applying
rem -          named text encoding table.
rem -          Encoded output may be longer then the
rem -          original but it does not matter if the
rem -          result is longer than 255 characters.
rem -          If the table name is the empty string,
rem -          no encoding will be used.
rem -          See constants above for supplied tables.
rem -          May ONLY be called within a user template
rem -
external flexInsertEncodedString:(string$,table$)

rem ----------------------------------------------------
rem - flexSetBaseTextEncoding$ - set encoding for base
rem -  Args:   table$, text encoding table name
rem -  Return: Name of previously used base encoding.
rem -  Notes:  Sets the encoding table to be used for
rem -          text copied directly from the input to
rem -          output streams; i.e. text that appears
rem -          outside of template invocations.
rem -          This setting has no effect on the values
rem -          of template arguments or text generated
rem -          by templates.
rem -          If the table name is the empty string,
rem -          or this function is never used, no base
rem -          encoding will be used. This is the
rem -          default.
rem -          See constants above for supplied tables.
rem -          May ONLY be called within a user template
rem -
external flexSetBaseTextEncoding$:(table$)

rem ----------------------------------------------------
rem - flexSetEncodingTableFile$ - set user encoding file
rem -  Args:   file$, name of new encoding table file
rem -  Return: Name of previously used table file.
rem -  Notes:  Selects user encoding table file, to be
rem -          used insead of the one supplied by
rem -          FlexHTML. All existing text encoding
rem -          table settings are cleared.
rem -          If not used, text encoding operations
rem -          will use the default supplied encoding
rem -          tables.
rem -          File must be a valid FlexHTML encoding
rem -          table file.
rem -          May ONLY be called within a user template
rem -
external flexSetEncodingTableFile$:(file$)

rem ----------------------------------------------------
rem - flexInsertBoilerplate - FlexHTML footer to output
rem -  Args:   empty$, reserved (must be "" for now)
rem -  Return: Nothing
rem -  Notes:  Standard FlexHTML HTML footer insert
rem -          is placed into output stream.
rem -          Reserved parameter, empty$, MUSt be ""
rem -          May ONLY be called within a user template
rem -
rem -          Please consider using this footer at
rem -          the end of all public HTML documents
rem -          generated with the help of FlexHTML.
rem -
external flexInsertBoilerplate:(empty$)

rem ----------------------------------------------------
rem - flexOutFile$ - returns name of current output file
rem -  Args:   None
rem -  Return: Value of outFile$ specified on flex: call
rem -  Notes:  Name is retuned in EPOC format (can be
rem -          converted to URL format using a text
rem -          encoding table).
rem -          May ONLY be called within a user template
rem -
external flexOutFile$:

rem ----------------------------------------------------
rem - flexKeyword$ - extract keyword from string
rem -  Args:   s$, string in which to look
rem -          allowNull%, if zero an error is raised if
rem -              no keyword was found in string
rem -  Return: Value of keyword, in upper case
rem -  Notes:  Given a string, this function trims all
rem -          leading and trailing white space and
rem -          returns the remainder, folded to upper
rem -          case.
rem -          If the remainder contains any characters
rem -          other than 'A' to 'Z', '0' to '9' or '-'
rem -          then an error is raised and the function
rem -          does not return.
rem -          An error is also raised if the remainder
rem -          is the empty string and allowNull% is
rem -          false.
rem -          May ONLY be called within a user template
rem -
external flexKeyword$:(s$,allowNull%)

rem ----------------------------------------------------
rem - flexError - test for and report error
rem -  Args:   ec%, standard OPL error code
rem -          msg$, error message string
rem -  Return: Nothing
rem -  Notes:  If ec% is non zero, an error report is
rem -          generated (including line number, error
rem -          description and supplied message text)
rem -          and processing is terminated.
rem -          Returns immediately if ec% is zero.
rem -          May ONLY be called within a user template
rem -
external flexError:(ec%,msg$)

rem ====================================================
rem End of FlexHTML.oph
rem ====================================================

9.2 FlexHTML.tab

; ====================================================
; = FlexHTML.tab - FlexHTML OPM escaping table
; = (C) 2000, 2001 David Rushall
; = In association with FreEPOC
; = All rights reserved.
; = See associated documentation for details of use
; = --------------------------------------------------
; = Please consider using standard FlexHTML footer
; = 'boilerplate' on public HTML pages generated with
; = this OPM. See "flexInsertBoilerplate:" in header.
; = --------------------------------------------------
; = Free your plamtop...   Free yourself...    FreEPOC
; = Web                        http://www.freepoc.org/
; = Email                             dave@freepoc.org
; = --------------------------------------------------
; = Dave Rushall       http://www.piecafe.demon.co.uk/
; ====================================================

; ----------------------------------------------------
; Table for HTTP URL escaping
; ----------------------------------------------------
HTTP	%FF
; Suppress control characters...
$00	$1F	\
; Space becomes a "+"...
$20		>	+
; EPOC directory separators to URL ones...
%\		>	/
; Allow other typical filename characters...
%0	%9	=
%A	%Z	=
%a	%z	=
%.		=
%_		=
; Remaining characters numerically escaped
; End of HTTP table
; ----------------------------------------------------

; ----------------------------------------------------
; Table for "1252, ISO Latin-1" language HTML escaping
; ----------------------------------------------------
HTML	&#999;
; Suppress control chars...
$00	$1F	\
$7F		\
; ...except for white space...
$09	$0A	=
$0D		=
; Allow remaining 7-bit characters...
$20	$7E	=
; ...except for special HTML characters...
%"		>	&quot;
%&		>	&amp;
%<		>	&lt;
%>		>	&gt;
; ISO 8859-1 characters (codes 160-255)...
$A0		>	&nbsp;
%¡		>	&iexcl;
%¢		>	&cent;
%£		>	&pound;
%¤		>	&curren;
%¥		>	&yen;
%¦		>	&brvbar;
%§		>	&sect;
%¨		>	&uml;
%©		>	&copy;
%ª		>	&ordf;
%«		>	&laquo;
%¬		>	&not;
%­		>	&shy;
%®		>	&reg;
%¯		>	&macr;
%°		>	&deg;
%±		>	&plusmn;
%²		>	&sup2;
%³		>	&sup3;
%´		>	&acute;
%µ		>	&micro;
%¶		>	&para;
%·		>	&middot;
%¸		>	&cedil;
%¹		>	&sup1;
%º		>	&ordm;
%»		>	&raquo;
%¼		>	&frac14;
%½		>	&frac12;
%¾		>	&frac34;
%¿		>	&iquest;
%À		>	&Agrave;
%Á		>	&Aacute;
%Â		>	&Acirc;
%Ã		>	&Atilde;
%Ä		>	&Auml;
%Å		>	&Aring;
%Æ		>	&AElig;
%Ç		>	&Ccedil;
%È		>	&Egrave;
%É		>	&Eacute;
%Ê		>	&Ecirc;
%Ë		>	&Euml;
%Ì		>	&Igrave;
%Í		>	&Iacute;
%Î		>	&Icirc;
%Ï		>	&Iuml;
%Ð		>	&ETH;
%Ñ		>	&Ntilde;
%Ò		>	&Ograve;
%Ó		>	&Oacute;
%Ô		>	&Ocirc;
%Õ		>	&Otilde;
%Ö		>	&Ouml;
%×		>	&times;
%Ø		>	&Oslash;
%Ù		>	&Ugrave;
%Ú		>	&Uacute;
%Û		>	&Ucirc;
%Ü		>	&Uuml;
%Ý		>	&Yacute;
%Þ		>	&THORN;
%ß		>	&szlig;
%à		>	&agrave;
%á		>	&aacute;
%â		>	&acirc;
%ã		>	&atilde;
%ä		>	&auml;
%å		>	&aring;
%æ		>	&aelig;
%ç		>	&ccedil;
%è		>	&egrave;
%é		>	&eacute;
%ê		>	&ecirc;
%ë		>	&euml;
%ì		>	&igrave;
%í		>	&iacute;
%î		>	&icirc;
%ï		>	&iuml;
%ð		>	&eth;
%ñ		>	&ntilde;
%ò		>	&ograve;
%ó		>	&oacute;
%ô		>	&ocirc;
%õ		>	&otilde;
%ö		>	&ouml;
%÷		>	&divide;
%ø		>	&oslash;
%ù		>	&ugrave;
%ú		>	&uacute;
%û		>	&ucirc;
%ü		>	&uuml;
%ý		>	&yacute;
%þ		>	&thorn;
%ÿ		>	&yuml;
; Remaining CP-1252 chars (codes 128-159)...
%€		>	&euro;
$81		\
%‚		>	&sbquo;
%ƒ		>	&fnof;
%„		>	&bdquo;
%…		>	&hellip;
%†		>	&dagger;
%‡		>	&Dagger;
%ˆ		>	&circ;
%‰		>	&permil;
%Š		>	&Scaron;
%‹		>	&lsaquo;
%Œ		>	&OElig;
$8D	$90	\
%‘		>	&lsquo;
%’		>	&rsquo;
%“		>	&ldquo;
%”		>	&rdquo;
%•		>	&bull;
%–		>	&ndash;
%—		>	&mdash;
%˜		>	&tilde;
%™		>	&trade;
%š		>	&scaron;
%›		>	&rsaquo;
%œ		>	&oelig;
$9D	$9E	\
%Ÿ		>	&Yuml;
; End of HTML table
; ----------------------------------------------------


Generated with help from FlexHTML for EPOC