View Source ExTypst (ExTypst v0.1.3)

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.

Link to this section 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.

Link to this section Types

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

Link to this section 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

Examples

iex> {:ok, pdf} = ExTypst.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

Examples

iex> ExTypst.render_to_string("= Hey <%= name %>!", name: "Jude")
"= Hey Jude!"