You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Language grammars listed below are re-distributed via [`tm-grammars`](https://github.com/antfu/textmate-grammars-themes/tree/main/packages/tm-grammars) into the `shikiji` package.
4
6
5
7
<LanguagesList />
6
8
7
9
Grammars are covered by their repositories’ respective licenses, which are permissive (apache-2.0, mit, etc), and made available in [this NOTICE](https://github.com/antfu/textmate-grammars-themes/blob/main/packages/tm-grammars/NOTICE).
8
10
9
11
For loading your custom languages, please reference to [this guide](/guide/load-lang).
12
+
13
+
## Special Languages
14
+
15
+
### Plain Text
16
+
17
+
You can set lang to `text` to bypass highlighting. This is useful as the fallback when you receive user specified language that are not available. For example:
18
+
19
+
```txt
20
+
import { codeToHtml } from 'shikiji'
21
+
22
+
const html = codeToHtml('console.log("Hello World")', {
23
+
lang: 'text', // [!code hl]
24
+
theme: 'vitesse-light',
25
+
})
26
+
```
27
+
28
+
`txt`, `plain` are provided as aliases to `text` as well.
29
+
30
+
### ANSI
31
+
32
+
A special processed language `ansi` is provided to highlight terminal outputs. For example:
33
+
34
+
```ansi
35
+
[0;90m┌[0m [0;36;1mWelcome to VitePress into the `shikiji` package.
4
6
5
7
<ThemesList />
6
8
7
9
Themes are covered by their repositories’ respective licenses, which are permissive (apache-2.0, mit, etc), and made available in [this NOTICE](https://github.com/antfu/textmate-grammars-themes/blob/main/packages/tm-themes/NOTICE).
8
10
9
11
For loading your custom themes, please reference to [this guide](/guide/load-theme).
12
+
13
+
## Special Themes
14
+
15
+
You can set theme to `none` to bypass highlighting. This is useful as the fallback when you receive user specified theme names that are not available. For example:
16
+
17
+
```ts twoslash theme:none
18
+
import { codeToHtml } from'shikiji'
19
+
20
+
const html =codeToHtml('console.log("Hello World")', {
<spanclass="line"><span></span><span>/** The title of the todo item */</span></span>
29
+
<spanclass="line"><span></span><span><spanclass="twoslash-hover"><spanclass="twoslash-popup-container"><codeclass="twoslash-popup-code"><spanclass="line"><span>Todo.title: string</span></span></code><divclass="twoslash-popup-docs">The title of the todo item</div></span>title</span></span><span>: string;</span></span>
30
+
<spanclass="line"><span>}</span></span>
31
+
<spanclass="line"><span></span></span>
32
+
<spanclass="line"><span>const </span><span><spanclass="twoslash-hover"><spanclass="twoslash-popup-container"><codeclass="twoslash-popup-code"><spanclass="line"><span>const todo: Readonly<Todo></span></span></code></span>todo</span></span><span>: </span><span><spanclass="twoslash-hover"><spanclass="twoslash-popup-container"><codeclass="twoslash-popup-code"><spanclass="line"><span>type Readonly<T> = { readonly [P in keyof T]: T[P]; }</span></span></code><divclass="twoslash-popup-docs">Make all properties in T readonly</div></span>Readonly</span></span><span><</span><span>Todo</span><span>> = {</span></span>
33
+
<spanclass="line"><span></span><span><spanclass="twoslash-hover twoslash-query-presisted"><spanclass="twoslash-popup-container"><divclass="twoslash-popup-arrow"></div><codeclass="twoslash-popup-code"><spanclass="line"><span>title: string</span></span></code><divclass="twoslash-popup-docs">The title of the todo item</div></span>title</span></span><span>: "Delete inactive users".</span><span><spanclass="twoslash-hover"><spanclass="twoslash-popup-container"><codeclass="twoslash-popup-code"><spanclass="line"><span>String.toUpperCase(): string</span></span></code><divclass="twoslash-popup-docs">Converts all the alphabetic characters in a string to uppercase.</div></span>toUpperCase</span></span><span>(),</span></span>
34
+
<spanclass="line"><span>};</span></span>
35
+
<spanclass="line"><span></span></span>
36
+
<spanclass="line"><span><spanclass="twoslash-hover"><spanclass="twoslash-popup-container"><codeclass="twoslash-popup-code"><spanclass="line"><span>const todo: Readonly<Todo></span></span></code></span>todo</span></span><span>.</span><span><spanclass="twoslash-error">title</span></span><span> = "Hello";</span></span><divclass="twoslash-meta-line twoslash-error-line">Cannot assign to 'title' because it is a read-only property.</div><spanclass="line"><span></span></span>
If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal.
39
+
All other strings are considered decimal.</span></span></div></span>arseInt</span></span><span>(</span><span><spanclass="twoslash-hover"><spanclass="twoslash-popup-container"><codeclass="twoslash-popup-code"><spanclass="line"><span>const todo: Readonly<Todo></span></span></code></span>todo</span></span><span>.</span><span><spanclass="twoslash-hover"><spanclass="twoslash-popup-container"><codeclass="twoslash-popup-code"><spanclass="line"><span>title: string</span></span></code><divclass="twoslash-popup-docs">The title of the todo item</div></span>title</span></span><span>, 10);</span></span>
0 commit comments