[Linux-txt2html] About How This site Is Produced

EXAMPLE TEMPLATE:
PRODUCT: txt2html Version 2.52 (adapted)
OP/SYS: Linux Fedora 15
COMPONENT: Automatically translating text to HTML format
PREREQUISITES: Perl V5.8.1 or above Getopt::Long Perl package Getopt::ArgvFile Perl package File::Basename Perl package Pod::Usage Perl package Yam::Syck Perl package Test::More Perl package Module::Build Perl package Version 0.26 or above
SOURCE: Philippe Vouters Fontainebleau/France
HIGH QUALITY MOBILES+TABLETS: http://android-land.fr
OVERVIEW: This article shows my way to automatically turn the text formatted articles I write using a standard text editor to HTML format using txt2html converter.
*** CAUTION *** This sample script has been tested using txt2html Version 2.51 on Linux Fedora 11. However, we cannot guarantee its effectiveness because of the possibility of error in transmitting or implementing it. It is meant to be used as a template for writing your own script and associated dictionaries, and may require modification for use on your system.
DOWNLOAD: Because txt2html is no longer Perl's cpan installable, you may download ../zip/txt2html-2.52.tar.gz
SCRIPT NOTES: All my source text files reside in my $HOME/tima/ user directory. On my Linux Fedora 11, I have setup the Apache root directory as /var/www/html (this is the default configuration). The target directory for the HTML formatted articles is /var/www/html/tima. I write my text articles following a design rule I inherited from DEC days (see the file article.txt). Automatically producing the HTML formatted pages is simple for me; I named my script tima.sh and because the /var/www/html directory is only superuser write enabled, from my account,I type the following: % ./tima.sh As I am using my user account, this explains why I am sudo'ing to root in the txt2html invocation.
BUILDING: From a root account: # tar -zxvf /path/to/txt2html-2.52.tar.gz # cd txt2html-2.52/ # perl Build.PL # ./Build # ./Build test # ./Build install Note: If # perl Build.PL complains with missing prerequisites, you can use Perl's cpan to download and install the missing Perl packages. For example: [~/tmp/txt2html-2.52]$ perl Build.PL Checking prerequisites... requires: ! Getopt::ArgvFile is not installed ! YAML::Syck is not installed ERRORS/WARNINGS FOUND IN PREREQUISITES. You may wish to install the versions of the modules indicated above before proceeding with this installation Run 'Build installdeps' to install missing prerequisites. You may then run always from a root account: # cpan cpan> install Getopt::ArgvFile cpan> install YAML::Syck cpan> exit The above will fetch over Internet the latest version of the requested Perl package as well as its dependencies and install them in correct paths inside your Perl's root directory. cpan is for Perl what ./configure, make, make test and make install are for compiled Opensource codes. The nearest cpan equivalent is Maven for large Java automatic builds. Once installed, they are immediately usable. In the txt2html # perl Build.Pl case, you should no longer face such errors if the command is rerun.
SCRIPT: #!/bin/ksh #set -x OUTDIR=/var/www/html/tima INDIR=~philippe/tima REDIRECT=~philippe/tima/redirect if [[ -d $OUTDIR ]]; then sudo rm -f $OUTDIR/*.html else sudo mkdir $OUTDIR fi for f in `ls $INDIR/*.txt`; do if [[ $f == "$INDIR/article.txt" || $f == "$INDIR/symptom.txt" ]];then continue fi echo "Processing $f" name=$(basename $f .txt) sudo /usr/local/bin/txt2html --titlefirst -pb 0 \ --default_link_dict $INDIR/article.dict --nomake_anchors \ --explicit_headings --outfile $OUTDIR/$name.html \ --nouse_mosaic_header --italic_delimiter "" --bold_delimiter "" \ --underline_delimiter "" --without_system_dict $f done sudo cp $REDIRECT/*.html $OUTDIR/ exit 0 Code article.txt : writing rules template: BACKGROUND: The following is a worldwide agreed upon template to be used for Example STARS articles. Example articles include programs, command procedures, TPU procedures, etc.. Text addressing the writer should be removed. Information within "{}" should be filled in or deleted. This document contains the most commonly used headings of an EXAMPLE article. However, others are available. For additional information on article standards, refer to the following article in the .STARS_ARTICLE_STANDARDS database located under SERVICE_TOOLS: [ART-STANDARDS] STARS Article Guidelines During the submission process, you will be prompted for the title. There is a 70 character limit. When prompted for the title, include a description of what the example does. The format of the title should be : Example-{product} {title} Note that there are two spaces between {product} and {title}. EXAMPLE TEMPLATE: PRODUCT: {product} Version{s} {n.n} OP/SYS: {operating system} Version{s} {n.n} COMPONENT: {component - placed appropriately under PRODUCT: or OP/SYS:} Writer: Use only if an article pertains to a specific subset or well-defined sub-functionality of a product. !!SOURCE: Philippe Vouters Fontainebleau/France
HIGH QUALITY MOBILES+TABLETS: http://android-land.fr OVERVIEW: Writer: Explain, if appropriate, the conditions which would produce the need for the example in this article. Tell the user what benefits will be realized by using the example. *** CAUTION *** This sample {program, procedure} has been tested using {product} V{n.n} on {op_sys} V{n.n}. However, we cannot guarantee its effectiveness because of the possibility of error in transmitting or implementing it. It is meant to be used as a template for writing your own {program, procedure}, and may require modification for use on your system. {PROGRAM, PROCEDURE} NOTES: Writer: Enter any notes that will help the user, such as specific conditions under which the example should be used, conceptual background information, a brief description of the parts of the program, necessary preparation for the example, required privileges, and so forth. {PROGRAM, PROCEDURE}: Writer: Include the program or procedure here. Be sure you have created your program or procedure without any tabs. Also, please use comment lines frequently to explain what the parts of the example do. You MUST include the following copyright at the top of the program enclosed in comment delimiters appropriate for the language being used: COPYRIGHT (C) 2003 BY HEWLETT-PACKARD COMPANY ALL RIGHTS RESERVED. THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED. THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY HEWLETT-PACKARD COMPANY. HP ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY HP. NO RESPONSIBILITY IS ASSUMED FOR THE USE OR RELIABILITY OF SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY HEWLETT-PACKARD COMPANY. SUPPORT FOR THIS SOFTWARE IS NOT COVERED UNDER ANY HP SOFTWARE PRODUCT SUPPORT CONTRACT, BUT MAY BE PROVIDED UNDER THE TERMS OF THE CONSULTING AGREEMENT UNDER WHICH THIS SOFTWARE WAS DEVELOPED. REFERENCE(S): Writer: The optional REFERENCE(S) section is used for documentation, escalations, or notesfile references. If all the references are hidden text, hide the REFERENCE heading.

