Skip to content

Commit

Permalink
Merge pull request #13 from ITZSHOAIB/vitest-test
Browse files Browse the repository at this point in the history
feat: vitest added and updated unique classnames logic
  • Loading branch information
ITZSHOAIB authored Nov 15, 2024
2 parents c053c4a + f88b774 commit 0a06e94
Show file tree
Hide file tree
Showing 24 changed files with 1,643 additions and 2,283 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-spoons-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"rehype-code-group": patch
---

feat: enhanced classnames
24 changes: 23 additions & 1 deletion .github/workflows/pre-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,26 @@ jobs:
run: pnpm build

- name: Typecheck
run: pnpm typecheck
run: pnpm typecheck

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Test
run: pnpm test
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,24 @@ Check this functionalty live: [https://4techloverz.com/wordpress-astro-migration
Here's an example of how to use the plugin with Rehype:

```typescript
import fs from "node:fs/promises";
import { rehype } from "rehype";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import rehypeMinifyWhitespace from "rehype-minify-whitespace";
import rehypeStringify from "rehype-stringify";
import rehypeCodeGroup from "rehype-code-group";

const document = await fs.readFile("example/input.html", "utf8");
const options = {};

const file = await rehype()
.use(rehypeCodeGroup, {
customClassNames: {
activeTabClass: "my-active-tab",
},
})
.process(document);

await fs.writeFile("example/output.html", String(file));
.use(remarkParse)
.use(remarkRehype)
.use(rehypeCodeGroup, options)
.use(rehypeMinifyWhitespace)
.use(rehypeStringify)
.process(input);

console.log(String(file))
```

### With Astro
Expand Down Expand Up @@ -126,9 +129,9 @@ You can customize the class names used by the plugin to match your project's sty

### Output Example 📄

Given the following input HTML: [input.html](https://github.com/ITZSHOAIB/rehype-code-group/blob/main/example/input.html)
Given the following input HTML: [input.html](https://github.com/ITZSHOAIB/rehype-code-group/blob/main/test/fixtures/single-md/input.html)

The plugin will produce the following output: [output.html](https://github.com/ITZSHOAIB/rehype-code-group/blob/main/example/output.html)
The plugin will produce the following output: [output.html](https://github.com/ITZSHOAIB/rehype-code-group/blob/main/test/fixtures/single-md/output.html)

## Contributing 🤝
Contributions are welcome! Please read the contributing guidelines first.
Expand Down
15 changes: 0 additions & 15 deletions example/index.js

This file was deleted.

33 changes: 0 additions & 33 deletions example/input.html

This file was deleted.

180 changes: 0 additions & 180 deletions example/output.html

This file was deleted.

18 changes: 0 additions & 18 deletions jest.config.cjs

This file was deleted.

20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
"changeset:version": "changeset version",
"changeset:publish": "pnpm build && changeset publish",
"prepare": "npx simple-git-hooks",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"test": "vitest",
"test:watch": "vitest --watch",
"test:coverage": "vitest run --coverage",
"generate:fixtures": "npx tsx scripts/generateFixtures.ts"
},
"dependencies": {
"hast-util-to-string": "^3.0.1",
Expand All @@ -37,16 +41,20 @@
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.9",
"@types/hast": "^3.0.4",
"@types/jest": "^29.5.14",
"@types/node": "^22.9.0",
"jest": "^29.7.0",
"@vitest/coverage-v8": "2.1.5",
"lint-staged": "^15.2.10",
"rehype-minify-whitespace": "^6.0.2",
"rehype-parse": "^9.0.1",
"rehype-stringify": "^10.0.1",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.1",
"rimraf": "^6.0.1",
"simple-git-hooks": "^2.11.1",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"tslib": "^2.8.1",
"typescript": "^5.6.3"
"typescript": "^5.6.3",
"vitest": "^2.1.5"
},
"peerDependencies": {
"typescript": ">=5.0.4"
Expand Down Expand Up @@ -85,7 +93,7 @@
"*": ["pnpm lint", "git add"]
},
"simple-git-hooks": {
"pre-commit": "pnpm typecheck && pnpm lint:staged"
"pre-commit": "pnpm typecheck && pnpm test:coverage && pnpm lint:staged"
},
"packageManager": "pnpm@9.12.0",
"engines": {
Expand Down
Loading

0 comments on commit 0a06e94

Please sign in to comment.