How to use entities - 10 common examples

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 5d-jh / school-menu-api / api / neis.js View on Github external
$('td div').each(function () {
        const text = entities.decodeHTML5($(this).html());

        const date = text.split(/\[조식\]|\[중식\]|\[석식\]/)[0].replace('<br>', '').trim();
          /*
          [예시]
          '3 <br>[중식]고등어' =(1)=&gt; '3 <br>' =(2)=&gt; '3 ' =(3)=&gt; '3'
          [설명]
          (1) 텍스트 '[조식]' 또는 '[중식]' 또는 '[석식]' 중 하나를 기준으로 나눈 배열의 첫 번째 원소를 고름
          (2) 첫 번째 원소의 <br> 태그를 제거함
          (3) 문자의 공백을 제거함
          */
        if (date/* 날짜 정보가 있는 경우에만 배열에 식단을 저장함 */) {
          const breakfast = /\[조식\](.*?)(\[|$)/g.exec(text) &amp;&amp; /\[조식\](.*?)(\[|$)/g.exec(text)[1];
            /*
            [예시]
            '[조식]고등어<br>참치[' =&gt; '고등어<br>참치'
            [설명]
github timonreinhard / wemo-client / client.js View on Github external
attributeList: function(data) {
      var xml = '' + entities.decodeXML(data) + '';
      xml2js.parseString(xml, { explicitArray: true }, function(err, result) {
        if (!err) {
          // In order to keep the existing event signature this
          // triggers an event for every attribute changed.
          result.attributeList.attribute.forEach(function(attribute) {
            self.emit('attributeList',
              attribute.name[0],
              attribute.value[0],
              attribute.prevalue[0],
              attribute.ts[0]
            );
          });
        }
      });
    }
  };
github orzhtml / react-native-orzhtml-htmlview / example / HTMLView / htmlToElement.js View on Github external
onLongPress={() =&gt; {
                          const text = entities.decodeHTML(item.children[0].data)
                          // 长按
                          opts.onLongPress &amp;&amp; opts.onLongPress(text)
                          // 长按显示弹窗
                          showActionPopover({
                            view: this[
                              'ShareNewsTagMarkParagraph' +
                                index +
                                ShareNewsTagMarkParagraphRand
                            ],
                            content: text
                          })
                        }}
                      &gt;
                        {entities.decodeHTML(item.children[0].data)}
                      
                    
                  )
                })}
github GetStream / Winds / api / src / controllers / rss.js View on Github external
}

		let feedUrl = normalizeUrl(feed.url);
		if (!isURL(feedUrl)) {
			continue;
		}

		let rss = await RSS.findOne({ feedUrl: feedUrl });
		const limit = moment().subtract(30, 'seconds');
		// don't update featured RSS feeds since that ends up removing images etc
		if (!rss || (!rss.featured && limit.isAfter(rss.lastScraped))) {
			let response = await RSS.findOneAndUpdate(
				{ feedUrl: feedUrl },
				{
					categories: 'RSS',
					description: entities.decodeHTML(feed.title),
					feedUrl: feedUrl,
					images: {
						favicon: foundRSS.site.favicon,
					},
					lastScraped: moment().format(),
					title: entities.decodeHTML(feedTitle),
					url: foundRSS.site.url,
					valid: true,
				},
				{
					new: true,
					rawResult: true,
					upsert: true,
				},
			);
github orzhtml / react-native-orzhtml-htmlview / example / HTMLView / htmlToElement.js View on Github external
function lineLabelMap (dom) {
    const textArray = []
    dom.map(item => {
      textArray.push(labelText(item))
    })
    return entities.decodeHTML(textArray.join(',').replace(/,/g, ''))
  }
  // 返回文本内容
github cheeriojs / dom-serializer / index.js View on Github external
function renderText(elem, opts) {
  var data = elem.data || '';

  // if entities weren't decoded, no need to encode them back
  if (
    opts.decodeEntities &&
    !(elem.parent && elem.parent.name in unencodedElements)
  ) {
    data = entities.encodeXML(data);
  }

  return data;
}
github cheeriojs / dom-serializer / index.js View on Github external
for (var key in attributes) {
    value = attributes[key];
    if (output) {
      output += ' ';
    }

    if (opts.xmlMode === 'foreign') {
      /* fix up mixed-case attribute names */
      key = foreignNames.attributeNames[key] || key;
    }
    output += key;
    if ((value !== null && value !== '') || opts.xmlMode) {
      output +=
        '="' +
        (opts.decodeEntities
          ? entities.encodeXML(value)
          : value.replace(/\"/g, '&quot;')) +
        '"';
    }
  }

  return output;
}
github arangodb / arangodb / js / node / node_modules / jshint / node_modules / htmlparser2 / node_modules / domutils / node_modules / dom-serializer / index.js View on Github external
function renderText(elem, opts) {
  var data = elem.data || '';

  // if entities weren't decoded, no need to encode them back
  if (opts.decodeEntities && !(elem.parent && elem.parent.name in unencodedElements)) {
    data = entities.encodeXML(data);
  }

  return data;
}
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( /&nbsp;/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 );
        }
    },