class GithubToCanvasQuiz::MarkdownConverter
Convert a string of Markdown to HTML using Redcarpet and Rouge.
Useage:
MarkdownConverter.new("# Hello\n\nWorld\n").to_html # => "<h1>Hello</h1>\n\n<p>World</p>\n"
Constants
- OPTIONS
Attributes
markdown[R]
options[R]
Public Class Methods
new(markdown, options = {})
click to toggle source
@param [String] markdown The markdown to be converted @param [Hash] options Overrides the defaults for the [Redcarpet](github.com/vmg/redcarpet) gem
# File lib/github_to_canvas_quiz/markdown_converter.rb, line 28 def initialize(markdown, options = {}) @options = OPTIONS.merge(options) @markdown = markdown end
Public Instance Methods
to_html()
click to toggle source
@return [String] the markdown converted to HTML
# File lib/github_to_canvas_quiz/markdown_converter.rb, line 34 def to_html Redcarpet::Markdown.new(renderer, options).render(markdown) end
Private Instance Methods
renderer()
click to toggle source
# File lib/github_to_canvas_quiz/markdown_converter.rb, line 40 def renderer HTMLRenderer.new(escape_html: true) end