![]() | ![]() | ![]() | ![]() | ![]() |
The following example shows how text can be included from a file. The included text is displayed using the html "<PRE>" tag and automates a complex, time consuming and error prone task.
Characters such as "<" are converted to "<" so that the lines will correctly display in a browser. The example will also show how keywords can be linked to a glossary or page which explains a concept. Two international symbols are also handled for demonstration purposes:
;--- Include header for example support ------------------------------------- #include "HTMLPRE.IH" ;--- Set up all international characters we will handle --------------------- #AutoTagState + #AutoTag 'ä' 'ä' #AutoTag 'ë' 'ë' #AsIs SETUP INTERNATIONAL_SYMBOLS #AutoTagState - ;--- Some HTML text --------------------------------------------------------- <P>The following is the contents of my "config.sys" file: ;--- Include the example ---------------------------------------------------- #AutoTagState + ;;Lets not affect any existing tagging #AutoTag "REM " "<A HREF='rem.htm'>REM</A> " ;;Define a single change <$ExampleFile FILE="E:\CONFIG.SYS" STATE=REMEMBER ASIS=INTERNATIONAL_SYMBOLS> #AutoTagState - ;;Restore original tagging state
This shows the contents of the header file (supplied with PPWIZARD) that provides HTML example support:
;---------------------------------------------------------------------------- ; MODULE NAME: HTMLPRE.IH ; ; $Author: Dennis_Bareis $ ; $Revision: 1.2 $ ; $Date: 20 Nov 1999 08:11:24 $ ; $Logfile: E:/DB/PVCS.IT/OS2/PPWIZARD/HTMLPRE.IHV $ ; ; DESCRIPTION: This is a header file for handling inclusion of ; "examples" into HTML. ; ; See PPWIZARD documentation for examples of this file ; in use. The sample "TryMe.IT" file also uses this ; header file. ; ; ; Macro "ExampleFile" ; ~~~~~~~~~~~~~~~~~~~ ; ; This macro takes the following parameters: ; ; FILE ; ~~~~ ; Manditory. Identifies the file to be included. ; ; FRAGMENT ; ~~~~~~~~ ; Optional. You may wish to have a single example ; file hold more than one example. The text that ; you supply for this parameter marks the line before ; as well as the line after the example. ; ; ; INDENT ; ~~~~~~ ; Optional. By default a 4 space indent is used, ; you specify the number of spaces with 0 being ; valid. ; ; STATE ; ~~~~~ ; Optional. By default no autotagging will be ; performed. If you specify "REMEMBER" then the ; currently available autotags will be used, you ; may also specify which states tags should come ; from (see the "#AutoTagState +" command). ; ; ; ASIS ; ~~~~ ; Optional. By default only basic "AsIs" tagging ; is performed. If for example you wished to ; handle international characters then you would ; need to specify the names of the AsIs tags to use. ; ; ; ; Macro "Example / eExample" ; ~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Note that your "inline" example code must not contain ; a reference to the macro "eExample" as this is used ; internally. ; ; This macro takes the following parameters: ; ; ; INDENT ; ~~~~~~ ; As above. ; ; STATE ; ~~~~~ ; As above. ; ; ; ASIS ; ~~~~ ; As above. ; ; ; ;---------------------------------------------------------------------------- ;--- Define the version number of this header file -------------------------- #define VERSION_HTMLPRE_IH 00.316 #require 99.265 ;--- Define some aliases for characters we need to be careful with ---------- #RexxVar "LT" =x= "<" ;;'<' Char #RexxVar "GT" =x= ">" ;;'>' Char #RexxVar "AMP" =x= "&" ;;'&' Char #RexxVar "HASH" =x= "#" ;;'#' Char ;--- Define look and feel of examples --------------------------------------- #ifndef HTMLPRE_JUST_PRE_TAGS ;--- Set up defaults that user can override -------------------------- #ifndef HTMLPRE_COLOR #define HTMLPRE_COLOR purple #endif #ifndef HTMLPRE_STYLE_OTHER #define HTMLPRE_STYLE_OTHER ;font-size:80% #endif ;--- Set up the tags ------------------------------------------------- #define ExampleFormatted \ <FONT COLOR=<$HTMLPRE_COLOR>> ;;Set up font (older browsers) -\ <PRE STYLE="color:<$HTMLPRE_COLOR><$HTMLPRE_STYLE_OTHER>"> #define eExampleFormatted \ </PRE> -\ </FONT> ;;Restore Font (older browsers) #elseif ;--- Either want default "PRE" look or will define via stylesheet ----- #define ExampleFormatted \ <pre> ;;Start Example #define eExampleFormatted \ </pre> ;;End of Example #endif ;--- Set up AsIs Mode (minimum changes required - user can add to these) ---- #AutoTagState + ;--- Define characters that should be automatically modified ------------- #AutoTag "<" "<?xLT>" #AutoTag ">" "<?xGT>" #AutoTag "&" "<?xAMP>" #AutoTag "#" "<?xHASH>" ;--- "PROGRAM" ASIS mode ------------------------------------------------- #AsIs SETUP HTMLPRE_IH #AutoTagState - ;---------------------------------------------------------------------------- ;--- ALLOW SPELL CHECKING IN EXAMPLES? -------------------------------------- ;---------------------------------------------------------------------------- #ifndef HTMLPRE_SPELL_CHECKING #define HTMLPRE_SPELL_CHECKING OFF #endif ;---------------------------------------------------------------------------- ;--- EXAMPLE FILE INCLUSION ------------------------------------------------- ;---------------------------------------------------------------------------- #define ExampleFile \ <$ExampleFormatted> -\ #AutoTagState + {$STATE=''} ;;User can set up own tags -\ #option PUSH AllowSpell={$SPELL="<$HTMLPRE_SPELL_CHECKING>"} ExtraIndent=^copies(' ', {$Indent='4'})^ -\ #AutoTag ON -\ #AsIs ON HTMLPRE_IH {$AsIs=''} -\ #include "{$File}" "{$Fragment=''}" -\ #AsIs OFF -\ #option POP -\ #AutoTagState - -\ <$eExampleFormatted> ;---------------------------------------------------------------------------- ;--- EXAMPLE (INLINE) ------------------------------------------------------- ;---------------------------------------------------------------------------- #define Example ;;Starts Example \ <$ExampleFormatted> -\ #AutoTagState + {$STATE=''} ;;User can set up own tags -\ #option PUSH AllowSpell={$SPELL="<$HTMLPRE_SPELL_CHECKING>"} ExtraIndent=^copies(' ', {$Indent='4'})^ -\ #option PUSH replace=OFF -\ #AutoTag '<?xLT>$eExample<?xGT>' '<$eExample>' #1 -\ #option POP ;;Restore REPLACE mode -\ #AutoTag ON -\ #AsIs ON HTMLPRE_IH {$AsIs=''} -\ #define HTMLPRE_INLINE_EXAMPLE #define eExample ;;Ends Example \ #ifndef HTMLPRE_INLINE_EXAMPLE -\ #error ^Incorrectly formatted inline example (can't include end of example tag)^ -\ #endif -\ #AsIs OFF -\ #option POP -\ #AutoTagState - -\ #undef HTMLPRE_INLINE_EXAMPLE -\ <$eExampleFormatted>
![]() | ![]() | ![]() | ![]() | ![]() |