View Source Typst (Typst v0.1.2)
This module provides the core functions for interacting with
the typst
markup language compiler.
Note that when using the formatting directives, they are exactly the same as
EEx
, so all of its constructs are supported.
See Typst's documentation for a quickstart.
Summary
Functions
Converts a given piece of typst markup to a PDF binary.
Same as render_to_pdf/2
, but raises if the rendering fails.
Formats the given markup template with the given bindings, mostly useful for inspecting and debugging.
Types
@type pdf_opt() :: {:extra_fonts, [String.t()]}
Functions
@spec render_to_pdf(String.t(), [formattable()], [pdf_opt()]) :: {:ok, binary()} | {:error, String.t()}
Converts a given piece of typst markup to a PDF binary.
Examples
iex> {:ok, pdf} = Typst.render_to_pdf("= test\n<%= name %>", name: "John")
iex> is_binary(pdf)
true
@spec render_to_pdf!(String.t(), [formattable()]) :: binary()
Same as render_to_pdf/2
, but raises if the rendering fails.
@spec render_to_string(String.t(), [formattable()]) :: String.t()
Formats the given markup template with the given bindings, mostly useful for inspecting and debugging.
Examples
iex> Typst.render_to_string("= Hey <%= name %>!", name: "Jude")
"= Hey Jude!"