aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/token_stream.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rdoc/token_stream.rb')
-rw-r--r--lib/rdoc/token_stream.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/rdoc/token_stream.rb b/lib/rdoc/token_stream.rb
index b0035227fa..0cfa2f1384 100644
--- a/lib/rdoc/token_stream.rb
+++ b/lib/rdoc/token_stream.rb
@@ -36,17 +36,27 @@ module RDoc::TokenStream
when RDoc::RubyToken::TkIVAR then 'ruby-ivar'
when RDoc::RubyToken::TkOp then 'ruby-operator'
when RDoc::RubyToken::TkId then 'ruby-identifier'
+ when RDoc::RubyToken::TkREGEXP then 'ruby-regexp'
+ when RDoc::RubyToken::TkDREGEXP then 'ruby-regexp'
when RDoc::RubyToken::TkNode then 'ruby-node'
when RDoc::RubyToken::TkCOMMENT then 'ruby-comment'
- when RDoc::RubyToken::TkREGEXP then 'ruby-regexp'
+ when RDoc::RubyToken::TkXSTRING then 'ruby-string'
when RDoc::RubyToken::TkSTRING then 'ruby-string'
when RDoc::RubyToken::TkVal then 'ruby-value'
end
- text = CGI.escapeHTML t.text
+ comment_with_nl = false
+ case t
+ when RDoc::RubyToken::TkRD_COMMENT, RDoc::RubyToken::TkHEREDOCEND
+ comment_with_nl = true if t.text =~ /\n$/
+ text = t.text.rstrip
+ else
+ text = t.text
+ end
+ text = CGI.escapeHTML text
if style then
- "<span class=\"#{style}\">#{text}</span>"
+ "<span class=\"#{style}\">#{text}</span>#{"\n" if comment_with_nl}"
else
text
end