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.
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 .
Bullet lists
Keep the reading rhythm
- Nested items indent
Ordered lists
Keep their numbers
- Task lists render
- Checkboxes
Blockquotes set a passage apart.
| Node | Styled by |
|---|---|
| Heading | typeset |
| Table | typeset |
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.
- 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.
Bullet items
Nest by indenting
- Two spaces are enough
- Deeper levels keep the same rhythm
Ordered items
Keep their starting number
And their hanging indent
- Task lists
- Render real checkboxes
| Node | Styled by | Align |
|---|---|---|
| Heading | typeset | left |
| Table | typeset | center |
| Code | shiki | right |
A blockquote sets a passage apart.
It can hold paragraphs, lists and code.
A thematic break separates sections without a wrapper.
Images keep their aspect ratio and inherit the typeset radius.
Links underline on hover and only accept safe schemes: javascript: never becomes an anchor.
Installation
Add the item with the shadcn CLI, or copy the source manually.
pnpm dlx shadcn@latest add litingyes/blocove/markdownRequires 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-mathtypeset.css next to your stylesheet, import it after Tailwind and add the .typeset-docs preset. See the Rich text editor setup.Usage
curl -o src/typeset.css https://ui.shadcn.com/typeset.css/* 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.
| Prop | Type | Default |
|---|---|---|
source | string | Required |
streaming | boolean | false |
typeset | boolean | true |
components | MarkdownComponents | - |
className | string | - |
contentClassName | string | - |
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.
| Prop | Type | Default |
|---|---|---|
code | ComponentType<MarkdownCodeProps> | - |
math | ComponentType<MarkdownMathProps> | - |
fences | Record<string, ComponentType<MarkdownCodeProps>> | - |