How to use the he.decode function in he

To help you get started, we’ve selected a few he 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 opencollective / opencollective-api / server / lib / email.js View on Github external
const render = (template, data) => {
  let text;
  data.imageNotSvg = data.collective && data.collective.image && !data.collective.image.endsWith('.svg');
  data = merge({}, data);
  delete data.config;
  data.config = { host: config.host };

  // sets paypalEmail for purpose of email templates
  if (data.user) {
    data.user.paypalEmail = data.user.paypalEmail || data.user.email;
  }

  if (templates[`${template}.text`]) {
    text = templates[`${template}.text`](data);
  }
  const html = juice(he.decode(templates[template](data)));

  // When in development mode, we log the data used to compile the template
  // (useful to get login token without sending an email)
  debugLib('data')(`Rendering ${template} with data`, data);

  return { text, html };
};
github Bright-Tech / Yii2-Ace-Admin / js / markdown / to-markdown.js View on Github external
string = string.replace(/]*>`([\s\S]*?)`<\/pre>/gi, function(str, innerHTML) {
    var text = he.decode(innerHTML);
    text = text.replace(/^\t+/g, '  '); // convert tabs to spaces (you know it makes sense)
    text = text.replace(/\n/g, '\n    ');
    return '\n\n    ' + text + '\n';
  });
github DIYgod / RSSHub / lib / middleware / parameter.js View on Github external
'Cache-Control': `public, max-age=${config.cache.routeExpire * 100}`,
        });
        throw Error('wrong path');
    }

    if (ctx.state.data) {
        if ((!ctx.state.data.item || ctx.state.data.item.length === 0) && !ctx.state.data.allowEmpty) {
            throw Error('this route is empty, please check the original site or <a href="https://github.com/DIYgod/RSSHub/issues/new/choose">create an issue</a>');
        }

        // fix allowEmpty
        ctx.state.data.item = ctx.state.data.item || [];

        // decode HTML entities
        ctx.state.data.title &amp;&amp; (ctx.state.data.title = he.decode(ctx.state.data.title + ''));
        ctx.state.data.description &amp;&amp; (ctx.state.data.description = he.decode(ctx.state.data.description + ''));

        // sort items
        ctx.state.data.item = ctx.state.data.item.sort((a, b) =&gt; +new Date(b.pubDate || 0) - +new Date(a.pubDate || 0));

        ctx.state.data.item.forEach((item) =&gt; {
            item.title &amp;&amp; (item.title = he.decode(item.title + ''));

            // handle pubDate
            if (item.pubDate) {
                item.pubDate = new Date(item.pubDate).toUTCString();
            }

            // handle link
            if (item.link) {
                let baseUrl = ctx.state.data.link;
                if (baseUrl &amp;&amp; !baseUrl.match(/^https?:\/\//)) {
github bkonkle / reactifier / src / components / article.jsx View on Github external
export default function Article({author, description, link, pubDate, subscription, title}) {
  const date = moment(pubDate)

  return (
    <article>
      <h2><a href="{link}">{he.decode(title)}</a></h2>
      <section>
        <p>
          {he.decode(description)} <a href="{link}">» read more</a>
        </p>
      </section>
      <footer>
        From{author ? ` ${author} on` : ''}&nbsp;
        <a href="{subscription.link}">{subscription.title}</a>&nbsp;
        <time datetime="{date.format('YYYY-MM-DD')}">
          {date.format('MMMM Do, YYYY')}
        </time>
      </footer>
    </article>
  )
}
github moderntribe / events-gutenberg / src / modules / blocks / event-venue / venue.js View on Github external
renderVenueName() {
		const { beforeTitle, afterTitle, maybeEdit } = this.props;
		return (
			<div>
				{ beforeTitle }
				<h3>
					{ decode( this.getVenueName() ) }
				</h3>
				{ afterTitle }
			</div>
		);
	}
github dsifford / academic-bloggers-toolkit / src / js / _legacy / reference-list / index.tsx View on Github external
insertStaticBibliography = async (): Promise =&gt; {
        let data: CSL.Data[] = this.ui.selected.map(
            id =&gt; this.props.store.citations.CSL.get(id)!,
        );

        const selectionHasReferences = this.editor.selection.match(
            /^$/,
        );
        if (selectionHasReferences &amp;&amp; selectionHasReferences[1]) {
            const selectionIds: string[] = JSON.parse(
                decode(selectionHasReferences[1]),
            );
            data = [
                ...data,
                ...selectionIds.map(
                    id =&gt; this.props.store.citations.CSL.get(id)!,
                ),
            ];
        }

        try {
            const bibliography = await this.processor.createStaticBibliography(
                data,
            );
            this.clearSelection();
            this.editor.setBibliography(
                this.props.store.displayOptions,
github htmlburger / carbon-fields / assets / js / fields / components / association / list-item.js View on Github external
}) =&gt; {
	return <li id="{item.id}">
		<span></span>

		<a href="#">
			{
				item.edit_link &amp;&amp; !associated
				? <em></em>
				: null
			}

			<em>{item.label}</em>

			<span></span>

			{decode(item.title)}

			{
				item.is_trashed
				? <i></i>
				: null
			}
		</a>

		{
			associated
			? <input readonly="{true}" disabled="{!visible}" value="{`${item.type}:${item.subtype}:${item.id}`}" name="{`${prefix}[${index}]`}" type="hidden"></li>
github bkonkle / reactifier / src / components / article.jsx View on Github external
export default function Article({author, description, link, pubDate, subscription, title}) {
  const date = moment(pubDate)

  return (
    <article>
      <h2><a href="{link}">{he.decode(title)}</a></h2>
      <section>
        <p>
          {he.decode(description)} <a href="{link}">» read more</a>
        </p>
      </section>
      <footer>
        From{author ? ` ${author} on` : ''}&nbsp;
        <a href="{subscription.link}">{subscription.title}</a>&nbsp;
        <time datetime="{date.format('YYYY-MM-DD')}">
          {date.format('MMMM Do, YYYY')}
        </time>
      </footer>
    </article>
  )
}
github builderbook / builderbook / book / 6-end / server / models / Chapter.js View on Github external
return `${text}`;
  };

  marked.setOptions({
    renderer,
    breaks: true,
    highlight(code, lang) {
      if (!lang) {
        return hljs.highlightAuto(code).value;
      }

      return hljs.highlight(lang, code).value;
    },
  });

  return marked(he.decode(content));
}
github oracle / content-and-experience-toolkit / sites / bin / report.js View on Github external
var _unescapeHTML = function (str) {
	return he.decode(str);
};

he

A robust HTML entities encoder/decoder with full Unicode support.

MIT
Latest version published 6 years ago

Package Health Score

70 / 100
Full package analysis