Sha256: 0939b371c34f254dcb7b6db8afaa7c6f67d02bc0003f70cfe34ed710f959aeea
Contents?: true
Size: 1.41 KB
Versions: 3
Compression:
Stored size: 1.41 KB
Contents
require "reflexive/routing_helpers" require "coderay" require "coderay/encoder" require "coderay/encoders/html" module Reflexive class CodeRayHtmlEncoder < ::CodeRay::Encoders::HTML include RoutingHelpers def token(text, type = :plain, tags = {}) if constant_access = tags[:constant_access] name, scope = constant_access.values_at(:name, :scope) @out << "<a href='#{ constant_lookup_path(name, scope) }'>" super(text, type) @out << "</a>" elsif type == :meta_scope # pass elsif type == :content && tags[:load_path] @out << "<a href='#{ load_path_lookup_path(text) }'>" super(text, type) @out << "</a>" elsif method_call = tags[:method_call] @out << "<a href='#{ method_call_path(method_call) }'>" super(text, type) @out << "</a>" elsif local_variable_assignment = tags[:local_variable_assignment] @out << "<span id='lv:#{ local_variable_assignment }'>" super(text, type) @out << "</span>" elsif local_variable_access = tags[:local_variable_access] @out << "<a href='#lv:#{ local_variable_access }' class='lva'>" super(text, type) @out << "</a>" else super(text, type) end end def compile(tokens, options) for token in tokens token(*token) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
reflexive-0.1.2 | lib/reflexive/coderay_html_encoder.rb |
reflexive-0.1.1 | lib/reflexive/coderay_html_encoder.rb |
reflexive-0.1.0 | lib/reflexive/coderay_html_encoder.rb |