| Title: | 'Typst' Bindings |
|---|---|
| Description: | Provides bindings to the 'Typst' typesetting system, enabling users to compile 'Typst' documents directly from R. The package interfaces with the 'Typst' 'Rust' library to render documents, making it possible to integrate 'Typst'-based workflows into R scripts, reports, and reproducible research pipelines. |
| Authors: | Joseph Barbier [aut, cre] |
| Maintainer: | Joseph Barbier <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.0 |
| Built: | 2026-05-14 15:22:51 UTC |
| Source: | https://github.com/y-sunflower/tynding |
Check that a character vector is valid Typst markup by compiling it. If no error, it assumes the code is valid.
is_valid_typst(x, error_on_failure = FALSE)is_valid_typst(x, error_on_failure = FALSE)
x |
A character vector |
error_on_failure |
Whether to raise an error if
the code is invalid. Default to |
Indicates whether the output PDF file exists
(for example, if TRUE, then Typst has been compiled
successfully).
typst_code <- c("= Hello World", "This is a Typst document.") is_valid_typst(typst_code) # TRUE typst_code <- c("= Hello World", "#This is a Typst document.") is_valid_typst(typst_code) # FALSE ## Not run: typst_code <- c("= Hello World", "#This is a Typst document.") is_valid_typst(typst_code, error_on_failure = TRUE) # ERROR ## End(Not run)typst_code <- c("= Hello World", "This is a Typst document.") is_valid_typst(typst_code) # TRUE typst_code <- c("= Hello World", "#This is a Typst document.") is_valid_typst(typst_code) # FALSE ## Not run: typst_code <- c("= Hello World", "#This is a Typst document.") is_valid_typst(typst_code, error_on_failure = TRUE) # ERROR ## End(Not run)
.typ file and return the output path.This function uses the Typst Rust library to compile a
.typ file to a supported output format and return the output path.
typst_compile( file, output = NULL, font_path = NULL, pdf_standard = NULL, output_format = NULL, root = NULL, ppi = NULL, ignore_system_fonts = FALSE, ... )typst_compile( file, output = NULL, font_path = NULL, pdf_standard = NULL, output_format = NULL, root = NULL, ppi = NULL, ignore_system_fonts = FALSE, ... )
file |
Path to an existing |
output |
Optional output path. Defaults to the input path with the extension implied by the output format. |
font_path |
Optional path to font files. |
pdf_standard |
Optional PDF standard specification. Options are: : |
output_format |
Optional output format. Supported values are |
root |
Optional Typst project root. Defaults to the parent directory of
|
ppi |
Optional pixels per inch value when exporting to png. If NULL, default to 144.0. |
ignore_system_fonts |
Whether to skip system font discovery. Embedded
Typst fonts and fonts from |
... |
Named inputs passed to the Typst document via |
Output path, invisibly.
Create a Typst file (.typ) from a character vector.
typst_write(x, output = NULL)typst_write(x, output = NULL)
x |
A character vector representing Typst code. |
output |
Optional output file path (must end with ".typ"). If NULL, a temporary file is created. |
The path to the written .typ file, invisibly.
## Not run: code <- c("= Hello World", "This is a Typst document.") typst_write(code, output = "hello.typ") ## End(Not run)## Not run: code <- c("= Hello World", "This is a Typst document.") typst_write(code, output = "hello.typ") ## End(Not run)