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