Article.dict txt2html dictionary converter: |\nBACKGROUND $| -h-><br><font size=5><B><A NAME=$&>$&</A></B></font> /\n\*\*\* CAUTION \*\*\*\z/ -h-><br><font size=5><B><A NAME="$&">$&</A></B></font> # disregard the "Verifying - Enter PEM pass phrase:" string /(\n|\z)(Verifying \- Enter PEM pass phrase:)(\n|\z)/ -h-> <br>$2<br> # Highlight with a smaller font size all lines ending with a colon and # starting with an uppercase letter. The line must underlined with a dash /(\n|\z)([A-Z]([A-Za-z, 0-9_\-\.'\$]+):)\n(\-|\*)+(\n|\z)/ -h-> $1<font size=5><B><A NAME="$2"><U>$2</U></A></B></font>$5 # Convert all line starting with uppercase words or uppercased strings # terminated by a colon /(\n\w+ PACKET:.*\z)|(\n[A-Z]([A-Z0-9\(\)\/\-'\.,_ ]{4,}([a-z0-9]+)?)+:.*\z)/ -h->$1<br><font size=5><B><A NAME="$2">$2</A></B></font> # This regex is designed to uninterpret the above keywords for the article # "[Linux,txt2html] How this site is designed" /(\n|\z)!!(.*?)!!/ -h-> $1$2 # process <NOTE>text</NOTE> so that text comes up with a yellow backgreound /(\n|\z)&lt;NOTE&gt;/ -h-><br>&lt;NOTE&gt;<span style='background:#F4FA58'> /&lt;\/NOTE&gt;(\n|\z)/ -h-></span>&lt;/NOTE&gt;<br> # process <QUOTE>text</QUOTE> so that text comes up with a grey background /^&lt;QUOTE&gt;$/ -h-><br>&lt;QUOTE&gt<span style='background:#A4A4A4'> /^&lt;\/QUOTE&gt;$/ -h-></span>&lt;/QUOTE&gt;<br> # Set bold-italic all strings limited by \B* and *\B /\\B\*(.*?)\*\\B/ -h-><font size=4><I><B>$1</B></I></font> |\*+| -h-> $& #This regex is designed to hide lines starting with a backslash /(\n|\z)[\\]{1,2}[^[fnrt]]?(.*)?(\n|\z)/ -h-> <br> #/(\n|\z)!!([:isalpha:]+)!!(\n|\z)/ -h-> $1$2 # Some people like to mark URLs explicitly <URL:foo>; /&lt;URL:\s*(\S+?)\s*&gt;/ -h-> <A HREF="$1">$1</A> |http(s)?:[\w/\.:\@+\-~\%#?=&;,]+[\w/]| -> $& #to integrate images to text. /&lt;IMAGE:\s*(\S+?)\s*&gt;/ -h-><div style="position:relative;"><IMG SRC="$1" VALIGN="TOP"></div> #document encoding /&lt;encoding:(.*)&gt;/ -h-><meta http-equiv="content-type" content="text/html; charset=$1" /> /&lt;!URL:foo!&gt;/ -h->&lt;URL:foo&gt; # process this special case for the txt2html docmeent containing this # article.dict so that the way I am organized remains understandable to the # Web readers reading this txt2html document. /\\\*B\*(.*?)\*\\\*B/ -h->\\B\*$1\*\\B
REFERENCE(S): Linux txt2html man. Researches on http://www.google.com/ for Regex expressions rules.