Skip to content

Commit

Permalink
Finish 3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Feb 11, 2018
2 parents f48587f + b3cdfb1 commit b90471b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 26 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.0.0
3.0.1
4 changes: 2 additions & 2 deletions lib/rdf/rdfa/reader/nokogiri.rb
Expand Up @@ -306,10 +306,10 @@ def doc_base(base)
case @host_language
when :xhtml1, :xhtml5, :html4, :html5
base_el = @doc.at_css("html>head>base")
base = base_el.attribute("href").to_s.split("#").first if base_el
base = base.join(base_el.attribute("href").to_s.split("#").first) if base_el
else
xml_base = root.attribute_with_ns("base", RDF::XML.to_s) if root
base = xml_base if xml_base
base = base.join(xml_base) if xml_base
end

base
Expand Down
4 changes: 2 additions & 2 deletions lib/rdf/rdfa/reader/rexml.rb
Expand Up @@ -329,10 +329,10 @@ def doc_base(base)
case @host_language
when :xhtml1, :xhtml5, :html4, :html5
base_el = ::REXML::XPath.first(@doc, "/html/head/base") rescue nil
base = base_el.attribute("href").to_s.split("#").first if base_el
base = base.join(base_el.attribute("href").to_s.split("#").first) if base_el
else
xml_base = root.attribute("base", RDF::XML.to_s) if root
base = xml_base if xml_base
base = base.join(xml_base) if xml_base
end

base || @base_uri
Expand Down
70 changes: 49 additions & 21 deletions spec/reader_spec.rb
Expand Up @@ -428,30 +428,58 @@
end
end

it "html>head>base" do
html = %(<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.1"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<head>
<base href="http://example/"></base>
<title>Test 0072</title>
</head>
<body>
<p about="faq">
Learn more by reading the example.org
<span property="dc:title">Example FAQ</span>.
</p>
</body>
</html>
describe "html>head>base" do
it "uses absolute base" do
html = %(<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.1"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<head>
<base href="http://example/"></base>
<title>Test 0072</title>
</head>
<body>
<p about="faq">
Learn more by reading the example.org
<span property="dc:title">Example FAQ</span>.
</p>
</body>
</html>
)
expected = %q(
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<http://example/faq> dc:title "Example FAQ" .
)
expected = %q(
@prefix dc: <http://purl.org/dc/elements/1.1/> .

<http://example/faq> dc:title "Example FAQ" .
)
expect(parse(html, base_uri: 'http://example.org/')).to be_equivalent_graph(expected, logger: logger, format: :ttl)
end

it "uses relative base" do
html = %(<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.1"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<head>
<base href="foo/"></base>
<title>Test 0072</title>
</head>
<body>
<p about="faq">
Learn more by reading the example.org
<span property="dc:title">Example FAQ</span>.
</p>
</body>
</html>
)
expected = %q(
@prefix dc: <http://purl.org/dc/elements/1.1/> .
expect(parse(html)).to be_equivalent_graph(expected, logger: logger, format: :ttl)
<http://example.org/foo/faq> dc:title "Example FAQ" .
)

expect(parse(html, base_uri: 'http://example.org/')).to be_equivalent_graph(expected, logger: logger, format: :ttl)
end
end

describe "xml:base" do
Expand Down

0 comments on commit b90471b

Please sign in to comment.