From cdf30dccf99dc205154582222998b4cf6d2b4920 Mon Sep 17 00:00:00 2001 From: Vincent Tang <10290348+vincentntang@users.noreply.github.com> Date: Wed, 25 Nov 2020 12:42:30 -0500 Subject: [PATCH] disable cdata --- lib/index.js | 5 +++-- readme.md | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2ad40a43..c8e2ab3d 100755 --- a/lib/index.js +++ b/lib/index.js @@ -31,8 +31,8 @@ function getSize(filename) { function generateXML (data){ var channel = []; - channel.push({ title: { _cdata: data.title } }); - channel.push({ description: { _cdata: data.description || data.title } }); + channel.push({ title: data.disable_cdata ? data.title: { _cdata: data.title }}); + channel.push({ description: data.disable_cdata ? data.description: { _cdata: data.description || data.title } }); channel.push({ link: data.site_url || 'http://github.com/dylang/node-rss' }); // image_url set? if (data.image_url) { @@ -140,6 +140,7 @@ function RSS (options, items) { this.title = options.title || 'Untitled RSS Feed'; this.description = options.description || ''; + this.disable_cdata = options.disable_cdata || false; this.generator = options.generator || 'RSS for Node'; this.feed_url = options.feed_url; this.site_url = options.site_url; diff --git a/readme.md b/readme.md index 5c636063..87129d42 100644 --- a/readme.md +++ b/readme.md @@ -23,6 +23,7 @@ var feed = new RSS(feedOptions); * `title` **string** Title of your site or feed * `description` _optional_ **string** A short description of the feed. + * `disable_cdata` _optional_ **boolean** Disables CDATA for `title` and `description` if true. * `generator` _optional_ **string** Feed generator. * `feed_url` **url string** Url to the rss feed. * `site_url` **url string** Url to the site that the feed is for.