Module: YARD::Templates::Helpers::HtmlSyntaxHighlightHelper
- Defined in:
- lib/yard/templates/helpers/html_syntax_highlight_helper.rb,
lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
Instance Method Summary
Instance Method Details
- (Object) html_syntax_highlight_ruby(source)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/yard/templates/helpers/html_syntax_highlight_helper.rb', line 5 def html_syntax_highlight_ruby(source) tokenlist = Parser::Ruby::Legacy::TokenList.new(source) tokenlist.map do |s| prettyclass = s.class.class_name.sub(/^Tk/, '').downcase prettysuper = s.class.superclass.class_name.sub(/^Tk/, '').downcase case s when Parser::Ruby::Legacy::RubyToken::TkWhitespace, Parser::Ruby::Legacy::RubyToken::TkUnknownChar h s.text when Parser::Ruby::Legacy::RubyToken::TkId prettyval = h(s.text) "<span class='#{prettyval} #{prettyclass} #{prettysuper}'>#{prettyval}</span>" else "<span class='#{prettyclass} #{prettysuper}'>#{h s.text}</span>" end end.join end |