叙事
标记语言与 CSS
了解如何在 Pixi’VN 中结合 ink 使用 Markdown 和 CSS 样式,包括如何转义冲突符号以及添加换行。
ink 与 Pixi’VN 的集成提供了一些附加功能,便于使用在文本中引入 标记 的组件。
换行
要换行,可以使用转义字符 \n。
在我们的示例中,由于使用 Markdown 显示换行,因此需要两个换行符:\n\n。
例如:
=== start ===
Hello, this is a test. \\n\\n This is a new line.Markdown
在 Pixi’VN 中,建议使用 Markdown 为文本添加样式。如果你已经在项目中实现了 Markdown,就可以在 ink 中使用 Markdown 语法设置文本样式。
为此,请注意 Markdown 语法中的许多符号也用于 ink 语法,例如 #、*、/、~、-、| 等。为避免冲突,可以在 Markdown 符号前添加转义字符 \。
例如:
Hello, this is some *italic* text and this is some **bold** text.\# Markdown Test \\n<>
Hello, this is a test of the markdown parser. Pixi’VN does not manage markdown, but you can implement a markdown parser to display text with markdown syntax. \\n<>
For example in React, you can use the library [@tanstack/markdown](https:\/\/www.npmjs.com/package/@tanstack/markdown). \\n<>
\#\# Bold Text \\n<>
\**This is bold text.** \\n<>
\#\# Italic Text \\n<>
\*This is italic text.* \\n<>
\#\# Delete Text \\n<>
\~~This is deleted text.~~ \\n<>
\#\# Link Test \\n<>
[Link to Google](https:\/\/www.google.com) \\n<>
\#\# H2 Test \\n<>
\#\#\# H3 Test \\n<>
\#\#\#\# H4 Test \\n<>
\#\# Code Test \\n<>
\`Hello World\` \\n<>
\`\`\`js \\n<>
console.log("Hello World") \\n<>
\`\`\` \\n<>
\#\# List Test \\n<>
\- Item 1 \\n<>
\* Item 2 \\n<>
\- [x] Item 3 \\n<>
\#\# Table Test \\n<>
\| Header 1 \| Header 2 \| \\n<>
\| -------- \| -------- \| \\n<>
\| Cell 1 \| Cell 2 \| \\n<>
\#\# Separator Test \\n<>
\*\*\* \\n<>
FooterCSS
你也可以使用 Tailwind CSS 类,通过 HTML 设置文本样式。
例如:
<span class="inline-block text-blue-500">some *blue* text</span>.
<span class="inline-block text-red-500">some *red* text</span>.
<span class="inline-block text-green-500">some *green* text</span>.