diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-29 11:52:50 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-29 11:52:50 +0000 |
commit | 4790c08906f296eea070c06933a5c2484b30584e (patch) | |
tree | 2f1835afaf8562c9ae611c80b7361c1eaa79b897 /lib/rdoc/token_stream.rb | |
parent | 26a9bf756bf66e77dd7b897f7ad97a7ffdfb3275 (diff) |
Merge rdoc-6.0.0.beta1.
This version fixed strange behavior of ruby code parser.
We will list all of impromovement to Changelog when 6.0.0 releasing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/token_stream.rb')
-rw-r--r-- | lib/rdoc/token_stream.rb | 16 |
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 |