We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If you use:
xml_builder = Builder::XmlMarkup.new(indent: 2) xml_builder.card do |card_builder| #... card_builder.description do card_builder.cdata!(description) end end
And then somewhere along the line add CDATA blocks to your tree, you end up with indented CDATA blocks:
<card> ... <description> <![CDATA[Welcome to.... ]]> </description> </card> </
The problem is that upon parsing the indentation (new line and leading whitespace) becomes part of the text() for the <description> node:
text()
<description>
irb> xml.at_xpath('card/description').text => "\n Welcome to
This is because XmlMarkup#cdata! calls #_special which in turns calls _indent.
#_special
_indent
I suspect indent should be skipped on CDATA sections: https://bugs.openjdk.java.net/browse/JDK-8223291 nashwaan/xml-js#14
In fact Nokogiri does skip indent for CDATA-only nodes:
irb> doc = Nokogiri::XML("<foo><bar><![CDATA[lorem ipsum]]></foo>") => #<Nokogiri::XML::Document:0xe09c name="document" children=[#<Nokogiri::XML::Element:0xe088 name="foo" children=[#<Nokogiri::XML::Element:0xe074 name="bar" children=[#<Noko... irb> puts doc <?xml version="1.0"?> <foo> <bar><![CDATA[lorem ipsum]]></bar> </foo>
Is this a bug or a feature? 🤔
The text was updated successfully, but these errors were encountered:
No branches or pull requests
If you use:
And then somewhere along the line add CDATA blocks to your tree, you end up with indented CDATA blocks:
The problem is that upon parsing the indentation (new line and leading whitespace) becomes part of the
text()
for the<description>
node:This is because XmlMarkup#cdata! calls
#_special
which in turns calls_indent
.I suspect indent should be skipped on CDATA sections:
https://bugs.openjdk.java.net/browse/JDK-8223291
nashwaan/xml-js#14
In fact Nokogiri does skip indent for CDATA-only nodes:
Is this a bug or a feature? 🤔
The text was updated successfully, but these errors were encountered: