Content
The content-rendering stack — markdown, code, math, diagrams, callouts and images for LLM/chat/doc output.
The content-rendering stack turns LLM / chat / documentation output into rich, safe UI: full GitHub-flavored markdown, KaTeX math, Shiki-highlighted code, Mermaid diagrams, GitHub-style callouts, and lazy, zoomable images. It lives on its own subpath, @yuhuanowo/yunui/content, so apps that do not import this entry do not include its rendering modules. The entry statically imports Shiki's core, React Markdown and its Markdown plugins; only Shiki grammars/themes and Mermaid load on demand.
Install
Although these packages are optional peers in YunUI's package metadata, the @yuhuanowo/yunui/content barrel statically imports the Markdown, math, and Shiki modules. Install these renderer peers in the host app whenever you import this entry:
pnpm add @yuhuanowo/yunui react-markdown remark-gfm remark-math \ rehype-raw rehype-katex rehype-slug katex shikiMermaid is dynamically loaded and only needs to be installed when you render Mermaid charts. rehype-sanitize is a regular YunUI dependency. yunui doctor checks content stylesheet wiring but does not verify that renderer peers resolve in the host build; run the app's build to validate module resolution.
Styles
Import the content stylesheet and the KaTeX stylesheet once, wherever you load global CSS:
@import "@yuhuanowo/yunui/content.css";@import "katex/dist/katex.min.css";Import
import { MarkdownRenderer, CodeBlock, InlineCode, CalloutBlock, MathRenderer, InlineMath, BlockMath, MermaidDiagram, ContentImage, ImageLightbox,} from "@yuhuanowo/yunui/content";Everything at once
MarkdownRenderer composes the whole stack. Feed it a markdown string with headings, a table, a task list, a fenced code block, a ```mermaid diagram, $math$, and a > [!NOTE] callout, and it renders each with the matching component.
MarkdownRenderer
Markdown renderer
Note
Callouts use GitHub's > [!TYPE] blockquote syntax — note, tip, important, warning, caution.
Table
| Feature | Supported | Notes |
|---|---|---|
| Tables | ✅ | GitHub-flavored |
| Task list | ✅ | Interactive checkboxes |
| Math | ✅ | KaTeX inline & block |
Task list
- Render headings, tables and lists
- Highlight code with Shiki
- Ship to production
Code
export function greet(name: string): string {
return `Hello, ${name}!`;
}Math
Diagram
The pieces
Each renderer is also exported as a standalone component so you can use it directly in your layout. These named exports still come from the same /content entry, so they resolve the entry's statically imported peers even if you only render one component:
- Markdown Renderer — the full GFM pipeline.
- Code Block — Shiki highlighting with a filename header, line numbers and copy.
- Callout Block — GitHub-style note / tip / warning panels.
- Math Renderer — KaTeX, inline or block.
- Mermaid Diagram — on-demand diagrams.
- Content Image — lazy, fade-in, click-to-zoom images.
- Image Lightbox — the full-screen viewer behind them.