Method: Massaji::Spa#initialize

Defined in:
lib/massaji.rb

#initialize(text, tag = "p") ⇒ Spa

Clean up some text by replacing characters.

text - The text coming in that is currently “full of knots”, or

bad text.

tag - Optional tag to pass in, defaults to paragraph tag.

Examples

Massaji::Spa.new("children\342\200\231s")
# => "children's"

Returns the text with appropriate substitutions made.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/massaji.rb', line 19

def initialize(text, tag="p")
  text.gsub!(/\\342\\200(?:\\234|\\235)/,'"')
  text.gsub!(/\\342\\200(?:\\230|\\231)/,"'")
  text.gsub!(/\\342\\200\\223/,"-")
  text.gsub!(/\\342\\200\\224/,"--")
  text.gsub!(/\\342\\200\\246/,"...")
  
  # not sure what these are, make empty for now
  text.gsub!(/\\342\\200\\242/,"")
  text.gsub!(/\\342\\200\\250/,"")
  text.gsub!(/\\342\\204\\242/,"")
  text.gsub!(/\\303\\251/,"") # e in cafe?
  text.gsub!(/\\303\\261/,"")

  insert_html(text)
  text = wrap(text, tag)
  
  @text = text
end