The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PERLANCAR::HTML::Tree::Examples - Generate sample HTML document

VERSION

This document describes version 1.0.3 of PERLANCAR::HTML::Tree::Examples (from Perl distribution PERLANCAR-HTML-Tree-Examples), released on 2016-04-07.

SYNOPSIS

 use PERLANCAR::HTML::Tree::Examples qw(gen_sample_data);

 my $html = gen_sample_data(size => 'medium1');

DESCRIPTION

Overview of available sample data

  • 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 ...)

FUNCTIONS

gen_sample_data(%args) -> str

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.

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.

    tiny1 is a very tiny document, with only depth of 2 and a total of 3 elements, including root node.

    small1 is a document of depth 4 and a total of 16 elements, including root element.

    medium1 is a document of depth 7 and ~20k elements.

Return value: (str)

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/PERLANCAR-HTML-Tree-Examples.

SOURCE

Source repository is at https://github.com/perlancar/perl-PERLANCAR-HTML-Tree-Examples.

BUGS

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.

SEE ALSO

show-perlancar-sample-html-tree (App::ShowPERLANCARSampleHTMLTree), a simple CLI to conveniently view the sample data.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

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.