Class: XmlConv::View::Preformatted
- Inherits:
-
HtmlGrid::Value
- Object
- HtmlGrid::Value
- XmlConv::View::Preformatted
- Defined in:
- lib/xmlconv/view/preformatted.rb
Constant Summary collapse
- BREAK_WIDTH =
65
Instance Method Summary collapse
Instance Method Details
#init ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/xmlconv/view/preformatted.rb', line 11 def init super if @value raw = @value.gsub(/>\s+</, '><').gsub(/\t|\r\n?/, '') # fix encoding if raw =~ /ISO\-8859\-1|WINDOWS\-1252/i raw.force_encoding(Encoding::ISO_8859_1) end raw.encode!(Encoding::UTF_8).force_encoding(Encoding::UTF_8) @value = <<~PRE <pre>#{ cgi_with_utf8 { # prettify (indent) pretty = begin CGI.pretty(raw); rescue raw; end # omit tags CGI.escapeHTML(wrap(pretty)) } }</pre> PRE end end |