Class: Lookbook::MarkdownRenderer
- Defined in:
- lib/lookbook/services/markdown_renderer.rb
Defined Under Namespace
Classes: LookbookMarkdownRenderer
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text, opts = {}) ⇒ MarkdownRenderer
constructor
A new instance of MarkdownRenderer.
Methods inherited from Service
Constructor Details
#initialize(text, opts = {}) ⇒ MarkdownRenderer
Returns a new instance of MarkdownRenderer.
7 8 9 10 |
# File 'lib/lookbook/services/markdown_renderer.rb', line 7 def initialize(text, opts = {}) @text = text @opts = opts.to_h end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
5 6 7 |
# File 'lib/lookbook/services/markdown_renderer.rb', line 5 def opts @opts end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/lookbook/services/markdown_renderer.rb', line 5 def text @text end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 |
# File 'lib/lookbook/services/markdown_renderer.rb', line 12 def call clean_text = ActionViewAnnotationsStripper.call(text) md = Redcarpet::Markdown.new(LookbookMarkdownRenderer, opts) md.render(clean_text).html_safe end |