Class: SlackTransformer::Slack::Bold
- Inherits:
-
Object
- Object
- SlackTransformer::Slack::Bold
- Defined in:
- lib/slack_transformer/slack/bold.rb
Constant Summary collapse
- PATTERN =
/ (?<=^|\W) # preceded by start of line or non-word character (?<![*~`]) # but not *, ~, or `, which are mrkdwn delimiters # Note: _ is also a mrkdwn delimiter, but it's included in \W because # it's a word character. ([_~]?) # optionally preceded by _ or ~ \*((?:[^*]|(?<=[\w\s])\*+(?=\w))+)\* # one or more of either not *, or one or more * preceded by word # character or space and followed by word character, surrounded by * \1 # followed by _ or ~ if preceded by it (?![*`]) # not followed by * or ` (?=\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) ⇒ Bold
constructor
A new instance of Bold.
- #to_html ⇒ Object
Constructor Details
#initialize(input) ⇒ Bold
Returns a new instance of Bold.
39 40 41 |
# File 'lib/slack_transformer/slack/bold.rb', line 39 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/bold.rb', line 4 def input @input end |
Instance Method Details
#to_html ⇒ Object
43 44 45 |
# File 'lib/slack_transformer/slack/bold.rb', line 43 def to_html input.gsub(PATTERN, '\1<b>\2</b>\1') end |