lib/rdf/rdfa/reader.rb in rdf-rdfa-1.1.2 vs lib/rdf/rdfa/reader.rb in rdf-rdfa-1.1.3

- old
+ new

@@ -365,21 +365,24 @@ def extract_script(el, input, type, options, &block) add_debug(el, "script element of type #{type}") begin # Formats don't exist unless they've been required - case type + case type.to_s when 'application/rdf+xml' then require 'rdf/rdfxml' - when 'text/ntriples' then require 'rdf/ntriples' - when 'text/turtle' then require 'text/turtle' + when 'text/ntriples' then require 'rdf/ntriples' + when 'text/turtle' then require 'rdf/turtle' + when 'application/ld+json' then require 'json/ld' end rescue end if reader = RDF::Reader.for(:content_type => type) add_debug(el, "=> reader #{reader.to_sym}") reader.new(input, options).each(&block) + else + add_debug(el, "=> no reader found") end end # Look for Embedded Turtle and RDF/XML unless @root.xpath("//rdf:RDF", "xmlns:rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#").empty? @@ -389,11 +392,13 @@ end # Look for Embedded scripts @root.css("script[type]").each do |el| type = el.attribute("type") - - extract_script(el, el.inner_text, type, @options) do |statement| + + text = el.inner_html.sub(%r(\A\s*\<!\[CDATA\[)m, '').sub(%r(\]\]>\s*\Z)m, '') + + extract_script(el, text, type, @options) do |statement| @repository << statement end end # Look for Embedded microdata