20.4. Converting ASCII to HTML20.4.1. ProblemYou want to convert ASCII text to HTML. For example, you have mail you want to display intelligently on a web page. 20.4.2. SolutionUse the simple little encoding filter in Example 20-3. Example 20-3. text2html
20.4.3. DiscussionConverting arbitrary plain text to HTML has no general solution because there are too many conflicting ways to represent formatting information. The more you know about the input, the better you can format it. For example, if you knew that you would be fed a mail message, you could add this block to format the mail headers:
The CPAN module HTML::TextToHTML has options for headers, footers, indentation, tables, and more. 20.4.4. See AlsoThe documentation for the CPAN modules HTML::Entities and HTML::TextToHTML
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|