class Markedly::Markdown
Constants
- AVAILABLE_EXTENSIONS
- DEFAULT_EXTENSIONS
- DEFAULT_RENDERER_OPTIONS
- RENDERER_OPTIONS
Public Class Methods
new(extensions = {}, renderer_options = {})
click to toggle source
# File lib/markedly/markdown.rb, line 51 def initialize(extensions = {}, renderer_options = {}) extensions ||= DEFAULT_EXTENSIONS renderer_options ||= DEFAULT_RENDERER_OPTIONS renderer_class = Class.new(Redcarpet::Render::HTML) do include WithPygments if Markdown.python_available? end renderer = renderer_class.new(renderer_options) @markdown = Redcarpet::Markdown.new(renderer, extensions) end
Private Class Methods
executable?(command)
click to toggle source
# File lib/markedly/markdown.rb, line 71 def self.executable?(command) if RUBY_PLATFORM =~ /mswin|mingw/ exts = ENV['PATHEXT'].split(';') exts.map {|ext| command + ext }.each do |exe| ENV['PATH'].gsub('\\', '/').split(';').map {|dir| File.join(dir, exe) }.each do |path| return true if File.executable?(path) end end return false end system("which #{command} > /dev/null 2>&1") end
python_available?()
click to toggle source
# File lib/markedly/markdown.rb, line 67 def self.python_available? executable?('python2') || executable?('python') end
Public Instance Methods
render(text)
click to toggle source
# File lib/markedly/markdown.rb, line 61 def render(text) @markdown.render(text) end