PERLANCAR::HTML::Tree::Examples - Generate sample HTML document
This document describes version 1.0.3 of PERLANCAR::HTML::Tree::Examples (from Perl distribution PERLANCAR-HTML-Tree-Examples), released on 2016-04-07.
use PERLANCAR::HTML::Tree::Examples qw(gen_sample_data); my $html = gen_sample_data(size => 'medium1');
size=tiny1
<body data-level="0" id="1"> <h1 data-level="1" id="2"> </h1> <h1 data-level="1" id="3"> </h1> </body>
size=small1
<body data-level="0" id="1"> <h1 data-level="1" id="2"> <h2 data-level="2" id="3"> <h3 data-level="3" id="4"> </h3> <h3 data-level="3" id="5"> </h3> <h3 data-level="3" id="6"> <h4 data-level="4" id="7"> </h4> </h3> <h3 data-level="3" id="8"> </h3> </h2> </h1> <h1 data-level="1" id="9"> </h1> <h1 data-level="1" id="10"> <h2 data-level="2" id="11"> <h3 data-level="3" id="12"> (... 12 more line(s) not shown ...)
size=medium1
<body data-level="0" id="1"> <h1 data-level="1" id="2"> <h2 data-level="2" id="3"> <h3 data-level="3" id="4"> <h4 data-level="4" id="5"> </h4> <h4 data-level="4" id="6"> <h5 data-level="5" id="7"> </h5> </h4> </h3> <h3 data-level="3" id="8"> <h4 data-level="4" id="9"> </h4> </h3> </h2> <h2 data-level="2" id="10"> <h3 data-level="3" id="11"> <h4 data-level="4" id="12"> <h5 data-level="5" id="13"> (... 40782 more line(s) not shown ...)
Generate sample HTML document.
This routine can generate some sample HTML document with specified size (total number of elements and nested level). It is used for testing and benchmarking HTML::Parser or CSS selector like Mojo::DOM.
Mojo::DOM
This function is not exported by default, but exportable.
Arguments ('*' denotes required arguments):
size* => str
Which document to generate.
There are several predefined sizes to choose from. The sizes are roughly equivalent to sample trees in PERLANCAR::Tree::Examples.
PERLANCAR::Tree::Examples
tiny1 is a very tiny document, with only depth of 2 and a total of 3 elements, including root node.
tiny1
small1 is a document of depth 4 and a total of 16 elements, including root element.
small1
medium1 is a document of depth 7 and ~20k elements.
medium1
Return value: (str)
Please visit the project's homepage at https://metacpan.org/release/PERLANCAR-HTML-Tree-Examples.
Source repository is at https://github.com/perlancar/perl-PERLANCAR-HTML-Tree-Examples.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=PERLANCAR-HTML-Tree-Examples
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
show-perlancar-sample-html-tree (App::ShowPERLANCARSampleHTMLTree), a simple CLI to conveniently view the sample data.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2016 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install PERLANCAR::HTML::Tree::Examples, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PERLANCAR::HTML::Tree::Examples
CPAN shell
perl -MCPAN -e shell install PERLANCAR::HTML::Tree::Examples
For more information on module installation, please visit the detailed CPAN module installation guide.