pm_to_blib
Makefile
.emacs.desktop
+.build/*
[AutoPrereqs]
-[Prereqs]
-Test::XML = 0
\ No newline at end of file
+skip = (Test::XML|Arsenal|SimpleClass|SelectData|TestUtils|data::table2)
+
$self;
}
+sub HTML::Element::newnode {
+ my ($lol, $node_label, $new_node)=@_;
+
+ use Data::Rmap qw(rmap_array);
+
+ my ($mapresult) = rmap_array {
+
+
+ if ($_->[0] eq $node_label) {
+ $_ = $new_node;
+ Data::Rmap::cut($_);
+ } else {
+ $_;
+ }
+
+ } $lol;
+
+ $mapresult;
+
+}
sub HTML::Element::crunch {
my $container = shift;
</span>
+=head2 Tree-Killing Methods
+=head3 $tree->prune
-=head1 SEE ALSO
+This removes any nodes from the tree which consist of nothing or nothing but whitespace.
+See also delete_ignorable_whitespace in L<HTML::Element>.
-=over
+=head2 Loltree Functions
+
+A loltree is an arrayref consisting of arrayrefs which is used by
+C<< new_from__lol >> in L<HTML::Element> to produce HTML trees.
+The CPAN distro L<XML::Element::Tolol> creates such XML trees by parsing XML files,
+analagous to L<XML::Toolkit>. The purpose of the functions in this section is to allow
+you manipulate a loltree programmatically.
-=item * L<HTML::Tree>
+These could not be methods because if you bless a loltree, then HTML::Tree will barf.
-A perl package for creating and manipulating HTML trees
+=head3 HTML::Element::replace_node($lol, $node_label, $new_node)
-=item * L<HTML::ElementTable>
+Given this initial loltree:
+
+ my $initial_lol = [ note => [ shopping => [ item => 'sample' ] ] ];
+
+This code:
+
+ sub shopping_items {
+ my @shopping_items = map { [ item => _ ] } qw(bread butter beans) ;
+ \@shopping_items;
+ }
+
+ my $new_lol = HTML::Element::newnode($initial_lol, item => shopping_items());
+
+ will replace the single sample with a list of shopping items:
+
+
+ [
+ 'note',
+ [
+ 'shopping',
+ [
+ [
+ 'item',
+ 'bread'
+ ],
+ [
+ 'item',
+ 'butter'
+ ],
+ [
+ 'item',
+ 'beans'
+ ]
+ ]
+ ]
+ ];
+
+Thanks to kcott and the other Perlmonks in this thread:
+http://www.perlmonks.org/?node_id=912416
+
+
+=head1 SEE ALSO
+
+=head2 L<HTML::Tree>
+
+A perl package for creating and manipulating HTML trees.
+
+=head2 L<HTML::ElementTable>
An L<HTML::Tree> - based module which allows for manipulation of HTML
trees using cartesian coordinations.
-=item * L<HTML::Seamstress>
+=head2 * L<HTML::Seamstress>
An L<HTML::Tree> - based module inspired by
XMLC (L<http://xmlc.enhydra.org>), allowing for dynamic
HTML generation via tree rewriting.
+=head2 Push-style tmeplating systems
+
+A comprehensive cross-language
+L<list of push-style templating systems|http://perlmonks.org/?node_id=674225>.
+
+
=head1 TODO
=over
use lib qw(t/ t/m/);
use File::Slurp;
-use Test::More qw(no_plan);
+use Test::More;
use TestUtils;
use HTML::TreeBuilder;
tage();
+done_testing;
--- /dev/null
+<html>\r
+ <head>\r
+<script src="smooth/scripts/mootools-1.2.1-core-yc.js" type="text/javascript"></script>\r
+<script src="smooth/scripts/mootools-1.2-more.js" type="text/javascript"></script>\r
+<script src="smooth/scripts/jd.gallery.js" type="text/javascript"></script>\r
+ <link rel="stylesheet" /="/" href="smooth/css/jd.gallery.css"\r
+ media="screen" type="text/css">\r
+ </head>\r
+ <body>\r
+<script type="text/javascript">\r\r
+function startGallery() {\r\r
+var myGallery = new gallery($('myGallery'), {\r\r
+timed: true\r\r
+});\r\r
+}\r\r
+window.addEvent('domready', startGallery);\r\r
+</script>\r
+ <div id="myGallery">\r
+ <div class="imageElement">\r
+ <h3>Item 1 Title</h3>\r
+ <p>Item 1 Description</p>\r
+ <a href="gallery-images/item-1/" title="open image" class="open"></a>\r
+ <img /="/" alt="Item 1 Title"\r
+ src="http://smoothgallery.jondesign.net/assets/images/samples/77196_6784-gallery.jpg"\r
+ class="full"> <img /="/" alt="thumbnail of Item 1 Title"\r
+ src="http://smoothgallery.jondesign.net/assets/images/samples/77196_6784-mini.jpg"\r
+ class="thumbnail"></div>\r
+ </div>\r
+ </body>\r
+</html>\r
-<html>
- <head>
-<script src="smooth/scripts/mootools-1.2.1-core-yc.js" type="text/javascript"></script>
-<script src="smooth/scripts/mootools-1.2-more.js" type="text/javascript"></script>
-<script src="smooth/scripts/jd.gallery.js" type="text/javascript"></script>
- <link rel="stylesheet" /="/" href="smooth/css/jd.gallery.css"
- media="screen" type="text/css">
- </head>
- <body>
-<script type="text/javascript">
-function startGallery() {
-var myGallery = new gallery($('myGallery'), {
-timed: true
-});
-}
-window.addEvent('domready', startGallery);
-</script>
- <div id="myGallery">
- <div class="imageElement">
- <h3>Item 1 Title</h3>
- <p>Item 1 Description</p>
- <a href="gallery-images/item-1/" title="open image" class="open"></a>
- <img /="/" alt="Item 1 Title"
- src="http://smoothgallery.jondesign.net/assets/images/samples/77196_6784-gallery.jpg"
- class="full"> <img /="/" alt="thumbnail of Item 1 Title"
- src="http://smoothgallery.jondesign.net/assets/images/samples/77196_6784-mini.jpg"
- class="thumbnail"></div>
- </div>
- </body>
-</html>
+<html>\r
+ <head>\r
+<script src="smooth/scripts/mootools-1.2.1-core-yc.js" type="text/javascript"></script>\r
+<script src="smooth/scripts/mootools-1.2-more.js" type="text/javascript"></script>\r
+<script src="smooth/scripts/jd.gallery.js" type="text/javascript"></script>\r
+ <link rel="stylesheet" /="/" href="smooth/css/jd.gallery.css"\r
+ media="screen" type="text/css">\r
+ </head>\r
+ <body>\r
+<script type="text/javascript">\r\r
+function startGallery() {\r\r
+var myGallery = new gallery($('myGallery'), {\r\r
+timed: true\r\r
+});\r\r
+}\r\r
+window.addEvent('domready', startGallery);\r\r
+</script>\r
+ <div id="myGallery">\r
+ <div class="imageElement">\r
+ <h3>Item 1 Title</h3>\r
+ <p>Item 1 Description</p>\r
+ <a href="gallery-images/item-1/" title="open image" class="open"></a>\r
+ <img /="/" alt="Item 1 Title"\r
+ src="http://smoothgallery.jondesign.net/assets/images/samples/77196_6784-gallery.jpg"\r
+ class="full"> <img /="/" alt="thumbnail of Item 1 Title"\r
+ src="http://smoothgallery.jondesign.net/assets/images/samples/77196_6784-mini.jpg"\r
+ class="thumbnail"></div>\r
+ </div>\r
+ </body>\r
+</html>\r
-<table summary="Code page support in different versions
- of MS Windows."
- frame="hsides" rules="groups" border="2">
+<table frame="hsides" rules="groups" border="2">
<caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
<colgroup align="center"></colgroup>
<colgroup align="left"></colgroup>
-<table summary="Code page support in different versions
- of MS Windows."
- frame="hsides" rules="groups" border="2">
+<table frame="hsides" rules="groups" border="2">
<caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
<colgroup align="center"></colgroup>
<colgroup align="left"></colgroup>
<P>
- <TABLE border="2" frame="hsides" rules="groups"
- summary="Code page support in different versions
- of MS Windows.">
+ <TABLE border="2" frame="hsides" rules="groups">
<CAPTION>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</CAPTION>
<COLGROUP align="center">
<COLGROUP align="left">
-<table summary="Code page support in different versions
- of MS Windows."
- frame="hsides" rules="groups" border="2">
+<table frame="hsides" rules="groups" border="2">
<caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
<colgroup align="center"></colgroup>
<colgroup align="left"></colgroup>
-<table summary="Code page support in different versions
- of MS Windows."
- frame="hsides" rules="groups" border="2">
+<table frame="hsides" rules="groups" border="2">
<caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
<colgroup align="center"></colgroup>
<colgroup align="left"></colgroup>
<P>
- <TABLE border="2" frame="hsides" rules="groups"
- summary="Code page support in different versions
- of MS Windows.">
+ <TABLE border="2" frame="hsides" rules="groups">
<CAPTION>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</CAPTION>
<COLGROUP align="center">
<COLGROUP align="left">
-<table summary="Code page support in different versions
- of MS Windows."
- frame="hsides" rules="groups" border="2">
+<table frame="hsides" rules="groups" border="2">
<caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
<colgroup align="center"></colgroup>
<colgroup align="left"></colgroup>
-<table summary="Code page support in different versions
- of MS Windows."
- frame="hsides" rules="groups" border="2">
+<table frame="hsides" rules="groups" border="2">
<caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
<colgroup align="center"></colgroup>
<colgroup align="left"></colgroup>
<P>
- <TABLE border="2" frame="hsides" rules="groups"
- summary="Code page support in different versions
- of MS Windows.">
+ <TABLE border="2" frame="hsides" rules="groups">
<CAPTION>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</CAPTION>
<COLGROUP align="center">
<COLGROUP align="left">
href="http://search.cpan.org/search?query=Element%3A%3ALibrary&mode=all">
<code>HTML::Element::Library</code> </a>. </p>
<p>
- <table
- summary="Code page support in different versions
- of MS Windows."
- frame="hsides" rules="groups" border="2">
+ <table frame="hsides" rules="groups" border="2">
<caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
<colgroup align="center"></colgroup>
<colgroup align="left"></colgroup>
href="http://search.cpan.org/search?query=Element%3A%3ALibrary&mode=all">
<code>HTML::Element::Library</code> </a>. </p>
<p>
- <table
- summary="Code page support in different versions
- of MS Windows."
- frame="hsides" rules="groups" border="2">
+ <table frame="hsides" rules="groups" border="2">
<caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
<colgroup align="center"></colgroup>
<colgroup align="left"></colgroup>
<P>
- <TABLE border="2" frame="hsides" rules="groups"
- summary="Code page support in different versions
- of MS Windows.">
+ <TABLE border="2" frame="hsides" rules="groups">
<CAPTION>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</CAPTION>
<COLGROUP align="center">
<COLGROUP align="left">
--- /dev/null
+<table summary="Code page support in different versions
+ of MS Windows."
+ frame="hsides" rules="groups" border="2">
+ <caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
+ <colgroup align="center"></colgroup>
+ <colgroup align="left"></colgroup>
+ <colgroup align="center" span="2"></colgroup>
+ <colgroup align="center" span="3">
+ <thead valign="top">
+ <tr>
+ <th>Code-Page<br>ID </th>
+ <th>Name </th>
+ <th>ACP </th>
+ <th>OEMCP </th>
+ <th>Windows<br>NT 3.1 </th>
+ <th>Windows<br>NT 3.51 </th>
+ <th>Windows<br>95 </th>
+ </tr>
+ <tbody>
+ <tr>
+ <td>1200</td>
+ <td>Unicode (BMP of ISO/IEC-10646)</td>
+ <td></td>
+ <td></td>
+ <td>X</td>
+ <td>X</td>
+ <td>* </td>
+ </tr>
+ <tr>
+ <td>1250</td>
+ <td>Windows 3.1 Eastern European</td>
+ <td>X</td>
+ <td></td>
+ <td>X</td>
+ <td>X</td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>1251</td>
+ <td>Windows 3.1 Cyrillic</td>
+ <td>X</td>
+ <td></td>
+ <td>X</td>
+ <td>X</td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>1252</td>
+ <td>Windows 3.1 US (ANSI)</td>
+ <td>X</td>
+ <td></td>
+ <td>X</td>
+ <td>X</td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>1253</td>
+ <td>Windows 3.1 Greek</td>
+ <td>X</td>
+ <td></td>
+ <td>X</td>
+ <td>X</td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>1254</td>
+ <td>Windows 3.1 Turkish</td>
+ <td>X</td>
+ <td></td>
+ <td>X</td>
+ <td>X</td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>1255</td>
+ <td>Hebrew</td>
+ <td>X</td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>1256</td>
+ <td>Arabic</td>
+ <td>X</td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>1257</td>
+ <td>Baltic</td>
+ <td>X</td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>1361</td>
+ <td>Korean (Johab)</td>
+ <td>X</td>
+ <td></td>
+ <td></td>
+ <td>**</td>
+ <td>X </td>
+ </tr>
+ </tbody>
+ <tbody>
+ <tr>
+ <td>437</td>
+ <td>MS-DOS United States</td>
+ <td></td>
+ <td>X</td>
+ <td>X</td>
+ <td>X</td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>708</td>
+ <td>Arabic (ASMO 708)</td>
+ <td></td>
+ <td>X</td>
+ <td></td>
+ <td></td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>709</td>
+ <td>Arabic (ASMO 449+, BCON V4)</td>
+ <td></td>
+ <td>X</td>
+ <td></td>
+ <td></td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>710</td>
+ <td>Arabic (Transparent Arabic)</td>
+ <td></td>
+ <td>X</td>
+ <td></td>
+ <td></td>
+ <td>X </td>
+ </tr>
+ <tr>
+ <td>720</td>
+ <td>Arabic (Transparent ASMO)</td>
+ <td></td>
+ <td>X</td>
+ <td></td>
+ <td></td>
+ <td>X</td>
+ </tr>
+ </tbody>
+ </thead>
+ </colgroup>
+</table>
href="http://search.cpan.org/search?query=Element%3A%3ALibrary&mode=all">
<code>HTML::Element::Library</code> </a>. </p>
<p>
- <table
- summary="Code page support in different versions
- of MS Windows."
- frame="hsides" rules="groups" border="2">
+ <table frame="hsides" rules="groups" border="2">
<caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
<colgroup align="center"></colgroup>
<colgroup align="left"></colgroup>
href="http://search.cpan.org/search?query=Element%3A%3ALibrary&mode=all">
<code>HTML::Element::Library</code> </a>. </p>
<p>
- <table
- summary="Code page support in different versions
- of MS Windows."
- frame="hsides" rules="groups" border="2">
+ <table frame="hsides" rules="groups" border="2">
<caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
<colgroup align="center"></colgroup>
<colgroup align="left"></colgroup>
<P>
- <TABLE border="2" frame="hsides" rules="groups"
- summary="Code page support in different versions
- of MS Windows.">
+ <TABLE border="2" frame="hsides" rules="groups">
<CAPTION>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</CAPTION>
<COLGROUP align="center">
<COLGROUP align="left">
--- /dev/null
+#!/usr/bin/perl -T
+
+
+use warnings;
+use strict;
+
+use Test::More;
+use Test::XML;
+
+BEGIN {
+ use_ok('HTML::TreeBuilder');
+ use_ok('HTML::Element::Library');
+}
+
+
+my $initial_lol = [ note => [ shopping => [ item => 'sample' ] ] ];
+my $new_lol = HTML::Element::newnode($initial_lol, item => shopping_items());
+
+
+sub shopping_items {
+ my @shopping_items = map { [ item => $_ ] } qw(bread butter beans);
+ \@shopping_items;
+}
+
+my $expected = [
+ 'note',
+ [
+ 'shopping',
+ [
+ [
+ 'item',
+ 'bread'
+ ],
+ [
+ 'item',
+ 'butter'
+ ],
+ [
+ 'item',
+ 'beans'
+ ]
+ ]
+ ]
+ ];
+
+is_deeply($new_lol, $expected, 'test unrolling');
+
+
+
+done_testing;
use File::Slurp;
-use Test::More qw(no_plan);
+use Test::More;
use TestUtils;
use HTML::TreeBuilder;
is ($generated_html, File::Slurp::read_file("$root.exp"), $root);
+
+done_testing;
use File::Slurp;
-use Test::More qw(no_plan);
+use Test::More;
+use Test::XML;
use TestUtils;
my $generated_html = ptree($tree, "$root.gen");
-is ($generated_html, File::Slurp::read_file("$root.exp"),
- "HTML for non-alternating table");
+is($generated_html, File::Slurp::read_file("$root.exp"), 'genhtml');
+
+
+done_testing;