rust-syndication / rss

Library for serializing the RSS web content syndication format
https://crates.io/crates/rss
Apache License 2.0
419 stars 52 forks source link

Allow choice between `write_cdata_element` and `write_text_element` #118

Closed ZNielsen closed 3 years ago

ZNielsen commented 3 years ago

Formatting (just a newline) for an rss description is not working for me. It appears the description of a channel is always written via write_text_element, while the description of an item is written with write_cdata_element.

I'm willing to do the work for this ask, but I'm not familiar enough with the mechanics to know if changing the channel description writer to write_cdata_element will break anything for people. Ideally (IMO) the description fields should have the same behavior. This can be done in a couple ways:

1) Change the channel description writer function to write_cdata_element.

Once someone with more knowledge on this would let me know their thoughts, I'll get started.

andy128k commented 3 years ago

Description usually contains HTML markup, so additional whitespace characters (e.g. newline) are ignored by RSS viewers.

ZNielsen commented 3 years ago

Yes, but my <br> tags are not rendering either.

ZNielsen commented 3 years ago

Do viewers not typically render HTML in the description tag? If this ask makes no sense I'm fine to close it. Just offering to do the work if it would be an improvement.

andy128k commented 3 years ago

If you want a <br> to be in a description, you need to set it explicitly. Like

channel.set_description("First line<br>Second line");

Generally, you may start with PR containing a failing test. This would be a good starting point to understand where the problem is (if any).

ZNielsen commented 3 years ago

Looks like this is just an issue with the specific reader I was testing on.