From b6f096372dc73d6a0fce52c98f8c5a138176c874 Mon Sep 17 00:00:00 2001 From: Pat Hawks Date: Tue, 5 Jan 2016 22:08:27 -0800 Subject: [PATCH] Combine two gsubs into one --- lib/jekyll-seo-tag.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index 0f9f649..7fa0d32 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -3,6 +3,12 @@ module Jekyll attr_accessor :context + HTML_ESCAPE = { + "\u201c".freeze => '“'.freeze, + "\u201d".freeze => '”'.freeze + } + HTML_ESCAPE_REGEX = Regexp.union(HTML_ESCAPE.keys).freeze + def render(context) @context = context output = Liquid::Template.parse(template_contents).render!(payload, info) @@ -11,8 +17,7 @@ module Jekyll output.gsub!(/[\s]{2,}/, "\n") # Encode smart quotes. See https://github.com/benbalter/jekyll-seo-tag/pull/6 - output.gsub!("\u201c", "“") - output.gsub!("\u201d", "”") + output.gsub!(HTML_ESCAPE_REGEX, HTML_ESCAPE) output end