diff --git a/lib/rdoc/ruby_lex.rb b/lib/rdoc/ruby_lex.rb index 7488b80773..c58be3d4f8 100644 --- a/lib/rdoc/ruby_lex.rb +++ b/lib/rdoc/ruby_lex.rb @@ -1211,7 +1211,7 @@ def identify_string(ltype, quoted = ltype, type = nil) str = if ltype == quoted and %w[" ' /].include? ltype then ltype.dup else - "%#{type or PERCENT_LTYPE.key ltype}#{PERCENT_PAREN_REV[quoted]||quoted}" + "%#{type}#{PERCENT_PAREN_REV[quoted]||quoted}" end subtype = nil diff --git a/test/test_rdoc_parser_ruby.rb b/test/test_rdoc_parser_ruby.rb index c369590ec9..b0719005ae 100644 --- a/test/test_rdoc_parser_ruby.rb +++ b/test/test_rdoc_parser_ruby.rb @@ -2838,7 +2838,7 @@ def test_sanity_interpolation_crazy def test_sanity_interpolation_curly util_parser '%{ #{} }' - assert_equal '%Q{ #{} }', @parser.get_tk.text + assert_equal '%{ #{} }', @parser.get_tk.text assert_equal RDoc::RubyToken::TkNL, @parser.get_tk.class end diff --git a/test/test_rdoc_ruby_lex.rb b/test/test_rdoc_ruby_lex.rb index 5ded86fd8c..cf2f23eeb3 100644 --- a/test/test_rdoc_ruby_lex.rb +++ b/test/test_rdoc_ruby_lex.rb @@ -286,6 +286,17 @@ def test_class_tokenize_percent_w_quote assert_equal expected, tokens end + def test_class_tokenize_percent_sign_quote + tokens = RDoc::RubyLex.tokenize '%%hi%', nil + + expected = [ + @TK::TkSTRING.new( 0, 1, 0, '%%hi%'), + @TK::TkNL .new( 5, 1, 5, "\n"), + ] + + assert_equal expected, tokens + end + def test_class_tokenize_regexp tokens = RDoc::RubyLex.tokenize "/hay/", nil