Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions lib/rdoc/token_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -65,7 +59,9 @@ def self.to_html(token_stream)
text = CGI.escapeHTML text

if style then
"<span class=\"#{style}\">#{text}</span>#{"\n" if comment_with_nl}"
end_with_newline = text.end_with?("\n")
text = text.chomp if end_with_newline
"<span class=\"#{style}\">#{text}</span>#{"\n" if end_with_newline}"
else
text
end
Comment on lines 61 to 67
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think this is more expressive:

      if style
        if text.end_with?("\n")
          "<span class=\"#{style}\">#{text.chomp}</span>\n"
        else
          "<span class=\"#{style}\">#{text}</span>"
        end
      else
        text
      end

Expand Down
Loading