output valid html
This commit is contained in:
parent
20b578966e
commit
2969a521f5
|
@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
|
|||
spec.add_development_dependency "bundler", "~> 1.10"
|
||||
spec.add_development_dependency "rake", "~> 10.0"
|
||||
spec.add_development_dependency "rspec", "~> 3.3"
|
||||
spec.add_development_dependency "html-proofer", "~> 2.5"
|
||||
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
{% if seo_title %}
|
||||
{% assign seo_title = seo_title | escape | markdownify | strip_html | strip_newlines %}
|
||||
{% assign seo_title = seo_title | markdownify | strip_html | strip_newlines | escape_once %}
|
||||
{% endif %}
|
||||
|
||||
{% if page.description %}
|
||||
|
@ -27,7 +27,7 @@
|
|||
{% assign seo_description = site.description %}
|
||||
{% endif %}
|
||||
{% if seo_description %}
|
||||
{% assign seo_description = seo_description | escape | markdownify | strip_html | strip_newlines %}
|
||||
{% assign seo_description = seo_description | markdownify | strip_html | strip_newlines | escape_once %}
|
||||
{% endif %}
|
||||
|
||||
{% if seo_title %}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
{% seo %}
|
||||
</head>
|
||||
<body>
|
||||
{{ content }}
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Some "post" & a test
|
||||
description: A post
|
||||
layout: default
|
||||
---
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
layout: default
|
||||
---
|
|
@ -1,4 +1,7 @@
|
|||
---
|
||||
title: blah "blah" & blah
|
||||
description: Some description
|
||||
layout: default
|
||||
---
|
||||
|
||||
# Test
|
||||
|
|
|
@ -4,6 +4,10 @@ describe Jekyll::SeoTag do
|
|||
|
||||
subject { Jekyll::SeoTag.new("seo", nil, nil) }
|
||||
|
||||
before do
|
||||
Jekyll.logger.log_level = :error
|
||||
end
|
||||
|
||||
it "builds" do
|
||||
expect(subject.render(context)).to match(/Jekyll SEO tag/i)
|
||||
end
|
||||
|
@ -29,9 +33,9 @@ describe Jekyll::SeoTag do
|
|||
end
|
||||
|
||||
it "escapes titles" do
|
||||
site = site({"title" => "Jekyll & Hyde"})
|
||||
site = site({"title" => 'Jekyll & "Hyde"'})
|
||||
context = context({ :site => site })
|
||||
expect(subject.render(context)).to match(/<title>Jekyll & Hyde<\/title>/)
|
||||
expect(subject.render(context)).to match(/<title>Jekyll & “Hyde”<\/title>/)
|
||||
end
|
||||
|
||||
it "uses the page description" do
|
||||
|
@ -135,4 +139,14 @@ describe Jekyll::SeoTag do
|
|||
expected = /<meta property="og:image" content="http:\/\/foo.invalid\/foo.png" \/>/
|
||||
expect(subject.render(context)).to match(expected)
|
||||
end
|
||||
|
||||
it "outputs valid HTML" do
|
||||
site.process
|
||||
options = {
|
||||
:check_html => true,
|
||||
:checks_to_ignore => ["ScriptCheck", "LinkCheck", "ImageCheck"]
|
||||
}
|
||||
status = HTML::Proofer.new(dest_dir, options).run
|
||||
expect(status).to eql(true)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
||||
require 'jekyll'
|
||||
require 'jekyll-seo-tag'
|
||||
require 'html/proofer'
|
||||
|
||||
ENV["JEKYLL_LOG_LEVEL"] = "error"
|
||||
|
||||
def dest_dir
|
||||
File.expand_path("../tmp/dest", File.dirname(__FILE__))
|
||||
end
|
||||
|
||||
def source_dir
|
||||
File.expand_path("./fixtures", File.dirname(__FILE__))
|
||||
end
|
||||
|
||||
CONFIG_DEFAULTS = {
|
||||
"source" => File.expand_path("./fixtures", File.dirname(__FILE__)),
|
||||
"destination" => File.expand_path("../tmp/dest", File.dirname(__FILE__)),
|
||||
"source" => source_dir,
|
||||
"destination" => dest_dir,
|
||||
"gems" => ["jekyll-seo-tag"]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue