Class: SiSU_XHTML_EPUB2_Tune::CleanXHTML

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/xhtml_epub2_tune.rb

Instance Method Summary collapse

Constructor Details

#initialize(html = '') ⇒ CleanXHTML

Returns a new instance of CleanXHTML.



92
93
94
# File 'lib/sisu/xhtml_epub2_tune.rb', line 92

def initialize(html='')
  @html=html
end

Instance Method Details

#cleanObject



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/sisu/xhtml_epub2_tune.rb', line 95

def clean
  html=@html
  str=if html.is_a?(String)
    html
  else html.obj
  end
  str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;').
    gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;').
    gsub(/<br>/u,'<br />').
    gsub(/#{Mx[:nbsp]}/u,$ep[:hsp])
end