@shikijs/core 3.15.0 → 3.16.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.mjs +41 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1386,6 +1386,8 @@ function tokensToHast(tokens, options, transformerContext, grammarState = getLas
|
|
|
1386
1386
|
lineNode = transformer?.line?.call(context, lineNode, idx + 1) || lineNode;
|
|
1387
1387
|
lineNodes.push(lineNode);
|
|
1388
1388
|
lines.push(lineNode);
|
|
1389
|
+
} else if (structure === "inline") {
|
|
1390
|
+
lineNodes.push(lineNode);
|
|
1389
1391
|
}
|
|
1390
1392
|
});
|
|
1391
1393
|
if (structure === "classic") {
|
|
@@ -1395,6 +1397,45 @@ function tokensToHast(tokens, options, transformerContext, grammarState = getLas
|
|
|
1395
1397
|
for (const transformer of transformers)
|
|
1396
1398
|
preNode = transformer?.pre?.call(context, preNode) || preNode;
|
|
1397
1399
|
root.children.push(preNode);
|
|
1400
|
+
} else if (structure === "inline") {
|
|
1401
|
+
const syntheticLines = [];
|
|
1402
|
+
let currentLine = {
|
|
1403
|
+
type: "element",
|
|
1404
|
+
tagName: "span",
|
|
1405
|
+
properties: { class: "line" },
|
|
1406
|
+
children: []
|
|
1407
|
+
};
|
|
1408
|
+
for (const child of root.children) {
|
|
1409
|
+
if (child.type === "element" && child.tagName === "br") {
|
|
1410
|
+
syntheticLines.push(currentLine);
|
|
1411
|
+
currentLine = {
|
|
1412
|
+
type: "element",
|
|
1413
|
+
tagName: "span",
|
|
1414
|
+
properties: { class: "line" },
|
|
1415
|
+
children: []
|
|
1416
|
+
};
|
|
1417
|
+
} else if (child.type === "element" || child.type === "text") {
|
|
1418
|
+
currentLine.children.push(child);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
syntheticLines.push(currentLine);
|
|
1422
|
+
const syntheticCode = {
|
|
1423
|
+
type: "element",
|
|
1424
|
+
tagName: "code",
|
|
1425
|
+
properties: {},
|
|
1426
|
+
children: syntheticLines
|
|
1427
|
+
};
|
|
1428
|
+
let transformedCode = syntheticCode;
|
|
1429
|
+
for (const transformer of transformers)
|
|
1430
|
+
transformedCode = transformer?.code?.call(context, transformedCode) || transformedCode;
|
|
1431
|
+
root.children = [];
|
|
1432
|
+
for (let i = 0; i < transformedCode.children.length; i++) {
|
|
1433
|
+
if (i > 0)
|
|
1434
|
+
root.children.push({ type: "element", tagName: "br", properties: {}, children: [] });
|
|
1435
|
+
const line = transformedCode.children[i];
|
|
1436
|
+
if (line.type === "element")
|
|
1437
|
+
root.children.push(...line.children);
|
|
1438
|
+
}
|
|
1398
1439
|
}
|
|
1399
1440
|
let result = root;
|
|
1400
1441
|
for (const transformer of transformers)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.16.0",
|
|
5
5
|
"description": "Core of Shiki",
|
|
6
6
|
"author": "Pine Wu <octref@gmail.com>; Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@shikijs/vscode-textmate": "^10.0.2",
|
|
40
40
|
"@types/hast": "^3.0.4",
|
|
41
41
|
"hast-util-to-html": "^9.0.5",
|
|
42
|
-
"@shikijs/types": "3.
|
|
42
|
+
"@shikijs/types": "3.16.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "unbuild",
|