latex

package module
v0.0.0-...-6f8b16a Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: MIT Imports: 7 Imported by: 0

README

go-latex

This package is a simple LaTeX parser which is used by Eolymp to render problem statements written using LaTeX.

Documentation

Index

Constants

View Source
const (
	TextKind = iota
	DocumentKind
	ElementKind
)

Variables

This section is empty.

Functions

func KeyValue

func KeyValue(raw string) (map[string]string, error)

func Measure

func Measure(raw string) (float32, string, error)

Measure parses measurement value, a number and units, for example: 5.1cm, 6em, 0.25\textwidth

func MeasurePixels

func MeasurePixels(raw string) (float32, error)

func Render

func Render(w io.Writer, node *Node) error

func String

func String(node *Node) (out string)

func ToPixels

func ToPixels(value float32, unit string) (float32, error)

Types

type ColumnSpec

type ColumnSpec struct {
	BorderLeft  bool   // column should have left border
	BorderRight bool   // column should have right border
	Align       string // column alignment: c, l or r
}

func ColumnSpecs

func ColumnSpecs(raw string) (spec []ColumnSpec)

ColumnSpecs parses column spec in tabular environment todo: add support for repeated syntax *{x}{...} todo: if not support, at least correctly handle @{} and !{}

type Command

type Command string

type EnvironmentEnd

type EnvironmentEnd struct {
	Name string
}

type EnvironmentStart

type EnvironmentStart struct {
	Name string
}

type Kind

type Kind int

type Node

type Node struct {
	Kind       Kind
	Parameters map[string]string
	Data       string
	Children   []*Node
}

func Parse

func Parse(r Scanner) (*Node, error)

func Strict

func Strict(r Scanner) (*Node, error)

type OptionalEnd

type OptionalEnd struct {
}

type OptionalStart

type OptionalStart struct {
}

type ParameterEnd

type ParameterEnd struct {
}

type ParameterStart

type ParameterStart struct {
}

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(r Scanner) *Parser

func NewStrictParser

func NewStrictParser(r Scanner) *Parser

func (*Parser) Define

func (p *Parser) Define(key, val string)

func (*Parser) Parse

func (p *Parser) Parse() (*Node, error)

func (*Parser) Value

func (p *Parser) Value(key string) string

type Scanner

type Scanner interface {
	io.RuneScanner
	io.Seeker
}

type Symbol

type Symbol string

type Text

type Text string

type Tokenizer

type Tokenizer struct {
	// contains filtered or unexported fields
}

func NewTokenizer

func NewTokenizer(r Scanner) *Tokenizer

func (*Tokenizer) Peek

func (l *Tokenizer) Peek() (rune, error)

func (*Tokenizer) Skip

func (l *Tokenizer) Skip() error

Skip until next non-whitespace symbol

func (*Tokenizer) SkipEOL

func (l *Tokenizer) SkipEOL() error

Skip until next non-whitespace symbol or end of line

func (*Tokenizer) Token

func (l *Tokenizer) Token() (any, error)

func (*Tokenizer) Verbatim

func (l *Tokenizer) Verbatim(stop func(rune, error) bool) (string, error)

Verbatim reads render rune by rune until stop returns true

type Verbatim

type Verbatim struct {
	Kind string
	Attr map[string]string
	Data string
}

Jump to

Keyboard shortcuts

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