File tree 1 file changed +81
-2
lines changed
1 file changed +81
-2
lines changed Original file line number Diff line number Diff line change 1
- # shiki-transformers
2
- Shiki transformers used by Typlog
1
+ # @typlog/shiki-transformers
2
+
3
+ Shiki transformers by Typlog.
4
+
5
+ ## Install
6
+
7
+ Install via npm:
8
+
9
+ ```
10
+ npm i @typlog/shiki-transformers
11
+ ```
12
+
13
+ Import from CDN:
14
+
15
+ ``` html
16
+ <script type =" module" >
17
+ import { transformerLineHighlight } from ' https://esm.sh/@typlog/shiki-transformers'
18
+ </script >
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ``` ts
24
+ import { codeToHtml } from ' shiki'
25
+ import { transformerLineHighlight } from ' @typlog/shiki-transformers'
26
+
27
+ const code = ` console.log('a')
28
+ console.log('b')
29
+ console.log('c')
30
+ console.log('e')
31
+ console.log('f')
32
+ console.log('g')
33
+ console.log('h')
34
+ `
35
+ const html = await codeToHtml (code , {
36
+ lang: ' ts' ,
37
+ theme: ' nord' ,
38
+ transformers: [
39
+ transformerLineHighlight ({
40
+ highlight: ' 1,3-5' ,
41
+ showLines: true ,
42
+ }),
43
+ ],
44
+ })
45
+ ```
46
+
47
+ ## Options
48
+
49
+ ``` ts
50
+ export interface TransformerHighlightOptions {
51
+ /**
52
+ * Lines to be highlighted
53
+ */
54
+ highlight? : string ;
55
+
56
+ /**
57
+ * Class for highlighted lines
58
+ *
59
+ * @default ' highlighted'
60
+ */
61
+ className? : string ;
62
+
63
+ /**
64
+ * Line numbers starts from
65
+ *
66
+ * @default 1
67
+ */
68
+ lineStart? : number ;
69
+
70
+ /**
71
+ * Display line numbers
72
+ *
73
+ * @default false
74
+ */
75
+ showLines? : boolean ;
76
+ }
77
+ ```
78
+
79
+ ## License
80
+
81
+ MIT License
You can’t perform that action at this time.
0 commit comments