diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index 8b09c1b..f638ed3 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -5,7 +5,16 @@ module Jekyll def render(context) @context = context - Liquid::Template.parse(template_contents).render!(payload, info).gsub(/[\n\s]{2,}/, "\n") + output = Liquid::Template.parse(template_contents).render!(payload, info) + + # Minify + output.gsub!(/[\n\s]{2,}/, "\n") + + # Encode smart quotes. See https://github.com/benbalter/jekyll-seo-tag/pull/6 + output.gsub!("\u201c", "“") + output.gsub!("\u201d", "”") + + output end private diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 9f9d6fa..6b6fbba 100644 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -35,7 +35,14 @@ describe Jekyll::SeoTag do it "escapes titles" do site = site({"title" => 'Jekyll & "Hyde"'}) context = context({ :site => site }) - expect(subject.render(context)).to match(/Jekyll & “Hyde”<\/title>/) + expect(subject.render(context)).to match(/<title>Jekyll & “Hyde”<\/title>/) + end + + it "escapes descriptions" do + site = site({"description" => 'Jekyll & "Hyde"'}) + context = context({ :site => site }) + expected = /<meta name="description" content="Jekyll & “Hyde”" \/>/ + expect(subject.render(context)).to match(expected) end it "uses the page description" do