RtfToHtml -
--------------------------------------------------------------------------------
Revision history:
Nb.
function RtfToHtml(const rtf:string):string;
--------------------------------------------------------------------------------
Revision history:
Nb. Date: Author What was done.
003 ? ? ?
002 21-aug-1997 TSE Minor (very minor) cleanup before release
001 20-aug-1997 TSE Unit created - RtfToHTML function
designed and written.
Author list:
TSE Troels Skovmand Eriksen TSEriksen@cyberdude.com
TSErikse@post8.tele.dk
? ? ?
Supported features:
rev. 001 Indents, Bullets, Left-, Centered & Rightjustified text,
Text styles (bold, italics and underline),
Fonts (face, size, color).
rev. 002 - do -
rev. 3 ?
--------------------------------------------------------------------------------
This unit and all procedures and functions herein is released as
freeware. Any components or units created using this unit or
portions hereoff must be released as freeware (This does not
cover applications - they may be shareware/commercial as needed).
Part of the function RtfToHTML may be covered by some obscure
Microsoft copyright since it reads the RTF format - check it out
yourself, if you do something worthwhile.
Please let this preface stay if you publish a changed/updated
version of this unit and write all changes the "Revision history"
section above. Who-Dun-it information should be inserted in the
"Author list" and the "Supported features" section should be updated.
This makes it easier to pass the blame :-)
I'm finished with this unit for now - but please email a copy of
any changes you make to me - Troels S Eriksen.
--------------------------------------------------------------------------------
The following should be fixed - if anybody want to do it?
* Should be rewritten into a conversion class - could be tricky, since
it seems like a stream only contains 4 Kb at a time ...
* Code should be cleaned up - this below is not that fast ...
* The indents (\li###) should be translated to or
just a with no - elements.
* The hanging paragraphs should be translated to definitionlists ( the
- term
- definition
structure )
* Tabs (\tab) should be fixed somehow ( heck, I DO want
a code ! )
* Embedded objects / pictures should be converted to .gif's
- I know it's possible
* Some nice way to handle links ( the way .rtf-sources for
helpfiles do ? )
* A even more nice way of handling tables - could fix the
indent / tab-problems as well
--------------------------------------------------------------------------------
The idea and logic behind this weirdo function :
Well, the idea was to write a pascal RTF-2-HTML converter which
doesn't just do some "search and replace" - but actually converts
the dammed stuff.
Since there's a difference between HTML and RTF in the
code-sequencing, I decided to try storing all paragraph and
textformatting information in two records (PARFMT and
TXTFMT) and only write the contents of these to the output
"stream" when needed.
This first attempt is successfull - not highly, but it'll convert
the contents of a TRichEdit control and most other .rtf documents
to HTML and keep the general layout.
Enjoy it
Troels S Eriksen, Denmark
--------------------------------------------------------------------------------
*) {$LONGSTRINGS ON