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) ⇒ MdText
constructor
A new instance of MdText.
- #render_options ⇒ Object
- #to_html ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(src, variant) ⇒ MdText
Returns a new instance of MdText.
9 10 11 12 |
# File 'lib/klaro/client/support/md_text.rb', line 9 def initialize(src, variant) @src = src @variant = variant end |
Instance Method Details
#render_options ⇒ Object
18 19 20 21 22 |
# File 'lib/klaro/client/support/md_text.rb', line 18 def SHARED_OPTIONS.merge({ hardbreaks: (@variant == :summary) }) end |
#to_html ⇒ Object
24 25 26 27 28 |
# File 'lib/klaro/client/support/md_text.rb', line 24 def to_html Commonmarker.to_html(to_s, options: { render: }).strip.gsub(/<a href/, '<a target="_blank" href') end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/klaro/client/support/md_text.rb', line 14 def to_s @src end |