Class: SlackTransformer::Slack::Preformatted
- Inherits:
-
Object
- Object
- SlackTransformer::Slack::Preformatted
- Defined in:
- lib/slack_transformer/slack/preformatted.rb
Constant Summary collapse
- PATTERN =
/ (?<=^|\W|_) # preceded by start of line, non-word character, or _ (?<!~) # but not ~ ([*_~]?) # optionally preceded by *, _, or ~ ```(.+)``` # one or more of anything surrounded by ``` \1 # followed by *, _, or ~ if preceded by it (?!~) # not followed by ~ (?=\W|_|$) # followed by non-word character, _, or end of line /x
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
-
#initialize(input) ⇒ Preformatted
constructor
A new instance of Preformatted.
- #to_html ⇒ Object
Constructor Details
#initialize(input) ⇒ Preformatted
Returns a new instance of Preformatted.
36 37 38 |
# File 'lib/slack_transformer/slack/preformatted.rb', line 36 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/preformatted.rb', line 4 def input @input end |
Instance Method Details
#to_html ⇒ Object
40 41 42 |
# File 'lib/slack_transformer/slack/preformatted.rb', line 40 def to_html input.gsub(PATTERN, '\1<pre>\2</pre>\1') end |