Module: Polytrix::Util::String::ClassMethods

Included in:
Polytrix::Util::String
Defined in:
lib/polytrix/util.rb

Instance Method Summary collapse

Instance Method Details

#ansi2html(text) ⇒ Object



101
102
103
# File 'lib/polytrix/util.rb', line 101

def ansi2html(text)
  HTML.from_ansi(text)
end

#escape_html(text) ⇒ Object Also known as: h



105
106
107
# File 'lib/polytrix/util.rb', line 105

def escape_html(text)
  HTML.escape_html(text)
end

#highlight(source, opts = {}) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/polytrix/util.rb', line 110

def highlight(source, opts = {})
  return nil if source.nil?

  opts[:language] ||= 'ruby'
  opts[:formatter] ||= 'terminal256'
  Highlight.new(opts).highlight(source)
end

#slugify(*labels) ⇒ Object



95
96
97
98
99
# File 'lib/polytrix/util.rb', line 95

def slugify(*labels)
  labels.map do |label|
    label.downcase.gsub(/[\.\s-]/, '_')
  end.join('-')
end