Cosmic Consulting  www.cosmicconsulting.com

Downloads

SHYPREC: Simple HYpertext PRE-proCessor

Version 1.3

Download the program   |   Read the license.

Summary

SHYPREC is a pre-processor for HTML similar to the way that cpp is a pre-processor for C/C++. SHYPREC looks for certain keywords that you put into the HTML comments and then carries out some action specified by the keyword. Using SHYPREC you can define your own variables and include external files. Being able to include files allows you to have repetitive HTML content in one external file used by multiple HTML pages.

SHYPREC is useful to people who want to control every aspect of the web page creation process but want to avoid the tedious and repetitive tasks. Commercial web page creation programs such as WSIWYG editors sometimes take care of these tasks but too frequently you lose control over the coding. In addition, you are stuck editing using that one program on that one platform. SHYPREC is written in Perl to be platform independent and give the HTML author maximum control with minimum work.

Usage

shyprec.pl inputfile 

will process the file inputfile and put the result on the standard output. If you use the keyword #shyfilename in the inputfile, SHYPREC will write the file into the specified file instead of the standard output.

Keywords

SHYPREC provides keywords that you place on their own inside of HTML comments, i.e., <!-- ... --> Each commented keyword must appear on its own line in the HTML file. The line containing the SHYPREC keyword is removed from the output.

<!-- #shyinclude "filename" -->
Include the external file filename in that position of the document. Note that you can have #shyinclude statements inside the included file (nested includes) arbitrarily deep. Note that SHYPREC does not check for circular includes (i.e., including one of the parent files).
<!-- #shydefine  variable value -->
This keyword allows you to define a variable (or more properly a macro) that is a simple replacement string. If you find yourself typing out a long sequence and want to have a short form for it, then this is the keyword for you. SHYPREC will replace all occurances of variable with value anywhere in the file and all included files. File includes are done before variable replacement.

Instances of the variable can come before the #shydefine keyword and #shydefine can occur inside the included files. Subsequent instances of #shydefine for the same variable will supercede the previous ones before the variable replacement. This feature allows you to define variable defaults in an included file and then override them for individual web pages.

At this point the restrictions on the variable name are very loose. The name must consist of anything except whitespace (spaces, tabs, carriage returns, linefeeds). Similarly the variable definition consists of anything except whitespace. This will probably change in the later versions so that we will have a mechanism for having whitespace in the variable definition. In the meantime, if you want whitespace in your HTML code to be inserted by the definition, you can use one of the standard HTML character entities

  • &#009; = horizontal tab
  • &#010; = line feed
  • &#013; = carriage return
  • &#032; = space
<!-- #shyfilename "filename" -->
Write the output for this file into the filename specified instead of to the standard output. This feature was added so that you can have SHYPREC run as a drag-and-drop program and still have the output go where you want it to. This feature was required to make SHYPREC useful with Macintosh port of Perl. I have found that this feature is also very useful for the command line invocation as well since you can specify multiple input files on the command line and the multiple output files will automatically be written to the correct places.

Note that the #shyfilename keyword is processed after the #shydefine keyword so that you can have the all or part of the output path specified by a defined variable.