Sha256: 5072a9ac74f35173fd25240185221ec305e3360eaecdb15d2729c0eebe13b66a

Contents?: true

Size: 718 Bytes

Versions: 20

Compression:

Stored size: 718 Bytes

Contents

# encoding: utf-8
module Slack
  module Messages
    module Formatting
      class << self
        #
        # Unescape a message.
        # @see https://api.slack.com/docs/formatting
        #
        def unescape(message)
          CGI.unescapeHTML(message.gsub(/[“”]/, '"')
            .gsub(/[‘’]/, "'")
            .gsub(/<(?<sign>[?@#!]?)(?<dt>.*?)>/) do |match|
              sign = $~[:sign]
              dt = $~[:dt]
              rhs = dt.split('|', 2).last
              case sign
              when '@', '!'
                "@#{rhs}"
              when '#'
                "##{rhs}"
              else
                rhs
              end
            end)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
slack-ruby-client-bhe-0.5.5 lib/slack/messages/formatting.rb
slack-ruby-client-bhe-0.5.4 lib/slack/messages/formatting.rb
slack-ruby-client-0.10.0 lib/slack/messages/formatting.rb
slack-ruby-client-0.9.1 lib/slack/messages/formatting.rb
slack-ruby-client-0.9.0 lib/slack/messages/formatting.rb
slack-ruby-client-0.8.1 lib/slack/messages/formatting.rb
slack-ruby-client-0.8.0 lib/slack/messages/formatting.rb
slack-ruby-client-0.7.9 lib/slack/messages/formatting.rb
slack-ruby-client-0.7.8 lib/slack/messages/formatting.rb
slack-ruby-client-0.7.7 lib/slack/messages/formatting.rb
slack-ruby-client-0.7.6 lib/slack/messages/formatting.rb
slack-ruby-client-0.7.5 lib/slack/messages/formatting.rb
slack-ruby-client-0.7.4 lib/slack/messages/formatting.rb
slack-ruby-client-0.7.3 lib/slack/messages/formatting.rb
slack-ruby-client-0.7.2 lib/slack/messages/formatting.rb
slack-ruby-client-0.7.1 lib/slack/messages/formatting.rb
slack-ruby-client-0.7.0 lib/slack/messages/formatting.rb
slack-ruby-client-0.6.0 lib/slack/messages/formatting.rb
slack-ruby-client-0.5.4 lib/slack/messages/formatting.rb
slack-ruby-client-0.5.3 lib/slack/messages/formatting.rb