txt2html/HTML::TextToHTML Sample Conversion
This sample is based hugely on the original sample.txt produced by Seth Golub for txt2html.
I used the following options to convert this document:
-titlefirst -mailmode -make_tables --custom_heading_regexp '^ *--[\w\s]+-- *$' --system_link_dict txt2html.dict --append_body sample.foot --infile sample.txt --outfile sample.html
This has either been done at the command line with:
perl -MHTML::TextToHTML -e run_txt2html -- options
or using the script
or from a (test) perl script with:
use HTML::TextToHTML; my $conv = new HTML::TextToHTML(); $conv->txt2html([options]);
From: email@example.com (Bozo the Clown)
To: firstname.lastname@example.org (Kathryn Andersen)
Subject: Re: HTML::TextToHTML
Date: Sun, 12 May 2002 10:01:10 -0500
BtC> Can you post an example text file with its html'ed output?
BtC> That would provide a much better first glance at what it does
BtC> without having to look through and see what the perl code does.
Good idea. I'll write something up.
The header lines were kept separate because they looked like mail headers and I have mailmode on. The same thing applies to Bozo's quoted text. Mailmode doesn't screw things up very often, but since most people are usually converting non-mail, it's off by default.
Paragraphs are handled ok. In fact, this one is here just to demonstrate that.
THIS LINE IS VERY IMPORTANT!
(Ok, it wasn't that important)
Since this is the first header noticed (all caps, underlined with an "="), it will be a level 1 header. It gets an anchor named "section_1".
This is the second type of header (not all caps, underlined with "="). It gets an anchor named "section_1_1".
This header was in the same style, so it was assigned the same header tag. Note the anchor names in the HTML. (You probably can't see them in your current document view.) Its anchor is named "section_1_2". Get the picture?
You can define your own custom header patterns if you know what your documents look like.
It just needs to have enough whitespace in the line. Surrounding blank lines aren't necessary. If it sees enough whitespace in a line, it preformats it. How much is enough? Set it yourself at command line if you want.
Looks for short lines in the middle of paragraphs and keeps them short with the use of breaks (<BR>). How short the lines need to be is configurable.
Unhyphenates split words that are in the middle of paragraphs. Let me know if trailing punctuation isn't handled "properly". It should be.
One can also have multi-paragraph list items, like this one.
We're the knights of the round table
We dance whene'er we're able
We do routines and chorus scenes
With footwork impeccable.
We dine well here in Camelot
We eat ham and jam and spam a lot.
If I want to emphasize something, then I'd use stars to wrap around the words, even if there were more than one, that's what I'd do. But I could also underline words, so long as the darn thing was not a_variable_name, in which case I wouldn't want to lose the underscores in something which thought it was underlining. Though we might want to underline more than one word in a sentence. Especially if it is The Title Of A Book. For another kind of emphasis, let's go and put something in bold.
But it doesn't even need to be that simple. Something which is really exciting is coping with italics and similar things spread across multiple lines.
(extract from Let It Rain by Kristen Hall)
I have given, I have given and got none Still I'm driven by something I can't explain It's not a cross, it is a choice I cannot help but hear his voice I only wish that I could listen without shame Let it rain, let it rain, on me Let it rain, oh let it rain, Let it rain, on me I have been a witness to the perfect crime Wipe the grin off of my face to hide the pain It isn't worth the tears you cry To have a perfect alibi Now I'm beaten at the hands of my own game Let it rain, let it rain, on me Let it rain, oh let it rain, Let it rain, on me
A definition list comprises the following:
If one has more than one paragraph in the definition, the first line of the next paragraph needs to be indented two spaces from where the term starts, otherwise we don't know that it belongs to the definition.
Here is a simple ALIGN table:
|-z||File has zero size.|
|-s||File has nonzero size (returns size).|
Here are some of the conditions of ALIGN tables:
|Context:||A table needs to be surrounded by blank lines.|
|Length:||A table must contain at least two rows.|
|Width:||A table must contain at least two columns.|
|Spacing:||There needs to be at least two spaces between the columns,|
|otherwise there might be some random paragraph which|
|could have inter-word spacing that lined up by accident.|
|Cell Size:||If you have more than one line (as just above) then|
|you will simply get empty cells where the other column is empty.|
|Alignment:||Alignment of cells is attempted to be preserved.|
This is a table with a border.
This is the same table like Postgresql would make it.
A delimited table needs to have its delimiters at the start and end, just to be sure that this is a table.
And one can have almost any delimiter one wishes.
There are some things which this module doesn't handle yet which I would like to implement.
The footer is everything from the end of this sentence to the </BODY> tag.
[ Home | txt2html sourceforge | Download ]