Typst (Typst v0.1.4)

View Source

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

formattable()

@type formattable() :: {atom(), any()}

pdf_opt()

@type pdf_opt() :: {:extra_fonts, [String.t()]}

Functions

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

@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

render_to_pdf!(typst_markup, bindings \\ [])

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

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

render_to_string(typst_markup, bindings \\ [])

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