Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions lib/rdoc/generator/markup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ def markup_code

src = RDoc::TokenStream.to_html @token_stream

# add initial whitespace so that the indent gets calculated correctly
src.prepend(' ' * @token_stream.first[:char_no]) if source_language == 'ruby' && @token_stream.first

# dedent the source
common_indent = src.length
src.scan(/^ *(?=\S)/) do |whitespace|
Expand Down
2 changes: 0 additions & 2 deletions lib/rdoc/generator/template/aliki/css/rdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,6 @@ main h6 a:hover {
.ruby-ivar { color: var(--code-orange); }
.ruby-operator { color: var(--code-green); }
.ruby-identifier { color: var(--code-blue); }
.ruby-node { color: var(--code-purple); }

.ruby-comment {
color: var(--color-neutral-500);
Expand All @@ -1037,7 +1036,6 @@ main h6 a:hover {
[data-theme="dark"] .ruby-ivar { color: var(--code-orange); }
[data-theme="dark"] .ruby-operator { color: var(--code-green); }
[data-theme="dark"] .ruby-identifier { color: var(--code-blue); }
[data-theme="dark"] .ruby-node { color: var(--code-purple); }

[data-theme="dark"] .ruby-comment {
color: var(--color-neutral-400);
Expand Down
1 change: 0 additions & 1 deletion lib/rdoc/generator/template/darkfish/css/rdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ main h6 {
.ruby-ivar { color: #B57614; } /* Brown */
.ruby-operator { color: #427B58; } /* Dark Teal */
.ruby-identifier { color: #076678; } /* Deep Teal */
.ruby-node { color: #8F3F71; } /* Plum */
.ruby-comment { color: #928374; font-style: italic; } /* Gray */
.ruby-regexp { color: #8F3F71; } /* Plum */
.ruby-value { color: #AF3A03; } /* Dark Orange */
Expand Down
34 changes: 17 additions & 17 deletions lib/rdoc/markup/to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'cgi/escape'
require 'cgi/util' unless defined?(CGI::EscapeExt)
require 'prism'
require 'rdoc/parser/ruby_colorizer'

##
# Outputs RDoc markup as HTML.
Expand Down Expand Up @@ -321,34 +322,33 @@ def accept_paragraph(paragraph)
@res << "</p>\n"
end

# Generate syntax highlighted html for ruby-like text.

def parsable_text_to_html(text)
tokens = RDoc::Parser::RubyColorizer.colorize(text)
result = RDoc::TokenStream.to_html tokens
result = result + "\n" unless result.end_with?("\n")
result
end

##
# Adds +verbatim+ to the output

def accept_verbatim(verbatim)
text = verbatim.text.rstrip
format = verbatim.format

klass = nil

# Apply Ruby syntax highlighting if
# - explicitly marked as Ruby (via ruby? which accepts :ruby or :rb)
# - no format specified but the text is parseable as Ruby
# Otherwise, add language class when applicable and skip Ruby highlighting
content = if verbatim.ruby? || (format.nil? && parseable?(text))
begin
tokens = RDoc::Parser::RipperStateLex.parse text
klass = ' class="ruby"'

result = RDoc::TokenStream.to_html tokens
result = result + "\n" unless "\n" == result[-1]
result
rescue
CGI.escapeHTML text
end
else
klass = " class=\"#{format}\"" if format
CGI.escapeHTML text
end
if verbatim.ruby? || (format.nil? && parseable?(text))
content = parsable_text_to_html(text)
klass = ' class="ruby"'
else
content = CGI.escapeHTML text
klass = " class=\"#{format}\"" if format
end

if @pipe
@res << "\n<pre><code>#{CGI.escapeHTML text}\n</code></pre>\n"
Expand Down
302 changes: 0 additions & 302 deletions lib/rdoc/parser/ripper_state_lex.rb

This file was deleted.

Loading
Loading