diff --git a/lib/rdoc/parser/ripper_state_lex.rb b/lib/rdoc/parser/ripper_state_lex.rb index cc7a87976c..5492f08726 100644 --- a/lib/rdoc/parser/ripper_state_lex.rb +++ b/lib/rdoc/parser/ripper_state_lex.rb @@ -494,7 +494,8 @@ class RDoc::Parser::RipperStateLex private def heredoc_end?(name, indent, tk) result = false if :on_heredoc_end == tk[:kind] then - tk_name = (indent ? tk[:text].gsub(/^ *(.+)\n?$/, '\1') : tk[:text].gsub(/\n\z/, '')) + tk_name = tk[:text].chomp + tk_name.lstrip! if indent if name == tk_name result = true end diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb index 8188318769..97abafca58 100644 --- a/test/rdoc/test_rdoc_parser_ruby.rb +++ b/test/rdoc/test_rdoc_parser_ruby.rb @@ -2914,6 +2914,21 @@ EXPECTED assert_equal expected, markup_code end + def test_parse_heredoc_end + code = "A = <