3.0.1 • Published 8 months ago

@lekoarts/rehype-meta-as-attributes v3.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@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));
}
3.0.1

8 months ago

3.0.0

1 year ago

2.0.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago