UHTML Programming Interface


PERL programming interface

Although UHTML isn't bound to any particular programming language, implementation in perl is obvious. It results out of the consideration of perl support by most http servers, it's powerful pattern matching and sufficient speed. A perl based apache module would be a next step to speed up UHTML. A implementation in C (C++) would be interesting for bigger projects.

UHTML functionality is added via perl modules. Module files in the servers script directory that comply the pattern uHTML/*.pm or *-uHTML.pm are loaded automatically. This gives the opportunity to include a particular functionality (= UHTML tags) into a project by simply copying of module files. perl modules found at other locations need to be included explicitly using require or use keywords.

The UHTML library consists of two packages, UHTML itself and uHTMLnode. The UHTML package loads all modules from the script directory that match uHTML/*pm followed by them that match *-uHTML.pm.

In those files functions are bound to particular UHTML tags by uHTML->registerTag( $TagName,$Code ) and to variables (functions) in attributes by uHTML->registerVar( $VarName,$Code ).

The functions $Code themselves are invoked with $Node as argument. The structure of $Node is defined by the uHTMLnode package. It provides the data structure and methods to handle the data. It is expected that the function produces the final HTML code. This code is usually mapped into the data structure by the method $Node->map( $HeadText,$TailText ). In this method the angular brackets containing the tag name and its attributes are removed respectively replaced by $HeadText and $TailText. In closed tags (those with </...>) $TailText replaces the closing brackets, otherwise it follows $HeadText immediately.

Functions bound to variables in attributes are expected to return the appropriate replacement text. Potential arguments are passed after the reference to the relevant node. Only arguments consisting of numbers, letters and . are valid. The number of comma separated arguments is unlimited. The arguments have to be enclosed by round brackets. In historical versions two sets of arguments closed separately in round brackets could follow a variable. The variable itself is marked by leading $. It was in earlier versions marked by § or ^ for people with no § on the keyboard. In old UHTML files the appropriate § and ^ can be replaced by $ for a update without any compatibility worries.

The processing of UHTML is invoked with uHTML->recode( $uHTML ). This function expects the UHTML content as argument and returns final HTML code.


German Version

Other Sites:

uHTML-Logo 2008 All Rights Reserved Amina Mendez & Roland Okello Valid HTML 4.01 Transitional CSS is valide!