
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
rehype-code-group
Advanced tools
A Rehype plugin for grouping code blocks with tabs, perfect for documentation and tutorials. Works with all Code Syntax Highlighters.
A Rehype plugin for grouping code blocks with tabs, allowing you to switch between different code snippets easily. Perfect for documentation and tutorials where you want to show the same code in different languages or configurations.
Inspired by Vitepress Code Groups
[!TIP] This plugin is versatile and can be used to create tabs for any type of content, not just code blocks. You can easily organize and display different types of content within tabs.
[!NOTE] This package is ESM only.
Install the plugin using any package manager:
npm install rehype-code-group
# or
pnpm add rehype-code-group
# or
yarn add rehype-code-group
In Deno with esm.sh:
import rehypeCodeGroup from 'https://esm.sh/rehype-code-group'
In browsers with esm.sh:
<script type="module">
import rehypeCodeGroup from 'https://esm.sh/rehype-code-group?bundle'
</script>
To incorporate code group tabs in your markdown file, use the following syntax:
::: code-group labels=[npm, pnpm, yarn]
```bash
npm install rehype-code-group
```
```bash
pnpm add rehype-code-group
```
```bash
yarn add rehype-code-group
```
:::
The code group will be rendered like this (The below UI used Expressive Code as a syntax highlighter):
Check this functionalty live: https://4techloverz.com/wordpress-astro-migration-easy-guide/#initialize-astro-project
Here's an example of how to use the plugin with Rehype:
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 options = {};
const file = await rehype()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeCodeGroup, options)
.use(rehypeMinifyWhitespace)
.use(rehypeStringify)
.process(input);
console.log(String(file))
You can also use this plugin with Astro (astro.config.ts
):
import { defineConfig } from 'astro/config';
import rehypeCodeGroup from 'rehype-code-group';
// https://docs.astro.build/en/reference/configuration-reference/
export default defineConfig({
// ...
markdown: {
// ...
rehypePlugins: [
// ...
rehypeCodeGroup,
],
},
// ...
})
You can customize the class names used by the plugin to match your project's styles. The available options are:
.use(rehypeCodeGroup, {
customClassNames: {
codeGroupClass: "my-code-group",
tabContainerClass: "my-tab-container",
tabClass: "my-tab",
activeTabClass: "my-active-tab",
blockContainerClass: "my-block-container",
activeBlockClass: "my-active-block",
},
})
Given the following input Markdown: input.md
The plugin will produce the following output: output.html
Contributions are welcome! Please read the contributing guidelines first.
This project is licensed under the MIT License - see the LICENSE file for details.
Happy coding! 🎉
0.2.4
73dbf05
Thanks @dependabot! - chore(deps-dev): bump typescript from 5.7.3 to 5.8.2FAQs
A Rehype plugin for grouping code blocks with tabs, perfect for documentation and tutorials. Works with all Code Syntax Highlighters.
The npm package rehype-code-group receives a total of 293 weekly downloads. As such, rehype-code-group popularity was classified as not popular.
We found that rehype-code-group demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.