tex2svg

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package tex2svg provides the support for coverting the specified TeX input into a parsed SVG's HTML node.

To work, we will first generate a TeX file and convert it into a PDF or DVI file using "pdflatex". Then we will convert the PDF file into the SVG file using "pdf2svg".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache added in v1.0.2

type Cache interface {
	Load(
		key []byte, generate func() ([]byte, error),
	) ([]byte, error)
}

Cache is the content cache that the Generate function could refer to before pulling up any subprocess and generate content.

The key and value must be transparent so that this package could arrange its content freely.

type Option

type Option func(*option)

Option passed for controlling the SVG generation.

func WithAttributes

func WithAttributes(attrs map[string]string) Option

WithAttributes specifies the attributes.

func WithCache added in v1.0.2

func WithCache(cache Cache) Option

WithCache sets the cache function for the generator.

func WithControlPrecision

func WithControlPrecision(precision int) Option

WithControlPrecision updates the precision of the control points in path.

func WithFallable

func WithFallable(fallable bool) Option

WithFallable specifies that the "latex.tex" will be used when a specified type is not present.

func WithFontSize

func WithFontSize(pt int) Option

WithFontSize sets font size in TeX's pt unit.

func WithLogger

func WithLogger(logger *log.Logger) Option

WithLogger sets a logger for printing out content.

func WithOptions

func WithOptions(opts ...Option) Option

WithOptions aggregates a few options into a single option.

func WithPrecision

func WithPrecision(precision int) Option

WithPrecision updates the precision of the node points.

func WithTemplate

func WithTemplate(template string) Option

WithTemplate sets the template forcefully.

Setting this will force all kinds of generation to use the specified template instead. This is useful for debugging template generation dedicatedly.

func WithTemplateDir

func WithTemplateDir(dir string) Option

WithTemplateDir sets the template search directory.

The template corresponding to specified node type will be looked up and used. Each template should accept in the template arguments FontSize and Code.

By default, the executable's directory will be searched for templates. And DeX comes with some preset templates.

type Result added in v1.0.1

type Result struct {
	Data     []byte
	Baseline float64
}

Result is the result of tex2svg generation.

func Generate

func Generate(
	ctx context.Context, typ, code string, opts ...Option,
) (*Result, error)

Generate SVG using the provided LaTeX data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL