A monorepo contains react components render Yozora AST Nodes. See https://yozora.guanghechen.com for details.
Use @yozora/react-yozora to render the @yozora/ast.
Choose @yozora/react-gfm for @yozora/parser-gfm ASTs, or
@yozora/react-gfm-ex for tables, strikethrough, extended autolinks and task
lists. @yozora/react-yozora adds footnotes, math, admonitions and executable
code. The presets share @yozora/react, the rendering kernel. The former
@yozora/react-markdown API now lives in @yozora/react-yozora.
The current prerelease line uses 3.0.0-alpha.26 across all public packages. See the
release notes for breaking changes and known limitations, and
release workflow for maintainer commands.
yozora.demo.mp4
Run pnpm demo and open http://127.0.0.1:7302 to test themes, Markdown, the code editor,
and live JSX. See packages/demo for development commands.
Import the stylesheet for the highest-level Yozora component you use:
import '@yozora/react-yozora/style.css'
import { ThemeProvider } from '@yozora/react-renderer'Each styled package exports ./style.css, including its dependency components.
For example, standalone editor users import @yozora/react-renderer-code/style.css.
CSS is loaded explicitly so ESM, CommonJS, and server rendering remain usable without
an automatic CSS loader. Keep these imports in your application's CSS entry point.
Styles are compiled with Tailwind CSS v4. The consumer does not need Tailwind, content
scanning, or Emotion. Utilities use the yz prefix, and Preflight is excluded. Custom
CSS can target existing yozora-* classes and override the --yozora_* tokens. Library
rules are unlayered so ordinary host resets do not outrank component selectors.
Utilities follow component rules; use matching specificity or explicit important
utilities when overriding more specific component selectors.
Use vscLightModernSchema.colors and vscDarkModernSchema.colors for direct
color-map access. The former lightSchema and darkenSchema exports were removed.
- Add the stylesheet import; remove
@emotion/cssif your application no longer uses it. - Import
ThemeProviderfrom@yozora/react-renderer. Replacetheme="light"withtheme="vsc" variant="light-modern", andtheme="darken"withtheme="vsc" variant="dark-modern". KeepclassNameandstyle. The new palettes replace the old colors; see the theme API. ThemeProvider.breakpoints,IThemeContext.breakpoints, andIBreakpointsremain available. The default small-screen threshold is479pxin compiled CSS; customxsMinusqueries render scoped<style media="...">elements and work before hydration and without JavaScript. Both paths use the same responsive rules.- For nonce-based CSP, pass the response nonce to
ThemeProviderthrough itsnonceprop. Custom breakpoint styles in both the theme and Markdown receive it. Nested providers inherit the nonce unless they supply their own. INodeStyleMapremains available without an Emotion dependency. Custom renderers continue to useINodeRendererMap,className, and Reactstyleprops.- Tables now render inside
.yozora-table-scrollfor horizontal scrolling. Direct-child selectors such as.yozora-markdown > section > tableneed to account for this wrapper; descendant selectors such as.yozora-markdown tablecontinue to work. - Minimum supported browsers are Chrome/Edge 111, Safari 16.4, and Firefox 128.
- Runtime JSX previews can use application CSS classes that were included at build time; class names created only inside runtime code strings are not compiled on demand.
-
npm
npm install --save @yozora/react-yozora@alpha
-
yarn
yarn add @yozora/react-yozora@alpha
import '@yozora/react-yozora/style.css'
import { calcDefinitionMap, calcFootnoteDefinitionMap } from '@yozora/ast-util'
import { ImageViewer, ThemeProvider } from '@yozora/react-renderer'
import YozoraParser from '@yozora/parser'
import { MathJaxProvider, Markdown, MarkdownProvider } from '@yozora/react-yozora'
const parser = new YozoraParser()
const ast = parser.parse(`source markdown contents`, { shouldReservePosition: true })
const definitionMap = calcDefinitionMap(ast)
const footnoteDefinitionMap = calcFootnoteDefinitionMap(ast)
<MathJaxProvider>
<ThemeProvider theme="vsc" variant="light-modern">
<MarkdownProvider
definitionMap={definitionMap}
footnoteDefinitionMap={footnoteDefinitionMap}
ImageViewer={ImageViewer}
>
<Markdown ast={ast} />
</MarkdownProvider>
</ThemeProvider>
</MathJaxProvider>| Package Name | Description |
|---|---|
| @yozora/react | Shared document layout and Provider; renderer defaults are supplied by a preset. |
| @yozora/react-renderer | AST renderers, SVG/image previews, themes, syntax highlighting, tokens and utilities. |
| Package Name | AST standard and additions |
|---|---|
| @yozora/react-gfm | @yozora/parser-gfm base nodes. |
| @yozora/react-gfm-ex | GFM plus tables, strikethrough, extended autolinks and task lists. |
| @yozora/react-yozora | GFM-Ex plus footnotes, math, admonitions and executable code. |
| Package Name | Token Name |
|---|---|
| @yozora/react-renderer-admonition | admonition |
| @yozora/react-renderer-code | code |
@yozora/react-renderer-code also exports CodeEditor, CodeEmbed, CodeLiteral, CodeLive,
CopyButton, and LightButtons for standalone use.
See its component documentation.
It also provides runner factories for Graphviz, JSX, and math.
| Package Name | Description |
|---|---|
| @yozora/react-embed-jsx | React component for rendering jsx directly in browser. |
| @yozora/react-embed-graphviz | React component for rendering graphviz (dot) directly in browser. |
| @yozora/react-embed-math | Render formula with mathjax in react. |
| @yozora/react-embed-mermaid | Render Mermaid diagrams as SVG in React. |