From bc4854fa426a39c2bd51b2fd1cfa0322a5a9a412 Mon Sep 17 00:00:00 2001 From: Kornelius Kalnbach Date: Wed, 20 Nov 2013 15:54:41 +0100 Subject: don't escape " in HTML --- lib/coderay/encoders/html.rb | 3 +-- test/functional/basic.rb | 4 ++-- test/functional/examples.rb | 8 ++++---- test/functional/for_redcloth.rb | 4 ++-- test/unit/html.rb | 4 ++-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb index c21b19d..7e83eb8 100644 --- a/lib/coderay/encoders/html.rb +++ b/lib/coderay/encoders/html.rb @@ -129,7 +129,6 @@ module Encoders def self.make_html_escape_hash { '&' => '&', - '"' => '"', '>' => '>', '<' => '<', "\t" => ' ' * DEFAULT_OPTIONS[:tab_width], @@ -140,7 +139,7 @@ module Encoders end HTML_ESCAPE = make_html_escape_hash - HTML_ESCAPE_PATTERN = /[\t"&><\0-\x8\xB-\x1F]/ + HTML_ESCAPE_PATTERN = /[\t&><\0-\x8\xB-\x1F]/ TOKEN_KIND_TO_INFO = Hash.new do |h, kind| h[kind] = kind.to_s.gsub(/_/, ' ').gsub(/\b\w/) { $&.capitalize } diff --git a/test/functional/basic.rb b/test/functional/basic.rb index 752d4ba..917b5ff 100755 --- a/test/functional/basic.rb +++ b/test/functional/basic.rb @@ -46,8 +46,8 @@ class BasicTest < Test::Unit::TestCase end end - RUBY_TEST_HTML = 'puts "' + - 'Hello, World!"' + RUBY_TEST_HTML = 'puts "' + + 'Hello, World!"' def test_simple_highlight assert_nothing_raised do assert_equal RUBY_TEST_HTML, CodeRay.scan(RUBY_TEST_CODE, :ruby).html diff --git a/test/functional/examples.rb b/test/functional/examples.rb index 985ef87..8da4fc7 100755 --- a/test/functional/examples.rb +++ b/test/functional/examples.rb @@ -10,7 +10,7 @@ class ExamplesTest < Test::Unit::TestCase div = CodeRay.scan('puts "Hello, world!"', :ruby).div assert_equal <<-DIV, div
-
puts "Hello, world!"
+
puts "Hello, world!"
DIV @@ -40,7 +40,7 @@ end - +
1
 
puts "Hello, world!"
puts "Hello, world!"
@@ -92,7 +92,7 @@ Token Types (7): div = tokens.div(:css => :class) assert_equal <<-DIV, div
-
{ "just": "an", "example": 42 }
+
{ "just": "an", "example": 42 }
DIV @@ -121,7 +121,7 @@ Token Types (7): div = ruby_highlighter.encode('puts "Hello, world!"') assert_equal <<-DIV, div
-
puts "Hello, world!"
+
puts "Hello, world!"
DIV end diff --git a/test/functional/for_redcloth.rb b/test/functional/for_redcloth.rb index 9fd244e..eebf19c 100644 --- a/test/functional/for_redcloth.rb +++ b/test/functional/for_redcloth.rb @@ -16,11 +16,11 @@ class BasicTest < Test::Unit::TestCase def test_for_redcloth require 'coderay/for_redcloth' - assert_equal "

puts "Hello, World!"

", + assert_equal "

puts \"Hello, World!\"

", RedCloth.new('@[ruby]puts "Hello, World!"@').to_html assert_equal <<-BLOCKCODE.chomp,
-
puts "Hello, World!"
+
puts "Hello, World!"
BLOCKCODE RedCloth.new('bc[ruby]. puts "Hello, World!"').to_html diff --git a/test/unit/html.rb b/test/unit/html.rb index 0072635..750b6c9 100644 --- a/test/unit/html.rb +++ b/test/unit/html.rb @@ -60,7 +60,7 @@ public class Test { * used to test the */ public class Test { - public static final String MESSAGE = "My message To the world"; + public static final String MESSAGE = \"My message To the world\"; static void main() { /* @@ -80,7 +80,7 @@ public class Test { * used to test the */ public class Test { - public static final String MESSAGE = "My message To the world"; + public static final String MESSAGE = \"My message To the world\"; static void main() { /* -- cgit v1.2.1