maik / xml-simple

Easy API for working with XML documents
MIT License
88 stars 27 forks source link

Add an option for self-closing tags #31

Closed orgads closed 3 years ago

orgads commented 3 years ago

Use <tag /> instead of <tag></tag>

maik commented 3 years ago

Hi!

Thank you very much for your suggestion. Could you, please, explain the reasoning behind your solution?

Best, Maik

orgads commented 3 years ago

Sure. There is a condition text_content.nil?, which is never satisfied, because text_content is assigned an empty string in case it is empty. Looks like it was overlooked in the original implementation.

maik commented 3 years ago

I am afraid I still do not get your point. Currently, XmlSimple emits <tag></tag> for empty tags and you want it to emit <tag /> instead?

orgads commented 3 years ago

Use backticks for tags.

maik commented 3 years ago

Sorry, I've fixed the markup.

orgads commented 3 years ago

Right. I also wrote it in the commit message, but the description in github didn't show it because it wasn't backticked. I edited the description later.

maik commented 3 years ago

Now I got it.

I am hesitating a bit to change the default behavior, because the library is widely used and I could imagine that some people rely on the current output format. (even though we all know it is a cardinal sin to process XML without a parser)

So, I suggest not to change the current output format but to add a new option. Using this option users could change the output format, then.

orgads commented 3 years ago

Fair enough.

orgads commented 3 years ago

Done. I don't know how to update the docs. I added the option to index.html, but I'm not sure about the rest. Can you please handle it?

maik commented 3 years ago

Wow, that was fast and you've also written text and documentation. Thank you very much!

orgads commented 3 years ago

My pleasure :)

orgads commented 3 years ago

When do you plan to release?

maik commented 3 years ago

Sorry, I totally forgot that. I've pushed it to rubygems.org a minute ago.

On Tue, Dec 29, 2020 at 4:15 PM Orgad Shaneh notifications@github.com wrote:

When do you plan to release?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/maik/xml-simple/pull/31#issuecomment-752116108, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAFQT3JYWHCSRVBP3P5VV3SXHXALANCNFSM4VFOLYTA .

orgads commented 3 years ago

Thanks :)