Class: SlackTransformer::Slack::Blockquote

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#inputObject (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_htmlObject



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