I’m encountering some issue with encoding between XML and HTML while working on my RSS preview page.
I use HTML tags in the title field of some articles (mostly to indicate the language of an English word in a French title). For example: Une fonctionnalité <span lang="en">awesome</>. This is working great on my website. The html tags are interpreted. (BTW this is a feature that I really like about Kirby fields.)
But by default, the feed (https://luce.carevic.eu/fr/feed) will show the html tags instead of interpreting them. I guess because of XML encoding.
I’ve found a way to remove the html tags (with Str::unhtml()) but I would rather that the HTML code be interpreted. I’ve tried with no luck to tinker with every escaping/parsing option but this is too complicated for me. The html tags are either deleted (which is at least something) or present in the text instead of interpreted.
I don’t know if I’m exposing my problem very clearly. If it isn’t, I’ll add example of the files.
I think I’ll let it go. I wanted to provide the proper pronunciation and hide decorative emoji for screenreader users but I cannot control how this will be interpreted in feed readers anyway. So I’ll just strip the html tags and that will be enough.
Thank you anyway. I’m discovering a whole new world with xml!
I could imagine that this is a follow-up problem of the solution discussed in this thread.
With 'mime' => 'xml' you are ending in a Content-Type header of text/xml, but I still think you should have application/xml. Unfortunately, as @sebastiangreger points out, you are bound using the mime options Kirby recognizes but there is no such option to produce application/xml.
However, you could try with 'mime' => 'xhtml' which will result in Content-Type application/xhtml+xml and I think this could work for you.
Oh that’s weird for the pubdate, it’s working fine in the preview page. It’s also correct on Inoreader. I’ll try the feed on several other feedreaders!
I will let the topic pending for a few days and if I can’t find a solution, I’ll close it
That’ right. As long as it is taken literally as it is in the pubdate field, it is ok. But in this format it is not parsable and thus one cannot work with it (sorting, translating).
So, I’ve fixed my pubdate while also having a nice looking format in the XSL file.
For this I simply worked with a custom tag in the XML file where I stored the output format that I needed. I’ve tried before to convert date directly in the XSL file but with no success. Not neat but it works.
So for now the choices are: to strip the HTML tags or to let them on Firefox. I chose the first option because I think that from a user perspective it’s worse to have the HTML tags than to have an improper pronunciation and occasional emojis.
As I still have a lot to do on my website, I’ll close the topic and let this issue pending for when I have time.
Thank you very much for your inputs. I’ve learn a lot about XSL and RSS feed!
I might do a shorter English version but that would require me to set up the English version of my website (my guess is that this will lead me back here very soon).