A preprocessor for Groff/Troff that lets you do arithmetic in Python.
src/gralc.py file and put it in your
Change directory to the root of the project and run
nix-build to install gralc in
If you have nix flakes enabled, you can run
nix shell git+https://git.sr.ht/~yoctocell/nixrc#gralc.
To perform arithmetic, write your expression between `\P`` and ``` (variables aren't supported tho).
three plus three is \P`3+3`.
You can define a base value in roff like this.
.nr base 400
Then use the base value to compute something.
Sugar \P`base*0.4` ml
Very useful for writing recipes.
Compile the document by calling
$ gralc demo.me | groff -me -Tpdf > demo.pdf
Or pipe the output of another command into
$ eqn demo.me | gralc.py | ...
test/demo.mm for a simple demo.
Because gralc is written in Python, it can read a configuration file where you can write your own Python code.
It will read your
$XDG_CONFIG_HOME/gralc/config.py file, or
~/.config/gralc/config.py as a fallback.
In you config file:
from math import * from random import *
Then in your groff file:
Extra cool random spicy number \P`random() * sin(pi)`