method
markup_code
v1_8_7_72 -
Show latest stable
- Class:
Generators::HtmlMethod
markup_code(tokens)public
Given a sequence of source tokens, mark up the source code to make it look purty.
# File lib/rdoc/generators/html_generator.rb, line 1057
def markup_code(tokens)
src = ""
tokens.each do |t|
next unless t
# p t.class
# style = STYLE_MAP[t.class]
style = case t
when RubyToken::TkCONSTANT then "ruby-constant"
when RubyToken::TkKW then "ruby-keyword kw"
when RubyToken::TkIVAR then "ruby-ivar"
when RubyToken::TkOp then "ruby-operator"
when RubyToken::TkId then "ruby-identifier"
when RubyToken::TkNode then "ruby-node"
when RubyToken::TkCOMMENT then "ruby-comment cmt"
when RubyToken::TkREGEXP then "ruby-regexp re"
when RubyToken::TkSTRING then "ruby-value str"
when RubyToken::TkVal then "ruby-value"
else
nil
end
text = CGI.escapeHTML(t.text)
if style
src << "<span class=\"#{style}\">#{text}</span>"
else
src << text
end
end
add_line_numbers(src) if Options.instance.include_line_numbers
src
end Related methods
- Instance methods
- <=>
- add_line_numbers
- aliases
- aref
- as_href
- call_seq
- create_source_code_file
- description
- document_self
- find_symbol
- index_name
- markup_code
- name
- params
- parent_name
- path
- section
- singleton
- visibility
- Class methods
- all_methods
- new
- reset