Brendan Francis O'Connor > Data-Microformat-0.04 > Data::Microformat

Download:
Data-Microformat-0.04.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.04   Source  

NAME ^

Data::Microformat - A base class for hCards and related modules

VERSION ^

This documentation refers to Data::Microformat version 0.03.

DESCRIPTION ^

This is the base class used for a variety of modules in Data::Microformat. It contains several helpful methods to reduce code duplication. It shouldn't be instantiated on its own (as it won't do anything useful), but can be used as a base class for other Data::Microformat modules.

SUBROUTINES/METHODS ^

Data::Microformat->new

This method creates a new instance of whatever subclass on which it was called.

This method should not be called directly on Data::Microformat, as it will not be particularly useful.

Data::Microformat->parse($content [, $url])

This method simply takes the content passed in and makes an HTML tree out of it, then hands it off to the from_tree method to do the actual interpretation. Should you have an HTML::Element tree already, there is no need to parse the content again; simply pass the tree's root to the from_tree method.

If you are calling this method on the hCard class, you can pass an additional parameter of the source URL, and this will allow the representative hCard to be determined. This parameter is optional.

Data::Microformat->from_tree($tree)

This method takes an HTML::Element tree and finds microformats in it. It will return one or many of the calling class (assuming it finds them) depending on the call; if called in array context, it will return all that it finds, and if called in scalar context, it will return just one.

The module tries hard not to require absolute adherence to the published specifications, but there is only so much flexibility it can have. It does not require that all the "required" information be present in a microformat-- just that what is there be reasonably well-formatted, enough to make parsing possible.

Certain modules may override this if they have specific parsing concerns.

$base->to_html

$base->to_hcard

This method, called on an instance of Data::Microformat or its subclasses, will return an hCard HTML representation of the data present. This is most likely to be used when building your own microformatted data, but can be called on parsed content as well. The returned data is very lightly formatted, and it uses only <div> tags for markup, rather than <span> tags.

to_hcard is a synonym for to_html.

$base->to_text

This method, called on an instance of Data::Microformat or its subclasses, will return a plain text representation of the data present. This format uses indentation to show nesting, and attempts to be easily human-readable.

DEPENDENCIES ^

This module relies upon the following other modules:

HTML::Entities

HTML::TreeBuilder

HTML::Stream

Which can be obtained from CPAN.

BUGS ^

Please report any bugs or feature requests to bug-data-microformat at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Microformat. I will be notified,and then you'll automatically be notified of progress on your bug as I make changes.

AUTHOR ^

Brendan O'Connor, <perl at ussjoin.com>

COPYRIGHT ^

Copyright 2008, Six Apart Ltd. All rights reserved.

LICENSE ^

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

syntax highlighting: