How to use the ent.encode function in ent

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 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 bunkerchat / bunker / server / services / fightService.js View on Github external
challenger,
		opponent
	) {
		var opponentNick = opponent.nick;
		var challengerNick = challenger.nick;

		var message = [];
		message.push("@" + challengerNick + " has challenged @" + opponentNick + " to a fight!");
		message.push(
			"Respond using /f " +
				challengerNick +
				" with 3 round moves, i.e. /f " +
				challengerNick +
				" h m l (see /help fight for more details)"
		);
		return { message: ent.encode(message.join("\n")) };
	});
}
github krakenjs / makara / lib / handler / metadata.js View on Github external
_format: function (def, str) {
        var key, bundle, orig;

        key = ent.encode(def.attributes.key || '');
        bundle = ent.encode(this._handler.bundle.file || '');
        orig = ent.encode(str || '');

        return util.format(this._pattern, key, bundle, orig, str);
    },
github balena-io / balena-cli / automation / capitanodoc / markdown.ts View on Github external
function renderCapitanoCommand(command: CapitanoCommand): string[] {
	const result = [`## ${ent.encode(command.signature)}`, command.help];

	if (!_.isEmpty(command.options)) {
		result.push('### Options');

		for (const option of command.options!) {
			if (option == null) {
				throw new Error(`Undefined option in markdown generation!`);
			}
			result.push(
				`#### ${utils.parseCapitanoOption(option)}`,
				option.description,
			);
		}
	}
	return result;
}

ent

Encode and decode HTML entities

MIT
Latest version published 6 days ago

Package Health Score

78 / 100
Full package analysis