PPWIZARD is a free preprocessor for HTML, REXX, Visual Basic or any text files.
[Bottom][Contents][Search][Prev]: #import - SQL[Next]: #import - WRAP
\ -> Commands -> #import -> #import - T2H

#import - T2H

This is a text to HTML #import mode (please read the #import documentation before trying to understand this section.

Sometimes you will wish to simply convert a number of text files to a equal number of html files. In this case you will probably wish to use the /Template switch and create a template for your background colors, titles, headers and footers that you require.

TEXT SPECIFIC DEFINITIONS/OPTIONS

These definitions are specific to the "T2H" import mode. If you can't understand how they work then I suggest you try using /debug or #debug to watch what variables the import uses etc.

EXAMPLE 1

This example imports a file and also extends the translation it will perform to include 2 international characters. For no real reason we will also prevent email addresses becoming "mailto" links and simply highlight email addresses in a different color.

;--- Save current Autotag state, set up international conversion, restore state ---
#AutoTagState +
#AutoTag      'ä'    'ä'
#AutoTag      'ë'    'ë'              ;;Only 2 for this example
#AsIs         SETUP  INTERNATIONAL_SYMBOLS
#AutoTagState -

;--- Update option so as to use the international chars as well as usual conversions -
#define T2H_ASIS_TAGGING     IMPORT_HTML_BASIC                   \
                             IMPORT_HTML_BOXGRAPHIC_TO_BOXTEXT   \
                             INTERNATIONAL_SYMBOLS

;--- Simply for demonstrate puroses, remove email links and make "olive" ---
#define T2H_MAILTO_LINK      <FONT COLOR=OLIVE>{$Url}</FONT>

;--- Import the text file ---
#import README.TXT T2H       ""

EXAMPLE 2

We don't wish to simply use "PRE" as we don't want to end up with long lines scrolling off to the right of the browser. We will simply end each line with "BR" tags, blank lines will output a second "BR" and look like a paragrapth break.

#define T2H_BEFORE <div style="background-color: #fffff7;color:black;display:block;white-space:pre;border:1px solid #800000;padding:5">
#define T2H_AFTER  </div>
#DefineRexx 'T2H_RECORD_FILTER'
   T2hNewLine = T2hNewLine || '<br>'
#DefineRexx
#import Stuff.txt T2h ''

EXAMPLE 3

We will still use a "PRE" in this case (slightly prettier than default), but we will prevent lines from being more than 80 columns long. If you wished continued lines to be displayed differently then this would not take much extra work.

#NextId
#define MAX_COLS  80
#define T2H_BEFORE <pre style="background-color: #fffff7;color:black;display:block;white-space:pre;border:1px solid #800000;padding:5">
#option PUSH DefineMacroReplace=YES       ;;Substitute macros straight away
#DefineRexx 'T2H_RECORD_FILTER' NOPACK
   if  length(T2hNewLine) > <$MAX_COLS> then
   do
       ;--- Line too long, we will adjust! ----------------------------------
       @@Left  = '';
       @@Right = T2hNewLine;
       do  while @@Right <> ''    ;;don't care about trailing whitespace
           ;--- Break off (up to) max characters ----------------------------
           parse var @@Right @@NextBit +<$MAX_COLS> @@Right;

           ;--- Now add to left bit -----------------------------------------
           @@Left = @@Left || '<br>' || @@NextBit
       end;
       T2hNewLine = @@Left;
   end;
#DefineRexx
#option POP
#import Stuff.txt T2h ''


email me  any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Search][Prev]: #import - SQL[Next]: #import - WRAP


PPWIZARD Manual
My whole website and this manual itself was developed using PPWIZARD (free preprocessor written by Dennis Bareis)
Sunday November 05 2017 at 10:00am