Sha256: b2110edd41b8321187047a77234ef06ec24ae7d889b77efa8f2eb13f1c36861d

Contents?: true

Size: 892 Bytes

Versions: 15

Compression:

Stored size: 892 Bytes

Contents

module YARD
  module Templates
    module Helpers
      module HtmlSyntaxHighlightHelper
        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
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
yard-0.6.4 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.6.3 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.6.2 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.6.1 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.6.0 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.5.8 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.5.7 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.5.6 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.5.5 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.5.4 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.5.3 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.5.2 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.5.1p1 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.5.1 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb
yard-0.5.0 lib/yard/templates/helpers/html_syntax_highlight_helper18.rb