@shikijs/transformers 2.5.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -8,7 +8,7 @@ interface MatchAlgorithmOptions {
8
8
  * Match algorithm to use
9
9
  *
10
10
  * @see https://shiki.style/packages/transformers#matching-algorithm
11
- * @default 'v1'
11
+ * @default 'v3'
12
12
  */
13
13
  matchAlgorithm?: MatchAlgorithm;
14
14
  }
package/dist/index.mjs CHANGED
@@ -1,5 +1,3 @@
1
- import { warnDeprecated } from '@shikijs/core';
2
-
3
1
  const matchers = [
4
2
  [/^(<!--)(.+)(-->)$/, false],
5
3
  [/^(\/\*)(.+)(\*\/)$/, false],
@@ -123,8 +121,7 @@ function v1ClearEndCommentPrefix(text) {
123
121
 
124
122
  function createCommentNotationTransformer(name, regex, onMatch, matchAlgorithm) {
125
123
  if (matchAlgorithm == null) {
126
- matchAlgorithm = "v1";
127
- warnDeprecated('The default `matchAlgorithm: "v1"` is deprecated and will be removed in the future. Please explicitly set `matchAlgorithm: "v3"` in the transformer options.', 3);
124
+ matchAlgorithm = "v3";
128
125
  }
129
126
  return {
130
127
  name,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shikijs/transformers",
3
3
  "type": "module",
4
- "version": "2.5.0",
4
+ "version": "3.1.0",
5
5
  "description": "Collective of common transformers transformers for Shiki",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -18,10 +18,7 @@
18
18
  ],
19
19
  "sideEffects": false,
20
20
  "exports": {
21
- ".": {
22
- "types": "./dist/index.d.mts",
23
- "default": "./dist/index.mjs"
24
- }
21
+ ".": "./dist/index.mjs"
25
22
  },
26
23
  "main": "./dist/index.mjs",
27
24
  "module": "./dist/index.mjs",
@@ -30,8 +27,8 @@
30
27
  "dist"
31
28
  ],
32
29
  "dependencies": {
33
- "@shikijs/core": "2.5.0",
34
- "@shikijs/types": "2.5.0"
30
+ "@shikijs/core": "3.1.0",
31
+ "@shikijs/types": "3.1.0"
35
32
  },
36
33
  "scripts": {
37
34
  "build": "unbuild",
package/dist/index.d.ts DELETED
@@ -1,206 +0,0 @@
1
- import { ShikiTransformerContext, ShikiTransformer } from '@shikijs/core';
2
- import { Element } from 'hast';
3
- import { ShikiTransformer as ShikiTransformer$1 } from '@shikijs/types';
4
-
5
- type MatchAlgorithm = 'v1' | 'v3';
6
- interface MatchAlgorithmOptions {
7
- /**
8
- * Match algorithm to use
9
- *
10
- * @see https://shiki.style/packages/transformers#matching-algorithm
11
- * @default 'v1'
12
- */
13
- matchAlgorithm?: MatchAlgorithm;
14
- }
15
- declare function createCommentNotationTransformer(name: string, regex: RegExp, onMatch: (this: ShikiTransformerContext, match: string[], line: Element, commentNode: Element, lines: Element[], index: number) => boolean, matchAlgorithm: MatchAlgorithm | undefined): ShikiTransformer;
16
-
17
- interface TransformerCompactLineOption {
18
- /**
19
- * 1-based line number.
20
- */
21
- line: number;
22
- classes?: string[];
23
- }
24
- /**
25
- * Transformer for `shiki`'s legacy `lineOptions`
26
- */
27
- declare function transformerCompactLineOptions(lineOptions?: TransformerCompactLineOption[]): ShikiTransformer$1;
28
-
29
- declare function parseMetaHighlightString(meta: string): number[] | null;
30
- interface TransformerMetaHighlightOptions {
31
- /**
32
- * Class for highlighted lines
33
- *
34
- * @default 'highlighted'
35
- */
36
- className?: string;
37
- }
38
- /**
39
- * Allow using `{1,3-5}` in the code snippet meta to mark highlighted lines.
40
- */
41
- declare function transformerMetaHighlight(options?: TransformerMetaHighlightOptions): ShikiTransformer$1;
42
-
43
- declare function parseMetaHighlightWords(meta: string): string[];
44
- interface TransformerMetaWordHighlightOptions {
45
- /**
46
- * Class for highlighted words
47
- *
48
- * @default 'highlighted-word'
49
- */
50
- className?: string;
51
- }
52
- /**
53
- * Allow using `/word/` in the code snippet meta to mark highlighted words.
54
- */
55
- declare function transformerMetaWordHighlight(options?: TransformerMetaWordHighlightOptions): ShikiTransformer$1;
56
- declare function findAllSubstringIndexes(str: string, substr: string): number[];
57
-
58
- interface TransformerNotationDiffOptions extends MatchAlgorithmOptions {
59
- /**
60
- * Class for added lines
61
- */
62
- classLineAdd?: string;
63
- /**
64
- * Class for removed lines
65
- */
66
- classLineRemove?: string;
67
- /**
68
- * Class added to the <pre> element when the current code has diff
69
- */
70
- classActivePre?: string;
71
- }
72
- /**
73
- * Use `[!code ++]` and `[!code --]` to mark added and removed lines.
74
- */
75
- declare function transformerNotationDiff(options?: TransformerNotationDiffOptions): ShikiTransformer$1;
76
-
77
- interface TransformerNotationErrorLevelOptions extends MatchAlgorithmOptions {
78
- classMap?: Record<string, string | string[]>;
79
- /**
80
- * Class added to the <pre> element when the current code has diff
81
- */
82
- classActivePre?: string;
83
- }
84
- /**
85
- * Allow using `[!code error]` `[!code warning]` notation in code to mark highlighted lines.
86
- */
87
- declare function transformerNotationErrorLevel(options?: TransformerNotationErrorLevelOptions): ShikiTransformer$1;
88
-
89
- interface TransformerNotationFocusOptions extends MatchAlgorithmOptions {
90
- /**
91
- * Class for focused lines
92
- */
93
- classActiveLine?: string;
94
- /**
95
- * Class added to the root element when the code has focused lines
96
- */
97
- classActivePre?: string;
98
- }
99
- /**
100
- * Allow using `[!code focus]` notation in code to mark focused lines.
101
- */
102
- declare function transformerNotationFocus(options?: TransformerNotationFocusOptions): ShikiTransformer$1;
103
-
104
- interface TransformerNotationHighlightOptions extends MatchAlgorithmOptions {
105
- /**
106
- * Class for highlighted lines
107
- */
108
- classActiveLine?: string;
109
- /**
110
- * Class added to the root element when the code has highlighted lines
111
- */
112
- classActivePre?: string;
113
- }
114
- /**
115
- * Allow using `[!code highlight]` notation in code to mark highlighted lines.
116
- */
117
- declare function transformerNotationHighlight(options?: TransformerNotationHighlightOptions): ShikiTransformer$1;
118
-
119
- interface TransformerNotationWordHighlightOptions extends MatchAlgorithmOptions {
120
- /**
121
- * Class for highlighted words
122
- */
123
- classActiveWord?: string;
124
- /**
125
- * Class added to the root element when the code has highlighted words
126
- */
127
- classActivePre?: string;
128
- }
129
- declare function transformerNotationWordHighlight(options?: TransformerNotationWordHighlightOptions): ShikiTransformer$1;
130
-
131
- interface TransformerNotationMapOptions extends MatchAlgorithmOptions {
132
- classMap?: Record<string, string | string[]>;
133
- /**
134
- * Class added to the <pre> element when the current code has diff
135
- */
136
- classActivePre?: string;
137
- }
138
- declare function transformerNotationMap(options?: TransformerNotationMapOptions, name?: string): ShikiTransformer$1;
139
-
140
- /**
141
- * Remove line breaks between lines.
142
- * Useful when you override `display: block` to `.line` in CSS.
143
- */
144
- declare function transformerRemoveLineBreak(): ShikiTransformer$1;
145
-
146
- /**
147
- * Remove notation escapes.
148
- * Useful when you want to write `// [!code` in markdown.
149
- * If you process `// [\!code ...]` expression, you can get `// [!code ...]` in the output.
150
- */
151
- declare function transformerRemoveNotationEscape(): ShikiTransformer$1;
152
-
153
- interface TransformerRenderWhitespaceOptions {
154
- /**
155
- * Class for tab
156
- *
157
- * @default 'tab'
158
- */
159
- classTab?: string;
160
- /**
161
- * Class for space
162
- *
163
- * @default 'space'
164
- */
165
- classSpace?: string;
166
- /**
167
- * Position of rendered whitespace
168
- * @default all position
169
- */
170
- position?: 'all' | 'boundary' | 'trailing';
171
- }
172
- /**
173
- * Render whitespaces as separate tokens.
174
- * Apply with CSS, it can be used to render tabs and spaces visually.
175
- */
176
- declare function transformerRenderWhitespace(options?: TransformerRenderWhitespaceOptions): ShikiTransformer$1;
177
-
178
- interface TransformerStyleToClassOptions {
179
- /**
180
- * Prefix for class names.
181
- * @default '__shiki_'
182
- */
183
- classPrefix?: string;
184
- /**
185
- * Suffix for class names.
186
- * @default ''
187
- */
188
- classSuffix?: string;
189
- /**
190
- * Callback to replace class names.
191
- * @default (className) => className
192
- */
193
- classReplacer?: (className: string) => string;
194
- }
195
- interface ShikiTransformerStyleToClass extends ShikiTransformer$1 {
196
- getClassRegistry: () => Map<string, Record<string, string> | string>;
197
- getCSS: () => string;
198
- clearRegistry: () => void;
199
- }
200
- /**
201
- * Remove line breaks between lines.
202
- * Useful when you override `display: block` to `.line` in CSS.
203
- */
204
- declare function transformerStyleToClass(options?: TransformerStyleToClassOptions): ShikiTransformerStyleToClass;
205
-
206
- export { type ShikiTransformerStyleToClass, type TransformerCompactLineOption, type TransformerMetaHighlightOptions, type TransformerMetaWordHighlightOptions, type TransformerNotationDiffOptions, type TransformerNotationErrorLevelOptions, type TransformerNotationFocusOptions, type TransformerNotationHighlightOptions, type TransformerNotationMapOptions, type TransformerNotationWordHighlightOptions, type TransformerRenderWhitespaceOptions, type TransformerStyleToClassOptions, createCommentNotationTransformer, findAllSubstringIndexes, parseMetaHighlightString, parseMetaHighlightWords, transformerCompactLineOptions, transformerMetaHighlight, transformerMetaWordHighlight, transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight, transformerNotationMap, transformerNotationWordHighlight, transformerRemoveLineBreak, transformerRemoveNotationEscape, transformerRenderWhitespace, transformerStyleToClass };