From 1e6b9e55e9e50487e12a63078d36ba5ca4f63ff8 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Thu, 25 Feb 2016 13:56:13 -0500 Subject: [PATCH] minify json ld and test --- lib/jekyll-seo-tag.rb | 2 +- spec/jekyll_seo_tag_spec.rb | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index 92fb7be..1e10877 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -5,7 +5,7 @@ module Jekyll class SeoTag < Liquid::Tag attr_accessor :context - MINIFY_REGEX = /(>\n|[%}]})\s+(<|{[{%])/ + MINIFY_REGEX = /([>,]\n|[%}]})\s+?(<|{[{%]|[ ]+\")/ def initialize(_tag_name, text, _tokens) super diff --git a/spec/jekyll_seo_tag_spec.rb b/spec/jekyll_seo_tag_spec.rb index 49c6121..17c5f0e 100644 --- a/spec/jekyll_seo_tag_spec.rb +++ b/spec/jekyll_seo_tag_spec.rb @@ -133,6 +133,18 @@ describe Jekyll::SeoTag do it 'outputs the site title meta' do expect(output).to match(%r{}) end + + it 'minifies the output' do + expected = <<-EOS + +Foo + + + + +EOS + expect(output).to match(expected) + end end end @@ -167,6 +179,16 @@ describe Jekyll::SeoTag do expect(json_data['description']).to eql('description') expect(json_data['image']).to eql('/img.png') end + + it 'minifies JSON-LD' do + expected = <<-EOS + { + "@context" : "http://schema.org", + "@type" : "BlogPosting", + "headline": "post", +EOS + expect(output).to match(expected) + end end end