Skip to content

Commit 6d0d903

Browse files
authored
feat: use shiki for better syntax highlighting (#2)
1 parent 2e5fdb9 commit 6d0d903

File tree

6 files changed

+468
-1175
lines changed

6 files changed

+468
-1175
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ Source code to highlight.
4444

4545
### lang
4646

47-
- Type: `string`
48-
49-
Language of the source code. If you don't set it yourself, this component will try to auto-detect it. [All languages of highlight.js](https://github.com/highlightjs/highlight.js/blob/master/SUPPORTED_LANGUAGES.md#supported-languages) are supported.
47+
- Type: [Lang](https://github.com/shikijs/shiki/blob/main/docs/languages.md)
5048

5149
### theme
5250

53-
- Type: [Theme](https://github.com/felixfbecker/cli-highlight/blob/main/src/theme.ts#L280)<br>
51+
- Type: [Theme](https://github.com/shikijs/shiki/blob/main/docs/themes.md)<br>
52+
53+
## Credits
5454

55-
You can write your custom theme and pass it as a prop. [More info regarding custom theme](https://github.com/felixfbecker/cli-highlight/blob/main/README.md#themes).
55+
Syntax Highlight is based on [Shiki](https://github.com/shikijs/shiki)

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,20 @@
4444
},
4545
"homepage": "https://github.com/vue-terminal/syntax-highlight#readme",
4646
"peerDependencies": {
47-
"vue-termui": "^0.0.17",
48-
"@vue/runtime-core": "^3.2.41"
47+
"@vue/runtime-core": "^3.2.41",
48+
"vue-termui": "^0.0.17"
4949
},
5050
"devDependencies": {
5151
"@types/node": "^18.11.9",
5252
"@vue/runtime-core": "^3.2.41",
53+
"chalk": "^5.2.0",
5354
"prettier": "^2.8.0",
5455
"tsup": "^6.5.0",
5556
"typescript": "^4.9.3",
5657
"vue": "^3.2.41",
5758
"vue-termui": "0.0.17"
5859
},
5960
"dependencies": {
60-
"cli-highlight": "^2.1.11"
61+
"shiki": "^0.11.1"
6162
}
6263
}

playground/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ export {}
88
declare module '@vue/runtime-core' {
99
export interface GlobalComponents {
1010
Box: typeof import('vue-termui')['TuiBox']
11+
Text: typeof import('vue-termui')['TuiText']
1112
}
1213
}

playground/src/App.vue

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,36 @@ setInterval(()=> {
1515
}, 1000)
1616
`
1717
)
18+
19+
const code2 = `
20+
fn main() {
21+
// Print text to the console
22+
println!("Hello World!");
23+
}
24+
`
1825
</script>
1926

2027
<template>
2128
<Box
22-
:padding="2"
29+
:padding="1"
2330
:width="50"
2431
justifyContent="center"
2532
alignItems="center"
2633
flexDirection="column"
27-
borderColor="blue"
34+
borderColor="green"
2835
borderStyle="round"
2936
>
3037
<SyntaxHighlight :code="code" lang="js" />
3138
</Box>
39+
<Box
40+
:padding="1"
41+
:width="50"
42+
justifyContent="center"
43+
alignItems="center"
44+
flexDirection="column"
45+
borderColor="blue"
46+
borderStyle="round"
47+
>
48+
<SyntaxHighlight :code="code2" lang="rust" theme="nord" />
49+
</Box>
3250
</template>

0 commit comments

Comments
 (0)