feed icon indicating copy to clipboard operation
feed copied to clipboard

Adding processing instruction

Open davidjamesstone opened this issue 3 years ago • 3 comments

I'd like to add a processing instruction to the xml, specifically a stylesheet:

<?xml-stylesheet type="text/xsl" href="./rss-style.xsl"?>

I've had a good look around the code but I can't a way of doing it - anyone have any ideas how to do this (other than post-process the string)

Many thanks

davidjamesstone avatar Feb 11 '21 14:02 davidjamesstone

Ths package leverages https://github.com/nashwaan/xml-js to generate the XML, so you'd need to start there.

paul-uz avatar Feb 18 '21 14:02 paul-uz

@paul-uz I believe https://github.com/nashwaan/xml-js already supports this via the "_instruction" key. This lib would need to expose that. I'm happy to issue a PR if I can work it out and it's something you think would be worth adding.

davidjamesstone avatar Feb 19 '21 23:02 davidjamesstone

Agree, this would be nice to have this ability.

We want to add xml-stylesheet our RSS feeds for Docusaurus (https://github.com/facebook/docusaurus/issues/9197)

See also: https://darekkay.com/blog/rss-styling/

I tweaked this lib code and this seems to do the job:

var base = {
  _declaration: { _attributes: { version: "1.0", encoding: "utf-8" } },
  _instruction: { "xml-stylesheet": 'href="/rss.xsl" type="text/xsl"' },
  rss: {}
};
CleanShot 2023-08-24 at 16 53 17@2x

slorber avatar Aug 24 '23 14:08 slorber