FEATURE: stop escaping special chars in title prettify

This feature is confusting and just leads to inconsistency
This commit is contained in:
Sam 2017-03-13 10:02:20 -04:00
parent 9364d8ce71
commit 82ca0e368e
2 changed files with 2 additions and 19 deletions

View File

@ -120,9 +120,6 @@ class HtmlPrettify < String
unless in_pre unless in_pre
t.gsub!("&#39;", "'") t.gsub!("&#39;", "'")
t = process_escapes t
t.gsub!("&quot;", '"') t.gsub!("&quot;", '"')
if do_dashes if do_dashes
@ -176,22 +173,6 @@ class HtmlPrettify < String
protected protected
# Return the string, with after processing the following backslash
# escape sequences. This is useful if you want to force a "dumb" quote
# or other character to appear.
#
# Escaped are:
# \\ \" \' \. \- \`
#
def process_escapes(str)
str = str.gsub('\\\\', '&#92;')
str.gsub!('\"', '&#34;')
str.gsub!("\\\'", '&#39;')
str.gsub!('\.', '&#46;')
str.gsub!('\-', '&#45;')
str.gsub!('\`', '&#96;')
str
end
# The string, with each instance of "<tt>--</tt>" translated to an # The string, with each instance of "<tt>--</tt>" translated to an
# em-dash HTML entity. # em-dash HTML entity.

View File

@ -24,6 +24,8 @@ describe HtmlPrettify do
t 'src="test.png"&gt; yay', "src=&ldquo;test.png&rdquo;&gt; yay" t 'src="test.png"&gt; yay', "src=&ldquo;test.png&rdquo;&gt; yay"
t '\\\\mnt\\c', "\\\\mnt\\c"
t ERB::Util.html_escape('<img src="test.png"> yay'), "&lt;img src=&ldquo;test.png&rdquo;&gt; yay" t ERB::Util.html_escape('<img src="test.png"> yay'), "&lt;img src=&ldquo;test.png&rdquo;&gt; yay"
end end