Skip to content

Latest commit

 

History

History

rehype-penrose

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@beoe/rehype-penrose

Rehype plugin to generate penrose diagrams in place of code fences. This

```penrose style="euclidean.style" domain="euclidean.domain" width=800 height=800
Plane P
Point p, q, r, s
In(p, P)
In(q, P)
In(r, P)
In(s, P)
Let a := Segment(p, q)
Let b := Segment(p, r)
Point m := Midpoint(a)
In(m, P)
Angle theta := InteriorAngle(q, p, r)
Let t := Triangle(p, r, s)
Ray w := Bisector(theta)
Segment h := PerpendicularBisector(a, m)
AutoLabel p, q, r, s, m
Label P $E^2$
```

will be converted to

<figure class="beoe penrose">
  <svg>...</svg>
</figure>

which looks like this:

example of how generated graph looks

Note:

You need to add domain and style files to shared folder, for example:

Usage

import rehypePenrose from "@beoe/rehype-penrose";

const html = await unified()
  .use(remarkParse)
  .use(remarkRehype)
  .use(rehypePenrose, { shared: "shared" })
  .use(rehypeStringify)
  .process(`markdown`);

Online documentation provides more details.

TODO

  • fix SVGO issue