@lekoarts/rehype-meta-as-attributes
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

@lekoarts/rehype-meta-as-attributes

Functionality

Adds code block meta to the node.properties.

```js title=hello hightlight
const hello = "world";
```

Is turned into title: "hello" and highlight: true.

You can access those in e.g. React then in the props of <pre> tags.

Install

npm install @lekoarts/rehype-meta-as-attributes

Use

Say we have the following file example.md:

# rehype-meta-as-attributes

```js title=hello hightlight
const hello = "world";
```

Then use it in your pipeline as following:

import { read } from "to-vfile";
import { unified } from "unified";
import remarkRehype from "remark-rehype";
import rehypeMetaAsAttributes from "@lekoarts/rehype-meta-as-attributes";

main();

async function main() {
  const file = await unified()
    .use(remarkRehype)
    .use(rehypeMetaAsAttributes)
    .process(await read("example.md"));

  console.log(String(file));
}

Readme

Keywords

none

Package Sidebar

Install

npm i @lekoarts/rehype-meta-as-attributes

Weekly Downloads

57

Version

3.0.1

License

MIT

Unpacked Size

2.31 kB

Total Files

4

Last publish

Collaborators

  • lekoarts