file

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCommandName added in v0.1.0

func IsCommandName(s string) bool

IsCommandName checks if string is valid command name.

Command name regular expression:

^[A-Za-z][-0-9A-Za-z]*$

Types

type Content

type Content interface {
	// WriterTo allows to write EMA form of content.
	io.WriterTo

	// ContentType always returns "data" or "text".
	// Value "data" represents type Data, value "text" represents type Text.
	ContentType() string
	// contains filtered or unexported methods
}

Content represents part of document.

type Data

type Data map[string]any

Data represents part of document. It can be stored as JSON object.

func (Data) Command added in v0.1.0

func (d Data) Command() (name string, args any, ok bool)

Command returns command name, args and true if Data is possible to represent as command.

func (Data) ContentType

func (Data) ContentType() string

ContentType always returns "data".

func (Data) WriteTo added in v0.1.0

func (d Data) WriteTo(w io.Writer) (n int64, err error)

WriteTo write EMA form of Data to passed io.Writer.

type Document

type Document struct {
	Content []Content
}

Document consists of data or text parts.

func DocumentFromJSON added in v0.1.0

func DocumentFromJSON(array []any) (*Document, error)

DocumentFromJSON creates new Document based on JSON array.

func ParseDocument

func ParseDocument(file string, source io.Reader) (*Document, error)

ParseDocument read document from passed source.

func (*Document) ToEMA added in v0.1.0

func (d *Document) ToEMA() ([]byte, error)

func (*Document) ToJSON added in v0.1.0

func (d *Document) ToJSON() []any

type Text

type Text string

Text represents part of document. It can be stored as plain text.

func (Text) ContentType

func (Text) ContentType() string

ContentType always returns "text".

func (Text) WriteTo added in v0.1.0

func (t Text) WriteTo(w io.Writer) (n int64, err error)

WriteTo write EMA form of Text to passed io.Writer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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