Class: Klaro::Client::MdText
- Inherits:
-
Object
- Object
- Klaro::Client::MdText
- Defined in:
- lib/klaro/client/support/md_text.rb
Constant Summary collapse
- SHARED_OPTIONS =
{ unsafe: false, }
Instance Method Summary collapse
-
#initialize(src, variant, options = {}) ⇒ MdText
constructor
A new instance of MdText.
- #render_options ⇒ Object
- #to_html(options = {}) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(src, variant, options = {}) ⇒ MdText
Returns a new instance of MdText.
9 10 11 12 13 |
# File 'lib/klaro/client/support/md_text.rb', line 9 def initialize(src, variant, = {}) @src = src @variant = variant = SHARED_OPTIONS.merge() end |
Instance Method Details
#render_options ⇒ Object
19 20 21 22 23 |
# File 'lib/klaro/client/support/md_text.rb', line 19 def .merge({ hardbreaks: (@variant == :summary) }) end |
#to_html(options = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/klaro/client/support/md_text.rb', line 25 def to_html( = {}) Commonmarker.to_html(to_s, options: { render: .merge() }).strip.gsub(/<a href/, '<a target="_blank" href') end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/klaro/client/support/md_text.rb', line 15 def to_s @src end |