feedsmith
Version:
Fast, all‑in‑one feed parser and generator for RSS, Atom, RDF, and JSON Feed, with support for Podcast, iTunes, Dublin Core, and OPML files.
56 lines (55 loc) • 1.46 kB
JavaScript
import { namespacePrefixes, namespaceStopNodes, namespaceUris, parserConfig } from "../../../common/config.js";
import { createNamespaceNormalizator } from "../../../common/utils.js";
import { XMLParser } from "fast-xml-parser";
//#region src/feeds/rss/parse/config.ts
const sharedStopNodes = [
"image.description",
"image.height",
"image.link",
"image.title",
"image.url",
"image.width",
"textinput.title",
"textinput.description",
"textinput.name",
"textinput.link",
"item.title",
"item.link",
"item.description",
"item.author.name",
"item.category",
"item.comments",
"item.enclosure",
"item.guid",
"item.pubdate",
"item.source"
];
const stopNodes = [
...namespaceStopNodes,
"rss.channel.title",
"rss.channel.link",
"rss.channel.description",
"rss.channel.language",
"rss.channel.copyright",
"rss.channel.managingeditor",
"rss.channel.webmaster",
"rss.channel.pubdate",
"rss.channel.lastbuilddate",
"rss.channel.category",
"rss.channel.generator",
"rss.channel.docs",
"rss.channel.cloud",
"rss.channel.ttl",
"rss.channel.rating",
"rss.channel.skiphours.hour",
"rss.channel.skipdays.day",
...sharedStopNodes.map((node) => `rss.channel.${node}`),
...sharedStopNodes.map((node) => `rss.${node}`)
];
const parser = new XMLParser({
...parserConfig,
stopNodes
});
const normalizeNamespaces = createNamespaceNormalizator(namespaceUris, namespacePrefixes);
//#endregion
export { normalizeNamespaces, parser, stopNodes };