Types::HTML5 - types for parsing strings of HTML into DOMs
package My::Page { use Moo; use Types::HTML5 -types; has template => ( is => 'ro', isa => HtmlTree, coerce => 1, ); sub output_page { ...; } }
This is still at a very early stage of development and has no test suite yet.
This type library provides useful type constraints and coercions for working with HTML5::DOM and XML::LibXML.
HtmlTree
A blessed HTML::DOM::Tree object. Coercions from HTML5::DOM::Document objects, XML::LibXML::Document objects, HTML5::DOM::Element objects, strings of HTML or XHTML, filehandles, and Path::Tiny objects.
HtmlDocument
A blessed HTML::DOM::Document object. Coercions from HTML5::DOM::Tree objects, XML::LibXML::Document objects, HTML5::DOM::Element objects, strings of HTML or XHTML, filehandles, and Path::Tiny objects.
HtmlElement
A blessed HTML5::DOM::Element object. Can coerce from XML::LibXML::Element objects.
HtmlComment
A blessed HTML5::DOM::Comment object. Can coerce from XML::LibXML::Comment objects and plain strings.
HtmlText
A blessed HTML5::DOM::Text object. Can coerce from XML::LibXML::Text objects and plain strings.
XmlDocument
A blessed XML::LibXML::Document object. Coercions from HTML5::DOM::Tree objects, HTML5::DOM::Document objects, HTML5::DOM::Element objects, strings of HTML or XHTML, filehandles, and Path::Tiny objects.
XmlElement
A blessed XML::LibXML::Element object. Can coerce from HTML5::DOM::Element objects.
XmlComment
A blessed XML::LibXML::Comment object. Can coerce from HTML5::DOM::Comment objects and plain strings.
XmlText
A blessed XML::LibXML::Text object. Can coerce from HTML5::DOM::Text objects and plain strings.
str_to_html($str)
Converts a string of HTML to an HTML5::DOM::Tree.
str_to_xml($str)
Converts a string of HTML to an XML::LibXML::Document.
html_to_xml($node)
Converts from an HTML5::DOM node to an XML::LibXML node. Supports text nodes, comments, elements, documents, and trees.
xml_to_html($node)
Converts from an XML::LibXML node to a HTML5::DOM node. Supports text nodes, comments, elements, and documents. (XML::LibXML::Document becomes HTML5::DOM::Tree, not HTML5::DOM::Document.)
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Types-HTML5.
HTML5::DOM, XML::LibXML, Path::Tiny.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2018 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Types::HTML5, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Types::HTML5
CPAN shell
perl -MCPAN -e shell install Types::HTML5
For more information on module installation, please visit the detailed CPAN module installation guide.