Skip to content

Commit c4bac39

Browse files
committed
Merge pull request #16 from pathawks/gsub
Combine two gsubs into one
2 parents c29c923 + b6f0963 commit c4bac39

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/jekyll-seo-tag.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ class SeoTag < Liquid::Tag
33

44
attr_accessor :context
55

6+
HTML_ESCAPE = {
7+
"\u201c".freeze => '&ldquo;'.freeze,
8+
"\u201d".freeze => '&rdquo;'.freeze
9+
}
10+
HTML_ESCAPE_REGEX = Regexp.union(HTML_ESCAPE.keys).freeze
11+
612
def render(context)
713
@context = context
814
output = Liquid::Template.parse(template_contents).render!(payload, info)
@@ -11,8 +17,7 @@ def render(context)
1117
output.gsub!(/[\s]{2,}/, "\n")
1218

1319
# Encode smart quotes. See https://github.com/benbalter/jekyll-seo-tag/pull/6
14-
output.gsub!("\u201c", "&ldquo;")
15-
output.gsub!("\u201d", "&rdquo;")
20+
output.gsub!(HTML_ESCAPE_REGEX, HTML_ESCAPE)
1621

1722
output
1823
end

0 commit comments

Comments
 (0)