rpic_svg: Render pic source to an SVG string

View source: R/rpic.R

rpic_svgR Documentation

Render pic source to an SVG string

Description

Render pic source to an SVG string

Usage

rpic_svg(src, circuits = FALSE, texlabels = FALSE)

Arguments

src

pic source code.

circuits

load the native circuit-element library (or write ⁠copy "circuits"⁠ in the source itself).

texlabels

typeset fully ⁠$...$⁠-delimited labels as TeX math (initializer only — the source can still set texlabels = 0).

Value

an SVG string.

Errors

Compile errors are raised as a classed rpic_error condition whose info field holds the structured diagnostic (message, line, col, end_col, file, kind, found, expected, hint; absent values are NA, and file names a copy include — NA means your own input). Positions are relative to your own source, even with circuits = TRUE:

tryCatch(
  rpic_svg("bxo", circuits = TRUE),
  rpic_error = function(e) e$info$hint  # "did you mean `box`?"
)

Examples

rpic_svg('box "hi"; arrow; circle "x"')
tryCatch(rpic_svg("bxo"), rpic_error = function(e) e$info$line)

rpic documentation built on July 15, 2026, 9:06 a.m.