NAME

HTML::WikiConverter - An HTML-to-wiki markup converter

SYNOPSIS

my $wc = new HTML::WikiConverter(
  html => $html
);

print $wc->output, "\n";

DESCRIPTION

There are lots of programs out there that convert wiki markup into HTML, but relatively few that convert HTML into wiki markup. HTML::WikiConverter falls into the latter category, converting HTML source into wiki markup.

HTML to wiki conversion may be used in conjunction with in-browser WYSIWYG text editors to provide a WYSIWYG wiki interface. For example, a wiki edit page could allow users to modify text using a WYSIWYG editor such as HTMLArea (see http://dynarch.com/mishoo/htmlarea.epl). When the page is saved, HTML is submitted to the server, which can then use HTML::WikiConverter to translate the HTML back to its wikitext equivalent. Some alternative solutions are enumerated at http://meta.wikipedia.org/wiki/WYSIWYG_editor.

METHODS

new
$wc = new HTML::WikiConverter( %attribs )

Accepts a list of attribute name/value pairs and returns a new HTML::WikiConverter object. Allowed attribute names:

file      - (scalar) name of HTML file to convert to wikitext
html      - (scalar) HTML source to convert
base_url  - (scalar) base URL used to make absolute URLs
dialect   - (scalar) wiki engine target (default is 'MediaWiki')
benchmark - (scalar) true value indicates that benchmarks
                     should be recorded

Supported wiki dialects are in the HTML::WikiConverter::Dialect namespace. The default installation of HTML::WikiConverter includes HTML::WikiConverter::Dialect::MediaWiki.

If both the 'file' and 'html' attributes are specified, only the 'file' attribute will be used. The HTML source (from the 'html' or 'file' attribute) is parsed immediately in the constructor.

All attributes (including those not listed above) will be passed to the dialect class when creating a tag handler instance.

file
$file = $wc->file

Returns the value of the 'file' property passed to the new constructor.

html
$html = $wc->html

Returns the value of the 'html' property passed to the new constructor.

root
$root = $wc->root

Returns the root HTML::Element of the HTML tree

dialect
tag_handler
tag_handler_class
$dialect       = $wc->dialect
$handler       = $wc->tag_handler
$handler_class = $wc->tag_handler_class

Related methods that return information about the current dialect being used to process incoming HTML. The dialect method returns whatever value was passed as the dialect property in the new constructor.

The tag_handler_class method returns the name of the dialect class, such as "HTML::WikiConverter::Dialect::MediaWiki".

The tag_handler returns the instance of the tag handler class that is being used for HTML conversion.

output
$output = $wc->output

Converts HTML input to wiki markup.

log
$log_output = $wc->log

Returns log information accumulated during conversion.

rendered_html
$html = $wc->rendered_html

Returns a pretty-printed version of the HTML that WikiConverter used to produce wikitext markup. This will almost certainly differ from the HTML input provided to new because of internal processing done by HTML::TreeBuilder, namely that all start tags are closed, HTML, BODY, and HEAD tags are automatically wrapped around the provided HTML source (if not already present), tags are converted to lowercase, tag attributes are quoted, etc.

This method is useful for debugging.

COPYRIGHT

Copyright (c) 2004 David J. Iberri

This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

David J. Iberri <diberri@yahoo.com>

1 POD Error

The following errors were encountered while parsing the POD:

Around line 341:

You forgot a '=back' before '=head1'