HTML::Element::Convert - Monkeypatch content conversion methods into HTML::Element


HTML-Element-Convert documentation  | view source Contained in the HTML-Element-Convert distribution.

Index


NAME

Top

HTML::Element::Convert - Monkeypatch content conversion methods into HTML::Element

VERSION

Top

Version 0.10

SYNOPSIS

Top

  use HTML::TreeBulder;
  use HTML::Element::Convert;

  my $tree = HTML::TreeBuilder->new_from_content($html);

  # Search for some JSON-encoded meta-data embedded in the document and extract it:
  my $element = $tree->look_down(...);
  my $hash = $element->extract_content;

  # This time extract the YAML data and delete the containing element from the tree:
  $element = $tree->look_down(...);
  $hash = $element->pull_content;

  # Convert the content of any <div> with a 'lang="markdown"' attribute into HTML:
  $tree->convert_content;

$element->convert_content

Look for every div below $element containing a lang attribute. If it recognizes lang, it will convert and replace the div's content.

Currently, only markdown is supported.

$content = $element->extract_content([TYPE])

Extract and parse the content of $element. If TYPE is given, then this method will assume the content is of the given type, and try to parse it accordingly. Otherwise it will use the lang attribute of $element to detemine the type.

$content = $element->pull_content([TYPE])

Like extract_content, extract and parse the content of $element. It will also delete $element from the tree.

AUTHOR

Top

Robert Krimen, <rkrimen at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-html-element-convert at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-Element-Convert. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc HTML::Element::Convert

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/HTML-Element-Convert

* CPAN Ratings

http://cpanratings.perl.org/d/HTML-Element-Convert

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTML-Element-Convert

* Search CPAN

http://search.cpan.org/dist/HTML-Element-Convert

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


HTML-Element-Convert documentation  | view source Contained in the HTML-Element-Convert distribution.