Module: Texta
Defined Under Namespace
Modules: Etest, NilAdapter, StringAdapter
Classes: Error, T
Class Method Summary
collapse
Class Method Details
.html(str) ⇒ Object
31
32
33
34
|
# File 'lib/texta.rb', line 31
def self.html(str)
str = ::HTMLEntities.new.encode text(str), :named
RDiscount.new(str).to_html
end
|
.init ⇒ Object
9
10
11
|
# File 'lib/texta.rb', line 9
def self.init
String.send :include, self
end
|
.is_html?(text) ⇒ Boolean
13
14
15
16
17
|
# File 'lib/texta.rb', line 13
def self.is_html?(text)
return true if text =~ /&([a-z]+)|(#[0-9]+);/
text =~ /<(ul|a|p|br|li|img|b|i)\b(.*?)>/
end
|
.text(str) ⇒ Object
36
37
38
39
|
# File 'lib/texta.rb', line 36
def self.text(str)
return str unless is_html?(str)
T.new(str)
end
|