encoder

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: EUPL-1.2 Imports: 14 Imported by: 0

Documentation

Overview

Package encoder provides a generic interface to encode the abstract syntax tree into some text form.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEncodings

func GetEncodings() []api.EncodingEnum

GetEncodings returns all registered encodings, ordered by encoding value.

Types

type CreateParameter

type CreateParameter struct {
	Lang string // default language
}

CreateParameter contains values that are needed to create some encoder.

type Encoder

type Encoder interface {
	// WriteZettel encodes a whole zettel and writes it to the Writer.
	WriteZettel(io.Writer, *ast.Zettel) error

	// WriteMeta encodes just the metadata.
	WriteMeta(io.Writer, *meta.Meta) error

	// WriteSz encodes  SZ represented zettel content.
	WriteSz(io.Writer, *sx.Pair) error
}

Encoder is an interface that allows to encode different parts of a zettel.

func Create

func Create(enc api.EncodingEnum, params *CreateParameter) Encoder

Create builds a new encoder with the given options.

type TextEncoder

type TextEncoder struct{}

TextEncoder encodes just the text and ignores any formatting.

func (*TextEncoder) WriteMeta

func (te *TextEncoder) WriteMeta(w io.Writer, m *meta.Meta) error

WriteMeta encodes metadata as text.

func (*TextEncoder) WriteSz added in v1.0.0

func (*TextEncoder) WriteSz(w io.Writer, node *sx.Pair) error

WriteSz writes SZ encoded content to the writer.

func (*TextEncoder) WriteZettel

func (te *TextEncoder) WriteZettel(w io.Writer, zn *ast.Zettel) error

WriteZettel writes metadata and content.

Jump to

Keyboard shortcuts

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