formatter

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaspDirectives added in v1.2.0

func ClaspDirectives(text string, entities []*client.TextEntity) []*client.TextEntity

ClaspDirectives to the following span as required by XEP-0393

func EntityToMarkdown

func EntityToMarkdown(entity *client.TextEntity) (*Insertion, *Insertion)

EntityToMarkdown generates the wrapping Markdown tags

func EntityToXEP0393

func EntityToXEP0393(entity *client.TextEntity) (*Insertion, *Insertion)

EntityToXEP0393 generates the wrapping XEP-0393 tags

func Format

func Format(
	sourceText string,
	entities []*client.TextEntity,
	entityToMarkup func(*client.TextEntity) (*Insertion, *Insertion),
) string

Format traverses an already sorted list of entities and wraps the text in a markup

func MergeAdjacentEntities added in v1.2.0

func MergeAdjacentEntities(entities []*client.TextEntity) []*client.TextEntity

MergeAdjacentEntities merges entities of a same kind

func SortEntities

func SortEntities(entities []*client.TextEntity) []*client.TextEntity

SortEntities arranges the entities in traversal-ready order

Types

type Insertion

type Insertion struct {
	Offset int32
	Runes  []rune
}

Insertion is a piece of text in given position

type InsertionStack

type InsertionStack []*Insertion

InsertionStack contains the sequence of insertions from the start or from the end

func (InsertionStack) NewIterator

func (s InsertionStack) NewIterator() func() *Insertion

NewIterator is a second order function that sequentially scans and returns stack elements; starts returning nil when elements are ended

Jump to

Keyboard shortcuts

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