class Microformat::SchemaOrg

Public Class Methods

parse(html, opts={}) click to toggle source
# File lib/microformat.rb, line 107
def self.parse(html, opts={})
  strict = opts.has_key? :strict ? opts[:strict] : true
  html = Nokogiri::HTML.parse html unless html.respond_to? :search
  scopes = html.search('//*[@itemscope and not(@itemprop)]')
    .map { |node| ItemScope.new node, strict }

  if scopes.any?
    ItemDocument.new scopes
  else
    nil
  end
end