NAME

Tk::HyperText - An ROText widget which renders HTML code.

SYNOPSIS

use Tk::HyperText;

my $html = $mw->Scrolled ('HyperText',
  -scrollbars => 'ose',
  -wrap       => 'word',
)->pack (-fill => 'both', -expand => 1);

$html->setHandler (Title    => \&onNewTitle);
$html->setHandler (Resource => \&onResource);
$html->setHandler (Submit   => \&onFormSubmit);

$html->loadString (qq~<html>
  <head>
  <title>Hello world!</title>
  </head>
  <body bgcolor="#0099FF">
  <font size="6" family="Impact" color="#FFFFFF">
  <strong>Hello, world!</strong>
  </font>
  </body>
  </html>
~);

DESCRIPTION

Tk::HyperText is a widget derived from Tk::ROText that renders HTML code.

PURPOSE

First of all, Tk::HyperText is NOT expected to become a full-fledged web browser widget. This module's original idea was just to be a simple HTML-rendering widget, specifically to match the capabilities of the AOL Instant Messenger's HTML widgets. That is, to render basic text formatting, images, and hyperlinks. Anything this module does that's extra is only there because I was up to the challenge.

VERSION 0.06+

This module is NOT backwards compatible with versions 0.05 and below. Specifically, the module was rewritten to use HTML::TokeParser as its HTML parsing engine instead of parsing it as plain text. Also, the methods have all been changed. The old module's overloading of the standard Tk::Text methods was causing all kinds of problems, and since this isn't really a "drop-in" replacement for the other Text widgets, its methods don't need to follow the same format.

Also, support for Cascading StyleSheets doesn't work at this time. It may be re-implemented at a later date, but, as this widget is not meant to become a full-fledged web browser (see "PURPOSE"), the CSS support might not return.

EXAMPLE

Run the `demo.pl` script included in the distribution.

WIDGET-SPECIFIC OPTIONS

WIDGET METHODS

EVENTS

All events receive a reference to its parent widget as $_[0]. The following are the event handlers currently supported by Tk::HyperText:

HTML SUPPORT

The following tags and attributes are supported by this module:

<html>
<head>
<title>
<body>     (bgcolor, text, link, alink, vlink)
<a>        (href, target)
<br>
<p>
<form>     (name, action, method, enctype)
<textarea> (name, cols, rows, disabled)
<select>   (name, size, multiple)
<option>   (value, selected)
<input>    (name, type, size, value, maxlength, disabled, checked)
            types: text, password, checkbox, radio, button, submit, reset
<table>    (border, cellspacing, cellpadding)
<tr>
<td>       (colspan, rowspan)
  <th>
  <thead>
  <tbody>
  <tfoot>
<hr>       (height, size)
<img>      (src, width, height, vspace, hspace, align, alt)*
<font>     (face, size, color, back)
  <basefont>
<h1>..<h6>
<ol>       (type, start)
<ul>       (type)
<li>
<blockquote>
<div>      (align)
<span>
<pre>
<code>
  <tt>
  <kbd>
  <samp>
<center>
  <right>
  <left>
<sup>
<sub>
<big>
<small>
<b>
  <strong>
<i>
  <em>
  <address>
  <var>
  <cite>
  <def>
<u>
  <ins>
<s>
  <del>

SEE ALSO

Tk::ROText and Tk::Text.

CHANGES

0.12 Feb 25, 2016
- Add more dependencies to get CPANTS to pass.

0.11 Feb 23, 2016
- Add dependency on HTML::TokeParser.

0.10 Sep 18, 2015
- Add dependency on Tk::Derived.

0.09 Nov 11, 2013
- Reformatted as per CPAN::Changes::Spec -neilbowers

0.08 Nov  1, 2013
- Use hex() instead of eval() to convert hex strings into numbers.
- Set default values for body colors.
- Stop demo.pl from being installed; rename it to eg/example.

0.06 July 14, 2008
- The module uses HTML::TokeParser now and does "real" HTML parsing.
- Badly broke backwards compatibility.

0.05 July 11, 2007
- Added support for "tag permissions", so that you can allow/deny specific tags from
  being rendered (i.e. say you're making a chat client which uses HTML and you don't
  want people inserting images into their messages, or style sheets, etc)
- Added the tags <address>, <var>, <cite>, and <def>.
- Added the <hr> tag.
- Added two "default images" that are displayed when an <img> tag tries to show
  an image that couldn't be found, or was found but is a file type that isn't
  supported (e.g. <img src="index.html"> would show an "invalid image" icon).
- Bug fix: every opened tag that modifies your style will now copy all the other
  stacks. As a result, opening <font back="yellow">, then <font color="red">, and
  then closing the red font, will still apply the yellow background to the following
  text. The same is true for every tag.
- Added some support for Cascading StyleSheets.
- Added some actual use for the "active link color": it's used as the hover color
  on links (using it as a true active color is mostly useless, since most of the
  time the page won't remain very long when clicking on a link to even see it)

0.04 June 23, 2007
- Added support for the <basefont> tag.
- Added support for <ul>, <ol>, and <li>. I've even extended the HTML specs a
  little and added "diamonds" as a shape for <ul>, and allowed <ul> to specify
  a decimal escape code (<ul type="#0164">)
- Added a "page history", so that the "visited link color" on pages can actually
  be applied to the links.
- Fixed the <blockquote> so that the margin applies to the right side as well.

0.02 June 20, 2007
- Bugfix: on consecutive insert() commands (without clearing it in between),
  the entire content of the HTML already in the widget would be inserted again,
  in addition to the new content. This has been fixed.

0.01 June 20, 2007
- Initial release.

AUTHOR

Noah Petherbridge, http://www.kirsle.net/

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.