diff --git a/lib/rdoc/token_stream.rb b/lib/rdoc/token_stream.rb index 5a4ca82a67..8b0d49d295 100644 --- a/lib/rdoc/token_stream.rb +++ b/lib/rdoc/token_stream.rb @@ -45,13 +45,7 @@ def self.to_html(token_stream) then 'ruby-identifier' end - comment_with_nl = false - if :on_comment == t[:kind] or :on_embdoc == t[:kind] or :on_heredoc_end == t[:kind] - comment_with_nl = true if "\n" == t[:text][-1] - text = t[:text].rstrip - else - text = t[:text] - end + text = t[:text] if :on_ident == t[:kind] && starting_title starting_title = false @@ -65,7 +59,11 @@ def self.to_html(token_stream) text = CGI.escapeHTML text if style then - "#{text}#{"\n" if comment_with_nl}" + if text.end_with?("\n") + newline = "\n" + text = text.byteslice(0...-1) + end + "#{text}#{newline}" else text end