API reference
A flexible Svelte preprocessor with extensive LaTeX support.
Interfaces
| Interface | Description |
|---|---|
CodeConfiguration | Resolved configuration the CodeHandler is constructed with. |
FrontmatterConfiguration | Controls which parts of the frontmatter block SvelTeX turns into generated code. |
MarkdownConfiguration | Type of the configuration object used to configure the markdown processor. |
MathConfiguration | Type of the configuration object used to configure the math processor. |
Sveltex | The Sveltex class implements Svelte's PreprocessorGroup interface, and is the awaited return type of the sveltex method. Its most important methods are markup, which is run on the Svelte file's entire contents, and script, which is run on the content of the <script> tag in the Svelte file, after the markup method. Together, they define how the Svelte file is preprocessed. |
SveltexConfiguration | Sveltex configuration options. |
TexConfiguration | Configuration options for the TeX backend. |
Functions
| Function | Description |
|---|---|
getDefaultCacheDirectory | The default cache directory for SvelTeX. |
getDefaultCodeConfig | Get the default configuration for a given code backend. |
getDefaultMarkdownConfig | The defaults SvelTeX uses for the markdown slice of its configuration when the user supplies none. The returned object's shape varies with the backend: unified gets remark/rehype/retext plugin slots, marked gets extensions, markdown-it gets a bare options, and so on. Useful for callers that need to inspect or extend the defaults programmatically. |
getDefaultMathConfig | Get the default configuration for a given math backend. |
getDefaultSveltexConfig | Get the default SvelTeX configuration options for the given backends. |
getDefaultTexConfig | The defaults SvelTeX uses for the tex slice of its configuration when the user supplies none — TeX engine and arguments, the dvisvgm / Poppler conversion settings, output and cache directories, SVGO pipeline, and verbosity. Useful for callers that need to inspect or extend the defaults programmatically; most users can rely on the implicit defaults and never call this directly. |
getDefaultVerbEnvConfig | Get the default configuration for a given verbatim environment type. |
getTexPresetDefaults | The defaults for a SvelTeX TeX preset — the bundled, named libraries + options sets a tex-type verbatim environment can opt into via its preset configuration. The only preset shipped today is 'tikz', which loads a sensible TikZ baseline (e.g. the babel, calc, and arrows.meta libraries). |
sveltex | Returns a promise that resolves to a new instance of Sveltex. |
Inspecting defaults programmatically
ts
import {
getDefaultSveltexConfig,
getDefaultCodeConfig,
getDefaultMarkdownConfig,
getDefaultMathConfig,
getDefaultTexConfig,
getDefaultVerbEnvConfig,
getTexPresetDefaults,
getDefaultCacheDirectory,
} from '@nvl/sveltex';
// The full default config for a `unified` / `shiki` / `katex` combo.
const defaults = getDefaultSveltexConfig('unified', 'shiki', 'katex');
// Just the math slice, with the `'hybrid'` CSS approach.
const mathDefaults = getDefaultMathConfig('mathjax', 'hybrid');
// The bundled `tikz` preset's defaults.
const tikz = getTexPresetDefaults('tikz');Each helper returns a freshly-cloned object — mutating it has no effect on subsequent calls.