microformats: willnorris.com/go/microformats Index | Files | Directories

package microformats

import "willnorris.com/go/microformats"

Package microformats provides a microformats parser, supporting both v1 and v2 syntax.

Usage:

import "willnorris.com/go/microformats"

Retrive the HTML contents of a page, and call Parse or ParseNode, depending on what input you have (an io.Reader or an html.Node).

To parse only a section of an HTML document, use a package like goquery to select the root node to parse from. For example, see cmd/gomf/main.go.

See also: http://microformats.org/wiki/microformats2

Index

Package Files

backcompat.go datetime.go microformats.go

type Data Uses

type Data struct {
    // Items includes all top-level microformats found on the page.
    Items []*Microformat `json:"items"`

    // Rels includes all related URLs found on the page (<a> or <link>
    // elements with a "rel" value).  Map keys are the rel value, mapped to
    // a slice of URLs with that relation.  For example:
    //
    //     map[string][]string{
    //         "author": {"http://example.com/a", "http://example.com/b"},
    //         "alternate": {"http://example.com/fr"},
    //     }
    //
    // Relative URL values are resolved to absolute URLs using the base URL
    // of the page.
    Rels map[string][]string `json:"rels"`

    // RelURLs maps related URLs found on the page to additional metadata
    // about that relationship. If a URL is linked to more than once, only
    // the metadata for the first link is included here.  Relative URL
    // values are resolved to absolute URLs using the base URL of the page.
    RelURLs map[string]*RelURL `json:"rel-urls"`
}

Data specifies all of the microformats and data parsed from a single HTML page.

func Parse Uses

func Parse(r io.Reader, baseURL *url.URL) *Data

Parse the microformats found in the HTML document read from r. baseURL is the URL this document was retrieved from and is used to resolve any relative URLs.

func ParseNode Uses

func ParseNode(doc *html.Node, baseURL *url.URL) *Data

ParseNode parses the microformats found in doc. baseURL is the URL this document was retrieved from and is used to resolve any relative URLs.

type Microformat Uses

type Microformat struct {
    Value      string                   `json:"value,omitempty"`
    HTML       string                   `json:"html,omitempty"`
    Type       []string                 `json:"type"`
    Properties map[string][]interface{} `json:"properties"`
    Shape      string                   `json:"shape,omitempty"`
    Coords     string                   `json:"coords,omitempty"`
    Children   []*Microformat           `json:"children,omitempty"`
    // contains filtered or unexported fields
}

Microformat specifies a single microformat object and its properties. It may represent a person, an address, a blog post, etc.

type RelURL Uses

type RelURL struct {
    Rels     []string `json:"rels,omitempty"`
    Text     string   `json:"text,omitempty"`
    Media    string   `json:"media,omitempty"`
    HrefLang string   `json:"hreflang,omitempty"`
    Title    string   `json:"title,omitempty"`
    Type     string   `json:"type,omitempty"`
}

RelURL represents the attributes of a URL. The URL value itself is the map key in the RelURLs field of the Data type.

Directories

PathSynopsis
ptdPackage ptd implements Post Type Discovery as defined by https://www.w3.org/TR/post-type-discovery/

Package microformats imports 12 packages (graph) and is imported by 2 packages. Updated 2018-09-14. Refresh now. Tools for package owners.