-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
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
Update transitive.rb #230
base: master
Are you sure you want to change the base?
Update transitive.rb #230
Conversation
This makes Transitive.rb do exactly what the docs say it should do. It outputs Pretty xml except for text nodes which are left untouched.
This formatter was adding newline characters so the Text nodes grew every time you saved/wrote them. Adding #strip fixes it. I've been working with it and it works perfectly.
Formatting this html content html = "<html><title> foo </title><body><div> bar </div></body></html>"
REXML::Document.new(html).write(STDOUT, 2, true) In the document
This is transitive output. It looks weird, but it's indented, it's valid, and the content is preserved. <html
><title
> foo </title
><body
><div
> bar </div
></body
></html
> This is not transitive. It looks pretty but the content is not preserved. <html>
<title>
foo
</title>
<body>
<div>
bar
</div>
</body>
</html> |
If you guys want to preserve Transitive the way that it is for backward compatibility, that's fine with me. My issue is that I need a user friendly (pretty) output that doesn't change my text nodes. I don't see any scenario where having the formatter change the text is advantageous. When I write my xml with Pretty, it adds a bunch of whitespace so when I read it back it's wrong. Its a different string that doesn't work. This makes no sense to me becuase the purpose of XML is to be read by a program, not a human. Pretty makes it human readable but now program readable. I really like Pretty.rb. I'd love to see it have an option to preserve text nodes. That would be the best imho. In fact, I would suggest making the default behavior of Pretty be to preserve text nodes, and have an option to indent with a bunch of whitespace. That makes sense to me. Are you guys receptive to that instead? |
What does "text nodes" mean? Could you provide a sample XML and an expected pretty output for it? |
Thanks for your comment.
Depending on your answer below, I think it would be more appropriate to extend
|
GitHub: fix GH-228
This makes Transitive.rb do exactly what the docs say it should do. It outputs Pretty xml except for text nodes which are left untouched. If you read the issue that I posted, you can see that the current Transitive output is garbled. Also, this has the benefit of being initialized using Prestty.rb, initialize method for simplicity.