class GrapeSwagger::Markdown::KramdownAdapter

Attributes

options[R]

Public Class Methods

new(config = {}) click to toggle source

Initializes the kramdown adapter with options. See kramdown documentation what options can be passed. Default it uses Github flavoured markup as input and won't use coderay as converter for syntax highlighting. config: an hash of configuration options to be passed to the kramdown. usage: Add the kramdown gem to your gemfile or run: $ (sudo) gem install kramdown

Then pass a new instance of GrapeSwagger::Markdown::KramdownAdapter as markdown option.

# File lib/grape-swagger/markdown/kramdown_adapter.rb, line 17
def initialize(config = {})
  require 'kramdown'
  defaults = {
    input: 'GFM',
    enable_coderay: false
  }
  @options = defaults.merge(config)
rescue LoadError
  raise GrapeSwagger::Errors::MarkdownDependencyMissingError, 'kramdown'
end

Public Instance Methods

markdown(text) click to toggle source

marks down the given text to html format. text: The text to be formatted.

# File lib/grape-swagger/markdown/kramdown_adapter.rb, line 32
def markdown(text)
  Kramdown::Document.new(text, @options).to_html
end