How to use the entities.decode function in entities

To help you get started, we’ve selected a few entities examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glennjones / microformat-node / lib / helper-text3.js View on Github external
getTextContent: function (element) {
		var isPre = (element.name === 'pre');

		var out = this.walkTreeForText1(element, isPre)
		if(out !== undefined){
			out = out.replace(/[ ]+/g, ' '); // remove double spaces
			out = out.replace(/\r /g, '\r'); // remove any space direcly after a line return
			out = out.replace(/\r{3,}/g, '\r\r'); // remove anything more than double line return
			return this.trim(entities.decode(out,2)) // decode HTML entities
		}else{
			return undefined
		}
	},
github glennjones / microformat-node / lib / text.js View on Github external
parse: function(dom, node, textFormat){
        var out;

        this.textFormat = (textFormat)? textFormat : this.textFormat;
        if(this.textFormat === 'normalised'){
            out = this.walkTreeForText( dom, node );
            if(out !== undefined){
                out = out.replace( / /g, ' ') ;    // exchanges html entity for space into space char
                out = utils.removeWhiteSpace( out );    // removes linefeeds, tabs and addtional spaces
                out = entities.decode( out, 2 );        // decode HTML entities
                out = out.replace( '–', '-' );          // correct dash decoding
                return utils.trim( out );
            }else{
                return undefined;
            }
        }else{
            return this.textContent( dom(node).html(), this.textFormat );
        }
    },
github glennjones / microformat-node / lib / helper-text3.js View on Github external
child,
	    	text;

	    if(this.excludeTags.indexOf(element.name) > -1){
	    	return out;
	    }

	    if(element.name === 'br'){
	    	return '\r';
	    }
	   
        // if element is a text node get its text
        if(element.type && element.type === 'text'){
            var textItem = this.getEltText(element)
            if(this.trim(textItem) !== '') {
            	textItem = entities.decode(textItem,2)
            	if(isPre){
            		out = textItem.replace(/ /g, ' ');
            	}else{
	            	out = this.trim( this.removeWhiteSpace(textItem), ' ', ' ');
	            }
	        }
        }


        // get the text of the child nodes
        if(element.children && element.children.length > 0){
            for (var j = 0; j < element.children.length; j++) {

            	child = element.children[j];
            	if(child.name === 'pre'){
            		isPre = true;
github hikari-no-yume / lunasync / server / stream.js View on Github external
res.on('end', function () {
            var pos, pos2, title;

            pos = data.indexOf('<title>');
            if (pos !== -1) {
                pos2 = data.indexOf('</title>', pos);
                if (pos2 !== -1) {
                    title = data.substr(pos + 7, pos2 - (pos + 7));
                    // decode HTML entities
                    title = entities.decode(title, 2);
                    callback(title);
                } else {
                    callback(false);
                }
            } else {
                callback(false);
            }
        });
    }).on('error', function (err) {
github rbren / rss-parser / index.js View on Github external
var getSnippet = function(str) {
  return Entities.decode(stripHtml(str)).trim();
}
github wellcometrust / wellcomecollection.org / server / model / article.js View on Github external
const series: Array = Object.keys(json.categories).map(catKey =&gt; {
      const cat = json.categories[catKey];
      return {
        url: cat.slug,
        name: cat.name,
        description: cat.description,
        commissionedLength: getSeriesCommissionedLength(cat.slug),
        color: getSeriesColor(cat.slug)
      };
    });

    const article: Article = {
      contentType: contentType,
      url: url,
      headline: entities.decode(json.title),
      standfirst: entities.decode(standfirst),
      description: entities.decode(json.excerpt),
      datePublished: new Date(json.date),
      mainMedia: mainMedia,
      thumbnail: thumbnail,
      articleBody: articleBody,
      associatedMedia: mainImage ? [mainImage] : [],
      author: List(),
      bodyParts: bodyParts,
      series: series,
      positionInSeries: positionInSeries
    };

    return article;
  }
}
github rbren / rss-parser / lib / utils.js View on Github external
utils.getSnippet = function(str) {
  return entities.decode(utils.stripHtml(str)).trim();
}
github glennjones / microformat-node / lib / ufparser.js View on Github external
getEValue: function(dom, node) {
		return entities.decode(dom(node).html(), 2);
		//return dom(node).html();
	},
github wellcometrust / wellcomecollection.org / server / model / article.js View on Github external
const series: Array = Object.keys(json.categories).map(catKey =&gt; {
      const cat = json.categories[catKey];
      return {
        url: cat.slug,
        name: cat.name,
        description: cat.description,
        commissionedLength: getSeriesCommissionedLength(cat.slug),
        color: getSeriesColor(cat.slug)
      };
    });

    const article: Article = {
      contentType: contentType,
      url: url,
      headline: entities.decode(json.title),
      standfirst: entities.decode(standfirst),
      description: entities.decode(json.excerpt),
      datePublished: new Date(json.date),
      mainMedia: mainMedia,
      thumbnail: thumbnail,
      articleBody: articleBody,
      associatedMedia: mainImage ? [mainImage] : [],
      author: List(),
      bodyParts: bodyParts,
      series: series,
      positionInSeries: positionInSeries
    };

    return article;
  }
}