Markdown

A streaming-safe markdown renderer. Every node is a semantic element inside a shadcn/typeset container, so the typography comes from typeset, and the append-only cache re-parses only the open block while the source grows.

UImarkdownView JSON

Every node is a plain semantic element inside a `.typeset typeset-docs` container, so a document looks exactly like the rich text editor and no second stylesheet has to be kept in sync. Streaming is the default behaviour, not a second mode: while `source` grows, the parse cache keeps every block that already ended and re-parses only the open one, so finished elements keep their DOM, a completed fence is not tokenized again, and a half-written marker stays literal until its closing token arrives. Raw HTML is escaped, and only `http`, `https`, `mailto`, `tel`, fragment and relative targets become anchors. Fence renderers register through `components.fences` keyed by lowercase language and fall back to `code`; they receive `complete` when the closing fence has arrived or the source is final, so a diagram renders on the closing line even when the answer ends without a trailing newline. A fence with no registered renderer keeps its source.

Preview

Composable by design

Blocove renders markdown into the elements shadcn/typeset already styles, so a document looks like the rich text editor without a second stylesheet.

Nodes

Text carries strong, emphasis, deleted and inline code, plus links and an image.

  • Bullet lists

  • Keep the reading rhythm

    • Nested items indent
  1. Ordered lists

  2. Keep their numbers

  • Task lists render
  • Checkboxes

Blockquotes set a passage apart.

NodeStyled by
Headingtypeset
Tabletypeset
ts
export const greeting = 'Blocove'

A claim with a footnote1.


Every node above is a plain semantic element: no wrapper components, no parallel stylesheet, no prose classes to keep in sync.

  1. Footnotes collect at the end of the document.

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

Headings scale from the typeset preset, so the document rhythm matches the rich text editor exactly.

Inline content keeps its meaning: strong, emphasis, deleted, inline code, snake_case_name (which is not emphasis), an escaped *marker*, a link and a footnote reference1.

  1. References render as superscript numbers.
  • Bullet items

  • Nest by indenting

    • Two spaces are enough
    • Deeper levels keep the same rhythm
  1. Ordered items

  2. Keep their starting number

  3. And their hanging indent

  • Task lists
  • Render real checkboxes
NodeStyled byAlign
Headingtypesetleft
Tabletypesetcenter
Codeshikiright

A blockquote sets a passage apart.

It can hold paragraphs, lists and code.


A thematic break separates sections without a wrapper.

The Blocove editor preview

Images keep their aspect ratio and inherit the typeset radius.

Links underline on hover and only accept safe schemes: javascript: never becomes an anchor.

Footnotes keep the document readable1 without breaking the flow2.

  1. The definition collects at the end, inside the typeset flow.
  2. References render as superscript numbers and link to their note.
Streaming… 0 / 445 characters

Installation

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

pnpm dlx shadcn@latest add litingyes/blocove/markdown

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

This example also uses: markdown-code-blockmarkdown-math

pnpm dlx shadcn@latest add litingyes/blocove/markdown-code-block litingyes/blocove/markdown-math
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

Install typeset
curl -o src/typeset.css https://ui.shadcn.com/typeset.css
Typeset setup
/* src/styles.css */@import "tailwindcss";@import "./typeset.css";@import "@fontsource-variable/inter";@import "@fontsource-variable/jetbrains-mono";
.typeset-docs {  --typeset-font-body: var(--font-inter);  --typeset-font-heading: var(--font-inter);  --typeset-font-mono: var(--font-jetbrains-mono);  --typeset-size: 16px;  --typeset-leading: 1.75;  --typeset-flow: 1.25em;}

API Reference

Props accepted by the exported components.

Markdown

The streaming-safe renderer. `source` is the whole document; growing the string token by token is the case the shell is built for. The layout element carries `data-slot="markdown"`; the typeset element deliberately does not, because typeset skips the descendants of a `data-slot` element.

PropTypeDefault
sourcestringRequired
streamingbooleanfalse
typesetbooleantrue
componentsMarkdownComponents-
classNamestring-
contentClassNamestring-

MarkdownComponents

Capability map of the shell. A node with no registered renderer keeps its literal source — a fence falls back to `<pre><code>` and math stays `$…$` — so the optional items compose without the shell knowing them. Fence renderers are keyed by lowercase language and fall back to `code`; a fence renderer receives `complete` when the closing fence has arrived or the source is final.

PropTypeDefault
codeComponentType<MarkdownCodeProps>-
mathComponentType<MarkdownMathProps>-
fencesRecord<string, ComponentType<MarkdownCodeProps>>-