How to use the katex/katex.js.renderToString function in katex

To help you get started, we’ve selected a few katex 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 imachug / Kiwipedia / main / src / wiki-templates / mathtag.js View on Github external
async afterRender(params, renderer) {
		try {
			return `<span class="math">${katex.renderToString(params._)}</span>`;
		} catch(e) {
			if(e instanceof katex.ParseError) {
				return await renderer(
					"ambox",
					{
						type: "serious",
						text: "Incorrect formula",
						"text-small": `Formula <code>${params._}</code> is incorrect.`
					}
				);
			} else {
				return await renderer(
					"ambox",
					{
						type: "serious",
						text: "Error during rendering formula",