carta/packages/plugin-math
2024-04-12 16:02:45 +02:00
..
src feat: use unified+rehype for parsing markdown 2024-04-12 08:24:46 +02:00
package.json fix(plugin-math): invalid version 2024-04-12 16:02:45 +02:00
README.md refactor: remove verbose prefixes 2024-04-12 08:24:37 +02:00
tsconfig.json fix: remove typescript project references 2023-11-14 18:37:19 +01:00

Carta Math Plugin

This plugin adds support for Katex expressions. Install it using:

npm i @cartamd/plugin-math

Setup

Styles

You need to get access to the katex stylesheet, to do so, you can either install katex using:

npm i katex

and then adding this import to your app:

import 'katex/dist/katex.css';

or by using a content delivery network:

<link
	rel="stylesheet"
	href="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/katex.min.css"
	integrity="sha384-3UiQGuEI4TTMaFmGIZumfRPtfKQ3trwQE2JgosJxCnGmQpL/lJdjpcHkaaFwHlcI"
	crossorigin="anonymous"
/>

Extension

<script lang="ts">
	import { Carta, MarkdownEditor } from 'carta-md';
	import { math } from '@cartamd/plugin-math';

	const carta = new Carta({
		extensions: [math()]
	});
</script>

<MarkdownEditor {carta} />

Usage

Inline:

Pythagorean theorem: $a^2+b^2=c^2$

Block:

$$
{\displaystyle {d^{2}x^{\mu } \over ds^{2}}+\Gamma ^{\mu }{}_{\alpha \beta }{dx^{\alpha } \over ds}{dx^{\beta } \over ds}=0}
$$

Documentation

Checkout the docs for examples, options and more.