How to use @bbob/parser - 1 common examples

To help you get started, we’ve selected a few @bbob/parser 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 DoctorMcKay / node-steam-user / components / chatroom.js View on Github external
function parseBbCode(str) {
	if (typeof str != 'string') {
		// Don't try to process non-string values, e.g. null
		return str;

	}
	// Steam will put a backslash in front of a bracket for a BBCode tag that shouldn't be parsed as BBCode, but our
	// parser doesn't ignore those. Let's just replace "\\[" with some string that's very improbable to exist in a Steam
	// chat message, then replace it again later.

	let replacement = Crypto.randomBytes(32).toString('hex');
	str = str.replace(/\\\[/g, replacement);

	let parsed = BBCode.parse(str, {
		"onlyAllowTags": [
			"emoticon",
			"code",
			"pre",
			"img",
			"url",
			"spoiler",
			"quote",
			"random",
			"flip",
			"tradeofferlink",
			"tradeoffer"
		]
	});

	return collapseStrings(parsed.map(processTagNode));

@bbob/parser

A BBCode to AST Parser part of @bbob

MIT
Latest version published 26 days ago

Package Health Score

80 / 100
Full package analysis

Popular @bbob/parser functions