Class: Markedly::Markdown

Inherits:
Object
  • Object
show all
Defined in:
lib/markedly/markdown.rb

Defined Under Namespace

Modules: WithPygments

Constant Summary collapse

AVAILABLE_EXTENSIONS =
[
  :no_intra_emphasis,
  :tables,
  :fenced_code_blocks,
  :autolink,
  :disable_indented_code_blocks,
  :strikethrough,
  :lax_spacing,
  :space_after_headers,
  :superscript,
  :underline,
  :highlight,
]
DEFAULT_EXTENSIONS =
{
  tables: true,
  fenced_code_blocks: true,
  autolink: true,
}
RENDERER_OPTIONS =
[
  :filter_html,
  :no_images,
  :no_links,
  :no_styles,
  :safe_links_only,
  :with_toc_data,
  :hard_wrap,
  :xhtml,
  :prettify,
  :link_attributes
]
DEFAULT_RENDERER_OPTIONS =
{}

Instance Method Summary collapse

Constructor Details

#initialize(extensions = {}, renderer_options = {}) ⇒ Markdown

Returns a new instance of Markdown.



51
52
53
54
55
56
57
58
59
# 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

Instance Method Details

#render(text) ⇒ Object



61
62
63
# File 'lib/markedly/markdown.rb', line 61

def render(text)
  @markdown.render(text)
end