@shikijs/rehype 1.12.1 → 1.14.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/core.d.mts +9 -0
- package/dist/core.d.ts +9 -0
- package/dist/core.mjs +4 -1
- package/package.json +3 -3
package/dist/core.d.mts
CHANGED
|
@@ -22,6 +22,15 @@ interface RehypeShikiExtraOptions {
|
|
|
22
22
|
* The fallback language to use when specified language is not loaded
|
|
23
23
|
*/
|
|
24
24
|
fallbackLanguage?: string;
|
|
25
|
+
/**
|
|
26
|
+
* `mdast-util-to-hast` adds a newline to the end of code blocks
|
|
27
|
+
*
|
|
28
|
+
* This option strips that newline from the code block
|
|
29
|
+
*
|
|
30
|
+
* @default true
|
|
31
|
+
* @see https://github.com/syntax-tree/mdast-util-to-hast/blob/f511a93817b131fb73419bf7d24d73a5b8b0f0c2/lib/handlers/code.js#L22
|
|
32
|
+
*/
|
|
33
|
+
stripEndNewline?: boolean;
|
|
25
34
|
/**
|
|
26
35
|
* Custom meta string parser
|
|
27
36
|
* Return an object to merge with `meta`
|
package/dist/core.d.ts
CHANGED
|
@@ -22,6 +22,15 @@ interface RehypeShikiExtraOptions {
|
|
|
22
22
|
* The fallback language to use when specified language is not loaded
|
|
23
23
|
*/
|
|
24
24
|
fallbackLanguage?: string;
|
|
25
|
+
/**
|
|
26
|
+
* `mdast-util-to-hast` adds a newline to the end of code blocks
|
|
27
|
+
*
|
|
28
|
+
* This option strips that newline from the code block
|
|
29
|
+
*
|
|
30
|
+
* @default true
|
|
31
|
+
* @see https://github.com/syntax-tree/mdast-util-to-hast/blob/f511a93817b131fb73419bf7d24d73a5b8b0f0c2/lib/handlers/code.js#L22
|
|
32
|
+
*/
|
|
33
|
+
stripEndNewline?: boolean;
|
|
25
34
|
/**
|
|
26
35
|
* Custom meta string parser
|
|
27
36
|
* Return an object to merge with `meta`
|
package/dist/core.mjs
CHANGED
|
@@ -11,6 +11,7 @@ function rehypeShikiFromHighlighter(highlighter, options) {
|
|
|
11
11
|
defaultLanguage,
|
|
12
12
|
fallbackLanguage,
|
|
13
13
|
onError,
|
|
14
|
+
stripEndNewline = true,
|
|
14
15
|
...rest
|
|
15
16
|
} = options;
|
|
16
17
|
return function(tree) {
|
|
@@ -30,7 +31,9 @@ function rehypeShikiFromHighlighter(highlighter, options) {
|
|
|
30
31
|
return;
|
|
31
32
|
if (fallbackLanguage && !langs.includes(lang))
|
|
32
33
|
lang = fallbackLanguage;
|
|
33
|
-
|
|
34
|
+
let code = toString(head);
|
|
35
|
+
if (stripEndNewline && code.endsWith("\n"))
|
|
36
|
+
code = code.slice(0, -1);
|
|
34
37
|
const cachedValue = cache?.get(code);
|
|
35
38
|
if (cachedValue) {
|
|
36
39
|
parent.children.splice(index, 1, ...cachedValue);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/rehype",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.14.0",
|
|
5
5
|
"description": "rehype integration for shiki",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"hast-util-to-string": "^3.0.0",
|
|
50
50
|
"unified": "^11.0.5",
|
|
51
51
|
"unist-util-visit": "^5.0.0",
|
|
52
|
-
"@shikijs/transformers": "1.
|
|
53
|
-
"shiki": "1.
|
|
52
|
+
"@shikijs/transformers": "1.14.0",
|
|
53
|
+
"shiki": "1.14.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"rehype-raw": "^7.0.0",
|