= '0.511';
1;
=pod
=head1 NAME
Web::Microformats2 - Read Microformats2 metadata from HTML or JSON
=head1 SYNOPSIS
use Web::Microformats2;
use v5.10;
my $mf2_parser = Web::Microformats2::Par
roperty is: '$name'";
}
my $serialized_mf2_doc = $mf2_doc->as_json;
my $other_mf2_doc = Web::Microformats2::Document->new_from_json(
$serialized_mf2_doc_from_somewhere_else
);
=head1 DESCRI
eryable in-memory object. They can also serialize this object
as JSON (using the Microformats2 rules for this), or read an already
JSON-serialized Microformats2 structure for further analysis.
See L<
);
use HTML::TreeBuilder::XPath;
use HTML::Entities;
use v5.10;
use Scalar::Util qw(blessed);
use JSON;
use DateTime::Format::ISO8601;
use URI;
use Carp;
use Web::Microformats2::Item;
use Web::Microf
b::Microformats2::Document;
use Moo;
use MooX::HandlesVia;
use Encode qw(encode_utf8);
use JSON qw(decode_json);
use List::Util qw(any);
use Types::Standard qw(HashRef ArrayRef InstanceOf);
use Web::
ub as_json {
my $self = shift;
my $data_for_json = {
rels => $self->rels,
'rel-urls' => $self->rel_urls,
items => $self->top_level_items,
};
return JSON->new-
or_json );
}
sub as_raw_data {
my $self = shift;
return decode_json( $self->as_json );
}
sub new_from_json {
my $class = shift;
my ( $json ) = @_;
my $data_ref = decode_json (
_property, but don't look for or insist on
# prefixes. Good for inflating from JSON, which has no
# prefix information.
sub add_base_property {
my $self = shi
{ 'no_prefixes' } ) {
@types = map { "h-$_" } @types;
}
return @types;
}
sub TO_JSON {
my $self = shift;
my $data = {
properties => $self->properties,
type =
a
L<Web::Microformats2::Document> instance, itself created by running
Microformats2-laden HTML or JSON through a L<Web::Microformats2::Parser>
object.
See L<Web::Microformats2> for further context an