https://github.com/jasonlamv-t/rehype-code-title
Rehype plugin to add code block title in pre element as div element.
https://github.com/jasonlamv-t/rehype-code-title
code-titles rehype rehype-plugin
Last synced: 3 months ago
JSON representation
Rehype plugin to add code block title in pre element as div element.
- Host: GitHub
- URL: https://github.com/jasonlamv-t/rehype-code-title
- Owner: JasonLamv-t
- Created: 2023-02-14T20:36:41.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-14T22:16:12.000Z (over 3 years ago)
- Last Synced: 2025-10-29T21:27:59.729Z (8 months ago)
- Topics: code-titles, rehype, rehype-plugin
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rehype-Code-Title
I'm writing a blog project with mdx-bundler and I want to annotate code title such as filename in the top of the code block. This plugin does just that!
### Usage
```js
import rehype from 'rehype';
import rehypeCodeTitle from '@jasonlamv-t/rehype-code-title';
import rehypePrism from 'rehype-prism-plus';
rehype()
.use(rehypeCodeTitle) // better choice to be before rehypePrism.
.use(rehypePrism)
.process(/* some html */);
```
For some markdown files like this:
````md
```js:index.js
const codeType = 'js';
```
````
It will be processed as:
```html
index.js
const codeType = 'js';
```