Markdown Math

Math renderer for the markdown item, typeset with KaTeX. An expression that is still being written renders instead of throwing, and needs no math renderer registered, where the shell leaves the source literal.

UImarkdown-mathView JSON

Formulas are typeset with KaTeX: `$…$` renders inline and `$$…$$` as a display block that scrolls instead of overflowing the reading column. A formula that is still being written, or that has a syntax error, renders with KaTeX's error color instead of throwing, so streaming math never blanks the sentence. Without this renderer the shell leaves the dollar signs in the text.

Preview

Inline math typesets in the sentence, as in eiπ+1=0e^{i\pi} + 1 = 0.

Display math gets its own line:

∫01x2 dx=13\int_0^1 x^2 \, dx = \frac{1}{3}

Installation

Add the item with the shadcn CLI, or copy the source manually.

pnpm dlx shadcn@latest add litingyes/blocove/markdown-math

Requires a shadcn/ui project set up with Base UI primitives. Blocove is developed against the b0 preset, but it installs no base config or theme tokens: your own preset, fonts and colors stay in place.

Or install from the namespace after adding the registry: npx shadcn@latest add @blocove/markdown-math

This example also uses: markdown

pnpm dlx shadcn@latest add litingyes/blocove/markdown
Typography is provided by shadcn/typeset. Copy typeset.css next to your stylesheet, import it after Tailwind and add the .typeset-docs preset. See the Rich text editor setup.

Usage

Import the KaTeX stylesheet
// KaTeX ships the layout the formulas render into.import "katex/dist/katex.min.css"

API Reference

Props accepted by the exported components.

MarkdownMath

Renders one formula. The shell passes `value`, `display` and `streaming`; register it through the shell's `components` map. The item declares `katex` as its dependency and expects the KaTeX stylesheet to be imported once by the application.

Extends MarkdownMathProps.

PropTypeDefault
valuestringRequired
displaybooleanRequired
streamingboolean-
classNamestring-