Pikchr
Pikchr diagram renderer for Elixir. Renders PIC-like markup to SVG using a Rust NIF wrapping the pikchr crate.
Installation
Add pikchr to your list of dependencies in mix.exs:
def deps do
[
{:pikchr, "~> 0.5.1"}
]
end
Precompiled NIFs are available for aarch64/x86_64 on macOS and Linux. To build from source, set PIKCHR_BUILD=true and ensure you have a Rust toolchain installed.
Usage
# Render a diagram to SVG
{:ok, svg} = Pikchr.render(~s[box "Hello" "World"])
# Bang variant raises on error
svg = Pikchr.render!(~s[arrow right 200% "Elixir" above])
# Custom CSS class (default: "pikchr")
{:ok, svg} = Pikchr.render(~s[box "Hello"], class: "diagram")
# Dark mode
{:ok, svg} = Pikchr.render(~s[box "Hello"], dark_mode: true)With MDEx
Use as a codefence renderer to render pikchr blocks in Markdown:
MDEx.to_html!(markdown,
codefence_renderers: %{
"pikchr" => fn _lang, _meta, code -> Pikchr.render!(code) end
}
)License
MIT