Title: | Write and Render 'Typst' Documents |
Version: | 0.0.3 |
Description: | Compile 'Typst' files using the 'typst-cli' (https://typst.app) command line tool. Automatically falls back to rendering via embedded 'Typst' from 'Quarto' (https://quarto.org) if 'Typst' is not installed. Includes utilities to check for 'typst-cli' availability and run 'Typst' commands. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Imports: | cli, fs, processx, rlang |
Depends: | R (≥ 4.1.0) |
Suggests: | jsonlite, rstudioapi, testthat (≥ 3.0.0) |
SystemRequirements: | Typst command line tool (<https://github.com/typst/typst>) or Quarto command line tool (<https://github.com/quarto-dev/quarto-cli>). |
Config/testthat/edition: | 3 |
URL: | http://christophertkenny.com/typr/, https://github.com/christopherkenny/typr |
NeedsCompilation: | no |
Packaged: | 2025-05-30 17:08:03 UTC; chris |
Author: | Christopher T. Kenny
|
Maintainer: | Christopher T. Kenny <christopherkenny@fas.harvard.edu> |
Repository: | CRAN |
Date/Publication: | 2025-05-30 17:20:02 UTC |
Find if Typst is available
Description
Find if Typst is available
Usage
has_any_typst()
has_typst_cli()
has_quarto_typst()
has_quarto_cli()
typr_has_typst()
typr_has_quarto()
typr_has_quarto_typst()
Value
a logical if Typst or Quarto are found
Examples
has_any_typst()
has_typst_cli()
has_quarto_cli()
has_quarto_typst()
Compile a Typst document
Description
Compile a Typst document
Usage
typr_compile(
input = NULL,
output_file = NULL,
output_format = c("pdf", "png", "svg", "html"),
typst_args = NULL
)
Arguments
input |
either a path to a |
output_file |
file to output to |
output_format |
format to use. One of |
typst_args |
Additional arguments to pass to Typst. Can be listed with |
Value
a path to the created file
Examples
typr_compile('hello world')
typr_compile(
input = 'Hello world', output_format = 'png',
typst_args = c('--ppi', '300')
)
List Available Typst Fonts
Description
List Available Typst Fonts
Usage
typr_fonts()
Value
a character vector of font names
Examples
typr_fonts()
Get Help Information for a Typst command
Description
Prints a message to the terminal with help information.
Silently returns the content as character which can be printed with cat()
.
Usage
typr_help(command = NULL)
Arguments
command |
name of a command to get help for, e.g. |
Value
a character vector of information, invisibly
Examples
typr_help('compile')
Create a project from a template
Description
Create a project from a template
Usage
typr_init(template = NULL, version = NULL, dir = NULL, typst_args = NULL)
Arguments
template |
a template to use, can be local or on Typst Universe. If the
string does not specify |
version |
a version string, e.g. |
dir |
The project directory |
typst_args |
Additional arguments to pass to Typst. Can be listed with |
Value
a directory, invisibly
Examples
typr_init('charged-ieee', dir = paste0(tempdir(), '/typr_example'))
Query within a Typst file
Description
Query within a Typst file
Usage
typr_query(
input = NULL,
selector = NULL,
typst_args = NULL,
as_json = !rlang::is_installed("jsonlite")
)
Arguments
input |
a path to a |
selector |
a string to search for, e.g. a |
typst_args |
Additional arguments to pass to Typst. Can be listed with |
as_json |
if |
Value
a length one character with json syntax if !as_json
, otherwise a list
Examples
tf <- fs::file_temp(ext = 'typ')
writeLines(text = '= test <lbl>\n', con = tf)
typr_query(input = tf, selector = '<lbl>')
Get installed Typst version
Description
Get installed Typst version
Usage
typr_version(keep_hash = FALSE)
Arguments
keep_hash |
description |
Value
a version, numeric if !keep_hash
Examples
typr_version()
Watch a Typst document
Description
Watch a Typst document
Usage
typr_watch(
input = NULL,
output_file = NULL,
output_format = c("pdf", "png", "svg", "html"),
typst_args = NULL
)
typr_watch_stop()
Arguments
input |
either a path to a |
output_file |
file to output to |
output_format |
format to use. One of |
typst_args |
Additional arguments to pass to Typst. Can be listed with |
Value
a path to the created file
Examples
tf <- fs::file_temp(ext = 'typ')
writeLines(text = '= test', con = tf)
typr_watch(tf)
writeLines(text = c('= test', 'hello'), con = tf)
Identify Install Typst to Use
Description
Identify Install Typst to Use
Usage
typr_which_typst()
Value
a character vector or NULL
if no Typst is found
Examples
typr_which_typst()