How to use ent - 10 common examples

To help you get started, we’ve selected a few ent 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 bunkerchat / bunker / api_old / services / messageService.js View on Github external
module.exports.createMessage = function (roomMember, text) {

	text = ent.encode(text);

	if (!text || !text.length) {
		throw new InvalidInputError(); // block the trolls
	}
	else if (/^\/nick\s+/i.test(text)) {
		return setUserNick(roomMember, text); // Change the current user's nick
	}
	else if (/^\/(away|afk|busy)/i.test(text)) {
		return setUserBusy(roomMember, text); // away, afk, busy (with optional message)
	}
	else if (/^\/help/i.test(text)) {
		return getHelp(roomMember, text);
	}
	else if (/^\/stats/i.test(text)) {
		return stats(roomMember, text);
	}
github oaeproject / Hilary / node_modules / oae-preview-processor / lib / processors / link / util.js View on Github external
return callback(err);
    }

    // Check if we can update the main content metadata (displayName, description, ..)
    opts = opts || {};
    if (
      opts.displayName &&
      ctx.content.displayName === ctx.content.link &&
      typeof opts.displayName === 'string'
    ) {
      ctx.addContentMetadata('displayName', ent.decode(opts.displayName));
      log().trace({ contentId: ctx.contentId }, 'Updating the content displayName.');
    }

    if (opts.description && !ctx.content.description && typeof opts.description === 'string') {
      ctx.addContentMetadata('description', ent.decode(opts.description));
      log().trace({ contentId: ctx.contentId }, 'Updating the content description.');
    }

    return callback();
  });
};
github fedspendingtransparency / data-act-broker-web-app / src / js / helpers / helpHelper.js View on Github external
const unescapeInlineHtml = (html) => {
    let tmpHtml = html;
    // find any inline HTML (as denoted by ```!inline-html [CODE] !inline-html```)
    const regex = /<p><code>!inline-html\n[\s\S]*\n!inline-html&lt;\/code&gt;&lt;\/p&gt;/;
    const results = regex.exec(tmpHtml);

    // we found inline HTML, unescape it and insert it into the parsed Markdown output
    if (results &amp;&amp; results.length &gt; 0) {
        const rawHtml = results[0].substring(21, results[0].length - 23);
        const decodedHtml = ent.decode(rawHtml);
        tmpHtml = tmpHtml.replace(regex, decodedHtml);
    }

    return tmpHtml;
};
</code></p>
github apostrophecms / apostrophe / apostrophe.js View on Github external
self.htmlToPlaintext = function(html) {
    // The awesomest HTML renderer ever (look out webkit):
    // block element opening tags = newlines, closing tags and non-container tags just gone
    html = html.replace(/&lt;\/.*?\&gt;/g, '');
    html = html.replace(/&lt;(h1|h2|h3|h4|h5|h6|p|br|blockquote).*?\&gt;/gi, '\n');
    html = html.replace(/&lt;.*?\&gt;/g, '');
    return ent.decode(html);
  };
github TimBeyer / html-to-vdom / lib / htmlparser-to-vdom.js View on Github external
convert: function (node, getVNodeKey) {
            if (node.type === 'tag' || node.type === 'script' || node.type === 'style') {
                return converter.convertTag(node, getVNodeKey);
            } else if (node.type === 'text') {
                return new VText(decode(node.data));
            } else {
                // converting an unsupported node, return an empty text node instead.
                return new VText('');
            }
        },
        convertTag: function (tag, getVNodeKey) {
github balena-io / balena-cli / automation / capitanodoc / markdown.ts View on Github external
.map(command => {
					const signature =
						typeof command === 'object'
							? command.signature // Capitano
							: capitanoizeOclifUsage(command.usage); // oclif
					return `\t- [${ent.encode(signature)}](${getAnchor(signature)})`;
				})
				.join('\n'),
github PAK90 / mtg-hunter / src / index.js View on Github external
function generateTextCostSymbols(source) {
  var tagged;
  if (source !== undefined) {
    // Get rid of / in any costs first, but only if inside {} brackets (so as not to affect +1/+1).
    source = source.replace(/(\/)(?=\w\})/g,'');
    // Then generate the tags through setting the innerHtml. This is the only way to preserve the text around the img tags.
    // Encode the source in html, to prevent XSS nastiness. Then replace the newlines with <br>. Then insert the <img> tags.
    tagged = <div>').replace(/\{([0-z,½,∞]+)\}/g, (fullMatch, firstMatch) =&gt;
        `<img height="12px/" src="./src/img/${firstMatch.toLowerCase()}.png">`
      )}}&gt;</div>
  }
  return tagged;
}
github pubpub / pubpub / src / markdown / markdown.js View on Github external
renderer.br = function (text) {
  var id = inlineIds++;
  inlines[id] = React.createElement(options.br || 'br', {key: keys++}, ent.decode(text));
  return '{$' + id + '$}';
};
github googleapis / google-cloud-node / packages / common / src / util.js View on Github external
this.response = errorBody.response;

  try {
    this.errors = JSON.parse(this.response.body).error.errors;
  } catch (e) {}

  var messages = [];

  if (errorBody.message) {
    messages.push(errorBody.message);
  }

  if (this.errors && this.errors.length === 1) {
    messages.push(this.errors[0].message);
  } else if (this.response && this.response.body) {
    messages.push(ent.decode(errorBody.response.body.toString()));
  } else if (!errorBody.message) {
    messages.push('Error during request.');
  }

  this.message = uniq(messages).join(' - ');
});

ent

Encode and decode HTML entities

MIT
Latest version published 5 days ago

Package Health Score

78 / 100
Full package analysis