YuhuanStudioYunUIDocs
Content

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:

bash2 lines
pnpm add @yuhuanowo/yunui react-markdown remark-gfm remark-math \
rehype-raw rehype-katex rehype-slug katex shiki

Mermaid 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:

css2 lines
@import "@yuhuanowo/yunui/content.css";
@import "katex/dist/katex.min.css";

Import

tsx12 lines
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

Full GFM with emphasis, strikethrough, links and inline code.

Note

Callouts use GitHub's > [!TYPE] blockquote syntax — note, tip, important, warning, caution.

Table

FeatureSupportedNotes
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

TypeScript3 lines
export function greet(name: string): string {
  return `Hello, ${name}!`;
}

Math

The Gaussian integral is ∫−∞∞e−x2 dx=π\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}, and in block form:
E=mc2E = mc^2

Diagram

Rendering 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:

On this page