Combine two gsubs into one

This commit is contained in:
Pat Hawks 2016-01-05 22:08:27 -08:00
parent 9f3da7e6fe
commit b6f096372d
No known key found for this signature in database
GPG Key ID: F1746FF5F18B3D1B
1 changed files with 7 additions and 2 deletions

View File

@ -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