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 formattable() :: {atom(), any()}
@type pdf_opt() :: {:extra_fonts, [String.t()]}

Functions

Link to this function

render_to_pdf(typst_markup, bindings \\ [], opts \\ [])

View Source
@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
Link to this function

render_to_pdf!(typst_markup, bindings \\ [])

View Source
@spec render_to_pdf!(String.t(), [formattable()]) :: binary()

Same as render_to_pdf/2, but raises if the rendering fails.

Link to this function

render_to_string(typst_markup, bindings \\ [])

View Source
@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!"