Module: Xlsxtream::XML
- Defined in:
- lib/xlsxtream/xml.rb
Constant Summary collapse
- XML_ESCAPES =
{ '&' => '&', '"' => '"', '<' => '<', '>' => '>', }.freeze
- XML_DECLARATION =
%'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n'.freeze
- WS_AROUND_TAGS =
/(?<=>)\s+|\s+(?=<)/.freeze
- UNSAFE_ATTR_CHARS =
/[&"<>]/.freeze
- UNSAFE_VALUE_CHARS =
/[&<>]/.freeze
Class Method Summary collapse
Class Method Details
.escape_attr(string) ⇒ Object
27 28 29 |
# File 'lib/xlsxtream/xml.rb', line 27 def escape_attr(string) string.gsub(UNSAFE_ATTR_CHARS, XML_ESCAPES) end |
.escape_value(string) ⇒ Object
31 32 33 |
# File 'lib/xlsxtream/xml.rb', line 31 def escape_value(string) string.gsub(UNSAFE_VALUE_CHARS, XML_ESCAPES) end |
.header ⇒ Object
19 20 21 |
# File 'lib/xlsxtream/xml.rb', line 19 def header XML_DECLARATION end |
.strip(xml) ⇒ Object
23 24 25 |
# File 'lib/xlsxtream/xml.rb', line 23 def strip(xml) xml.gsub(WS_AROUND_TAGS, ''.freeze) end |