Linguaggio di markup e CSS
Scopri come usare Markdown e gli stili CSS con ink in Pixi’VN, incluso come eseguire l’escape dei simboli in conflitto e aggiungere nuove righe.
L’integrazione tra ink e Pixi’VN offre alcune funzionalità aggiuntive per facilitare l’uso di componenti che introducono il markup nel testo.
Interruzioni di riga
Per andare a capo, puoi usare il carattere di escape \n.
Nel nostro caso, poiché usiamo Markdown per visualizzare l’interruzione di riga, ne servono due: \n\n.
Ad esempio:
=== start ===
Hello, this is a test. \\n\\n This is a new line.Markdown
Su Pixi’VN si consiglia di usare Markdown per formattare il testo. Se hai implementato Markdown nel tuo progetto, puoi utilizzare la sintassi Markdown per formattare il testo in ink.
Per farlo, tieni presente che molti simboli della sintassi Markdown sono usati anche dalla sintassi di ink, ad esempio #, *, /, ~, -, |, ecc. Per evitare conflitti, puoi inserire il carattere di escape \ prima del simbolo Markdown.
Ad esempio:
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
Puoi anche usare le classi Tailwind CSS per formattare il testo tramite HTML.
Ad esempio:
<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>.