Skip to content

Latest commit

 

History

History

rehype-gnuplot

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

@dat/rehype-gnuplot

Rehype plugin to generate Gnuplot diagrams (as inline SVGs) in place of code fences. This:

```gnuplot
plot [-10:10] sin(x)
```

will be converted to

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

which looks like this:

example of how generated graph looks

Usage

import rehypeGnuplot from "@beoe/rehype-gnuplot";

const html = await unified()
  .use(remarkParse)
  .use(remarkRehype)
  .use(rehypeGnuplot)
  .use(rehypeStringify)
  .process(`markdown`);

It support caching the same way as @beoe/rehype-code-hook does.

Tips

XKCD-style

You can create XKCD-style plots with this snippet. In order for it to work as SVG you need to changed following lines:

- set term postscript eps font 'HumorSans' fontfile 'Humor-Sans.pfa' 22
- set output 'xkcd.eps'
+ set terminal svg enhanced font "HumorSans,Patrick Hand,Chalkboard,Comic Sans MS,18"

You may use any font you like (don't forget to load it in HTML), for example: