跳转到内容
Pixi’VN

Markdown

概述在 Pixi’VN 中使用 Markdown 及其集成,包含 React、Vue、Svelte 和 Angular 的示例。

Pixi’VN 不绑定任何标记语言,赋予开发者选择自己偏好的标记语言的能力。不过,推荐使用 Markdown。

模板

在所有模板中,Markdown 组件已经预先定义。

ink

你可以在 ink 语法中使用此方法。详情请参阅此处。

以下是一些在 JavaScript 生态系统中实现 Markdown 的示例:

// I use the @tanstack/markdown library to convert the Markdown to HTML
// read more about it here: https://www.npmjs.com/package/@tanstack/markdown
// Tables, strikethrough and task lists (GFM) are supported out of the box,
// `allowHtml` enables raw HTML (e.g. <span style="color:blue">...</span>).
import { Markdown } from "@tanstack/markdown/react";

export default function MarkdownComponent({ text }: { text: string }) {
    return <Markdown allowHtml>{text}</Markdown>;
}

Markdown Typewriter

Markdown Typewriter is a library that combines Markdown and Typewriter. 该库由我创建,旨在满足我在 React 模板的 Markdown 组件中添加打字机效果的需求。

It renders Markdown with @tanstack/markdown and accepts its props. With allowHtml, raw HTML is typed out too, keeping its attributes: <span style="color:blue">...</span> is blue while it appears.

npm install markdown-typewriter motion @tanstack/markdown
React
import { MarkdownTypewriter } from "markdown-typewriter/react";

export default function MarkdownComponent({ text }: { text: string }) {
    return <MarkdownTypewriter allowHtml>{text}</MarkdownTypewriter>;
}

本页内容