Class: SlackTransformer::Slack::Blockquote
- Inherits:
-
Object
- Object
- SlackTransformer::Slack::Blockquote
- Defined in:
- lib/slack_transformer/slack/blockquote.rb
Constant Summary collapse
- PATTERN =
/ ^ # start of line ([*_~]?) # optionally preceded by *, _, or ~ >{3}(.+) # one or more of anything preceded by > \1 # followed by *, _, or ~ if preceded by it $ # end of line /mx
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
-
#initialize(input) ⇒ Blockquote
constructor
A new instance of Blockquote.
- #to_html ⇒ Object
Constructor Details
#initialize(input) ⇒ Blockquote
Returns a new instance of Blockquote.
28 29 30 |
# File 'lib/slack_transformer/slack/blockquote.rb', line 28 def initialize(input) @input = input end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
4 5 6 |
# File 'lib/slack_transformer/slack/blockquote.rb', line 4 def input @input end |
Instance Method Details
#to_html ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/slack_transformer/slack/blockquote.rb', line 32 def to_html input.gsub(PATTERN) do outer = Regexp.last_match(1) inner = Regexp.last_match(2).gsub("\n", '<br>') "#{outer}<blockquote>#{inner}</blockquote>#{outer}" end end |