Documentation
¶
Index ¶
Constants ¶
const DefaultBundleURL = "https://relay.fullyjustified.net/default_bundle_v33.tar"
Variables ¶
This section is empty.
Functions ¶
func PrepareBundle ¶
func PrepareBundle(ctx context.Context, destDir, bundleURL string, force bool, opts ...PrepareBundleOption) error
PrepareBundle downloads and extracts a Tectonic TeX Live bundle to destDir.
The bundle is an "itar" format: a tar archive where most entries are individually gzip-compressed. Metadata entries (like SVNREV) may not be compressed. Files are extracted to a flat directory structure.
If destDir already contains SHA256SUM and force is false, the download is skipped. After extraction, call Compiler.GenerateFormat to generate the latex.fmt format file.
Types ¶
type CompileError ¶
type CompileError struct {
ExitCode int32 // 1=TeX error, 2=panic/trap
Logs string // stderr output captured from tectonic
WasmErr error // underlying wazero error (for traps), nil for normal TeX errors
}
CompileError represents a failure during LaTeX compilation.
func (*CompileError) Error ¶
func (e *CompileError) Error() string
func (*CompileError) IsPanic ¶
func (e *CompileError) IsPanic() bool
IsPanic returns true if the error is a WASM engine trap (exit code 2).
func (*CompileError) IsTexError ¶
func (e *CompileError) IsTexError() bool
IsTexError returns true if the error is a TeX compilation error (exit code 1).
func (*CompileError) Unwrap ¶
func (e *CompileError) Unwrap() error
Unwrap returns the underlying wazero error for errors.Is/errors.As chaining.
type CompileOption ¶
type CompileOption func(*compileConfig)
CompileOption configures a single Compile() call.
func WithBundleDir ¶
func WithBundleDir(dir string) CompileOption
WithBundleDir overrides the bundle directory for this compilation.
func WithFontsDir ¶
func WithFontsDir(dir string) CompileOption
WithFontsDir overrides the fonts directory for this compilation.
func WithOutput ¶
func WithOutput(w io.Writer) CompileOption
WithOutput streams the compiled PDF to the given writer instead of returning it as a byte slice. When set, Compile returns (nil, nil) on success.
func WithStderr ¶
func WithStderr(w io.Writer) CompileOption
WithStderr tees tectonic's diagnostic output to the given writer.
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler compiles LaTeX documents to PDF using the Tectonic engine via WASM. It is safe for concurrent use; each Compile call gets its own WASM instance.
func New ¶
func New(ctx context.Context, opts ...CompilerOption) (*Compiler, error)
New creates a new Compiler, initializing the WASM runtime and pre-compiling the Tectonic module. This is a one-time cost.
func (*Compiler) Compile ¶
func (c *Compiler) Compile(ctx context.Context, texSource []byte, opts ...CompileOption) ([]byte, error)
Compile compiles the given LaTeX source to PDF. Each call creates an isolated WASM instance with its own filesystem.
func (*Compiler) GenerateFormat ¶
func (c *Compiler) GenerateFormat(ctx context.Context, bundleDir string, opts ...GenerateFormatOption) error
GenerateFormat generates the LaTeX format file (latex.fmt) in the bundle directory. This must be called once after extracting a bundle before compilations can succeed. If latex.fmt already exists in bundleDir, this is a no-op.
type CompilerOption ¶
type CompilerOption func(*compilerConfig)
CompilerOption configures a Compiler at creation time.
func WithCompilationCache ¶
func WithCompilationCache(dir string) CompilerOption
WithCompilationCache enables caching of the compiled WASM module on disk. Subsequent New() calls with the same directory will skip WASM compilation.
func WithDefaultBundleDir ¶
func WithDefaultBundleDir(dir string) CompilerOption
WithDefaultBundleDir sets the default bundle directory for all compilations.
func WithDefaultFontsDir ¶
func WithDefaultFontsDir(dir string) CompilerOption
WithDefaultFontsDir sets the default fonts directory for all compilations.
type GenerateFormatOption ¶
type GenerateFormatOption func(*generateFormatConfig)
GenerateFormatOption configures a single GenerateFormat() call.
func WithGenerateFormatStderr ¶
func WithGenerateFormatStderr(w io.Writer) GenerateFormatOption
WithGenerateFormatStderr tees tectonic's diagnostic output to the given writer during format generation.
type PrepareBundleOption ¶
type PrepareBundleOption func(*prepareBundleConfig)
PrepareBundleOption configures a PrepareBundle call.
func WithProgress ¶
func WithProgress(w io.Writer) PrepareBundleOption
WithProgress enables progress reporting to the given writer. Download progress (bytes/percentage) and extraction progress (file count) are reported.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
simple
command
Command simple demonstrates the full tecgonic workflow: download a TeX bundle, generate the format file, and compile LaTeX to PDF.
|
Command simple demonstrates the full tecgonic workflow: download a TeX bundle, generate the format file, and compile LaTeX to PDF. |