How to use the html-entities.Html5Entities.decode function in html-entities

To help you get started, we’ve selected a few html-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 tiffany352 / twitter-archive-browser / src / components / Message.js View on Github external
const message = props.message

  const isSelf = message.senderId === accountId
  const date = message.createdDate

  if (message.mediaUrls.length > 0) {
    console.log('has media urls', message)
    return (
      <div data-ismedia="true" data-isself="{isSelf}">
        {message.mediaUrls.map((url, index) =&gt; )}
        <div>{date.toLocaleTimeString()}</div>
      </div>
    )
  }

  const text = Html5Entities.decode(message.text)
  const segmenter = new Segmenter(text.length, { style: 'normal' })

  const linkPattern = /https?:\/\/t\.co\/[^\s]*/g
  for (const match of text.matchAll(linkPattern)) {
    segmenter.setSpan(match.index, match.index + match[0].length - 1, {
      style: 'link',
      href: match[0],
    })
  }

  const segments = segmenter.array.map(({ start, end, value }, index) =&gt; {
    const slice = text.slice(start, end+1)
    switch (value.style) {
      case 'normal':
        return <span>{slice}</span>
      case 'link':
github redco / goose-parser / lib / Transformations.js View on Github external
break;

                case this.TYPES.PICK:
                    transformedResult = _.pick(result, step.prop);
                    break;

                case this.TYPES.GET:
                    transformedResult = _.get(result, step.path, step.default);
                    break;

                case this.TYPES.DECODE_URL:
                    transformedResult = decodeURI(result);
                    break;

                case this.TYPES.DECODE_HTML:
                    return entities.decode(result);
                    break;

                case this.TYPES.COMBINE:
                    const fields = step.fields || [];
                    const type = step.dataType || 'string';
                    const resultValue = [];
                    _.each(fields, field => {
                        let value = this._storage.get(field);
                        switch (type) {
                            case 'int':
                                value = parseInt(value);
                                break;
                            case 'number':
                                value = parseFloat(value);
                                break;
                        }
github redco / goose-parser / lib / transforms / TransformDecodeHtml.js View on Github external
doTransform() {
        return entities.decode(this._value);
    }
}