Skip to content

Commit b7be27c

Browse files
committed
chore: progress
1 parent 9df0856 commit b7be27c

File tree

5 files changed

+56
-39
lines changed

5 files changed

+56
-39
lines changed

biome.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"useAwait": "off",
9292
"noConsoleLog": "off",
9393
"noExplicitAny": "off",
94+
"noFocusedTests": "off",
9495
"noEmptyInterface": "off",
9596
"noConfusingVoidType": "off"
9697
},

packages/core/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"scripts": {
2121
"build": "tsup --config=tsup.config.ts",
2222
"test": "vitest --run",
23+
"test:ui": "vitest --ui",
2324
"typecheck": "tsc --project tsconfig.json --noEmit",
2425
"clean": "rm -rf dist",
2526
"prebuild": "rm -rf dist",
@@ -38,11 +39,13 @@
3839
"@arethetypeswrong/cli": "^0.15.3",
3940
"@shikijs/transformers": "^1.10.1",
4041
"@types/node": "^20.14.9",
42+
"@vitest/ui": "^1.6.0",
4143
"hast-util-to-html": "^9.0.1",
4244
"mdast-util-to-hast": "^13.2.0",
4345
"prettier": "^3.3.2",
4446
"remark": "^15.0.1",
4547
"shiki": "^1.10.1",
48+
"ts-dedent": "^2.2.0",
4649
"tsup": "^8.1.0",
4750
"tsx": "^4.16.2",
4851
"typescript": "^5.5.3",

packages/core/src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,20 +435,18 @@ export function rehypePrettyCode(
435435
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
436436
visit(codeTree, 'element', (element) => {
437437
if (element.tagName === 'code') {
438-
const showLineNumbers = /srebmuNeniLwohs/.test(reverseString(meta));
438+
const showLineNumbers = /(?:^|\s)showLineNumbers(?:\s|$)/.test(meta);
439439
if (showLineNumbers) {
440440
if (element.properties) {
441441
element.properties['data-line-numbers'] = '';
442442
}
443443

444-
const lineNumbersStartAtMatch = reverseString(meta).match(
445-
/(?:\}(\d+){)?srebmuNeniLwohs/,
444+
const lineNumbersStartAtMatch = meta.match(
445+
/showLineNumbers=(\d+)/
446446
);
447447
const startNumberString = lineNumbersStartAtMatch?.[1];
448448
if (startNumberString) {
449-
const startAt = startNumberString
450-
? Number(reverseString(startNumberString)) - 1
451-
: 0;
449+
const startAt = Number(startNumberString) - 1;
452450
lineNumbersMaxDigits = startAt;
453451
if (element.properties) {
454452
element.properties.style = `counter-set: line ${startAt};`;

packages/core/vitest.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
export default defineConfig({
4+
test: {
5+
globals: true,
6+
},
7+
});

pnpm-lock.yaml

Lines changed: 41 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)