ox: Single carriage return is not converted to line feed
As described on https://www.w3.org/TR/2008/REC-xml-20081126/#sec-line-ends, a single carriage return should be converted to a line feed, but ox doesn’t convert it. Is this behavior expected? Actually, other XML libraries such as nokogiri and rexml convert it:
require 'nokogiri'
require 'ox'
require 'rexml'
class Handler
def text(value)
p value
end
alias_method :characters, :text
def method_missing(*args); end
end
xml = "<xml><value>foo\rbar</value></xml>"
handler = Handler.new
puts '== nokogiri =='
Nokogiri::XML::SAX::Parser.new(handler).parse(xml)
puts '== rexml =='
REXML::Parsers::StreamParser.new(REXML::Source.new(xml), handler).parse
puts '== ox with skip_return =='
Ox.sax_parse(handler, xml, { skip: :skip_return })
puts '== ox with skip_white =='
Ox.sax_parse(handler, xml, { skip: :skip_white })
The output is here:
== nokogiri ==
"foo"
"\nbar"
== rexml ==
"foo\nbar"
== ox with skip_return ==
"foo\rbar"
== ox with skip_white ==
"foo bar"
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (11 by maintainers)
Thank you for releasing the latest version, which resolves this issue. I’ve also confirmed the behavior with the latest version.