Skip to content

@beoe/rehype-penrose

Rehype plugin to generate Penrose diagrams in place of code fences. Example:

Use two fingers to pan and zoom

Installation

Terminal window
npm i @beoe/rehype-penrose

Usage

import rehypeD2 from "@beoe/rehype-penrose";
const html = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeD2, {
shared: "shared",
/* options */
})
.use(rehypeStringify)
.process(`markdown`);

Check out other options.

Configuration

You probaly want to use file strategy.

PenroseOptions

export type PenroseOptions = {
/**
* path to shared folder for `.domain` and `.style` files
*/
shared: string;
/**
* Width of diagram
*/
width?: number;
/**
* Height of diagram
*/
height?: number;
/**
* Name (or path) for `.style` file
*/
style?: string;
/**
* Name (or path) for `.domain` file
*/
domain?: string;
variation?: string;
namespace?: string;
};

You can set it globally:

use(rehypePenrose, {
width: 400,
height: 400,
});

Or locally:

```penrose width=400 height=400
...
```