logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

HTML::Microformats::Format::XOXO - the XOXO microformat

Author

       Toby Inkster <tobyink@cpan.org>.

Bugs

       Please report any bugs to <http://rt.cpan.org/>.

Description

       HTML::Microformats::Format::XOXO inherits from HTML::Microformats::Format. See the base class definition
       for a description of property getter/setter methods, constructors, etc.

       Unlike most of the modules in the HTML::Microformats suite, the "data" method returns an
       HTML::Microformats::Format::XOXO::UL, HTML::Microformats::Format::XOXO::OL or
       HTML::Microformats::Format::XOXO::DL object, rather than a plain hashref.

   HTML::Microformats::Format::XOXO::DL
       Represents an HTML DL element.

       "$dl->get_values($key)"
           Treating  a  DL as a key-value structure, returns a list of values for a given key.  Each value is an
           HTML::Microformats::Format::XOXO::DD object.

       "$dl->as_hash"
           Returns  a  hash  of  keys  pointing   to   arrayrefs   of   values,   where   each   value   is   an
           HTML::Microformats::Format::XOXO::DD object.

       "$dl->as_array"
           Logically what you think get_values("*") might do.

   HTML::Microformats::Format::XOXO::UL
       Represents an HTML UL element.

       "$ul->as_array"
           Returns an array of values, where each is a HTML::Microformats::Format::XOXO::LI object.

   HTML::Microformats::Format::XOXO::OL
       Represents an HTML OL element.

       "$ol->as_array"
           Returns an array of values, where each is a HTML::Microformats::Format::XOXO::LI object.

   HTML::Microformats::Format::XOXO::LI
       Represents an HTML LI element.

       "$li->get_link_href"
           Returns the URL linked to by the first link found within the item.

       "$li->get_link_rel"
           Returns  the value of the rel attribute of the first link found within the item.  This is an unparsed
           string.

       "$li->get_link_type"
           Returns the value of the type attribute of the first link found within the item.  This is an unparsed
           string.

       "$li->get_link_title"
           Returns the value of the rel attribute of the first link found within the item if present;  the  link
           text otherwise.

       "$li->get_text"
           Returns  the  value  of the text in the LI element except for the first DL element within the LI, and
           the first UL or OL element.

       "$li->get_html"
           Returns the HTML code in the LI element except for the first DL element within the LI, and the  first
           UL or OL element.

       "$li->get_properties"
           Returns  an  HTML::Microformats::Format::XOXO::DL object representing the first DL element within the
           LI.

       "$li->get_children"
           Returns  an  HTML::Microformats::Format::XOXO::OL  or   HTML::Microformats::Format::XOXO::UL   object
           representing the first OL or UL element within the LI.

       "$li->get_value($key)"
           A shortcut for "$li->get_properties->get_values($key)".

   HTML::Microformats::Format::XOXO::DD
       This has an identical interface to HTML::Microformats::Format::XOXO::LI.

Disclaimer Of Warranties

       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.

perl v5.32.1                                       2021-09-12              HTML::Microformats::Format::XOXO(3pm)

Microformat

       HTML::Microformats::Format::XOXO supports XOXO as described at <http://microformats.org/wiki/xoxo>.

Name

       HTML::Microformats::Format::XOXO - the XOXO microformat

Rdf Output

       XOXO  does  not  map especially naturally to RDF, so this module returns the data as a JSON literal using
       the property <http://open.vocab.org/terms/json>.

See Also

       HTML::Microformats::Format, HTML::Microformats.

Synopsis

        use HTML::Microformats::DocumentContext;
        use HTML::Microformats::Format::XOXO;

        my $context = HTML::Microformats::DocumentContext->new($dom, $uri);
        my @objects = HTML::Microformats::Format::XOXO->extract_all(
                          $dom->documentElement, $context);
        my $list = $objects[0];

        # Let's assume this structure:
        #
        # <ol class="xoxo people">
        #   <li>
        #     <a href="http://tobyinkster.co.uk/">Toby Inkster</a>
        #     <dl>
        #       <dt>Eye colour</dt>
        #       <dd>Blue</dt>
        #       <dt>Hair colour</dt>
        #       <dd>Blonde</dt>
        #       <dd>Brown</dt>
        #     </dl>
        #   </li>
        # </ol>

        print $list->data->as_array->[0]->get_link_title;
        # Toby Inkster
        print $list->data->as_array->[0]->get_properties
             ->get_value('Eye colour')->[0];
        # Blue
        print join '-', $list->data->as_array->[0]
             ->get_value('Hair colour');
        # Blonde-Brown

See Also