module GitHub::Markup
Constants
- VERSION
- Version
Public Instance Methods
can_render?(filename, content, symlink: false)
click to toggle source
# File lib/github/markup.rb, line 81 def can_render?(filename, content, symlink: false) renderer(filename, content, symlink: symlink) != nil end
command(symbol, command, regexp, languages, name, &block)
click to toggle source
# File lib/github/markup.rb, line 72 def command(symbol, command, regexp, languages, name, &block) if File.exist?(file = File.dirname(__FILE__) + "/commands/#{command}") command = file end impl = CommandImplementation.new(regexp, languages, command, name, &block) markup_impl(symbol, impl) end
language(filename, content, symlink: false)
click to toggle source
# File lib/github/markup.rb, line 92 def language(filename, content, symlink: false) return unless defined?(::Linguist) blob = Linguist::Blob.new(filename, content, symlink: symlink) Linguist.detect(blob, allow_empty: true) end
markup(symbol, gem_name, regexp, languages, opts = {}, &block)
click to toggle source
# File lib/github/markup.rb, line 60 def markup(symbol, gem_name, regexp, languages, opts = {}, &block) impl = GemImplementation.new(regexp, languages, gem_name, &block) markup_impl(symbol, impl) end
markup_impl(symbol, impl)
click to toggle source
# File lib/github/markup.rb, line 65 def markup_impl(symbol, impl) if markups.key?(symbol) raise ArgumentError, "The '#{symbol}' symbol is already defined." end markups[symbol] = impl end
markup_impls()
click to toggle source
# File lib/github/markup.rb, line 34 def markup_impls markups.values end
markups()
click to toggle source
# File lib/github/markup.rb, line 30 def markups @@markups end
preload!()
click to toggle source
# File lib/github/markup.rb, line 38 def preload! markup_impls.each(&:load) end
render(filename, content, symlink: false, options: {})
click to toggle source
# File lib/github/markup.rb, line 42 def render(filename, content, symlink: false, options: {}) if (impl = renderer(filename, content, symlink: symlink)) impl.render(filename, content, options: options) else content end end
render_s(symbol, content, options: {})
click to toggle source
# File lib/github/markup.rb, line 50 def render_s(symbol, content, options: {}) raise ArgumentError, 'Can not render a nil.' if content.nil? if markups.key?(symbol) markups[symbol].render(nil, content, options: options) else content end end
renderer(filename, content, symlink: false)
click to toggle source
# File lib/github/markup.rb, line 85 def renderer(filename, content, symlink: false) language = language(filename, content, symlink: symlink) markup_impls.find do |impl| impl.match?(filename, language) end end