annotate

package
Version: v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2015 License: BSD-3-Clause, MIT Imports: 3 Imported by: 0

README

annotate

A Go package for applying multiple sets of annotations to a region of text.

Documentation on Sourcegraph

Build Status status authors Total views

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStartOutOfBounds       = errors.New("annotation start out of bounds")
	ErrEndOutOfBounds         = errors.New("annotation end out of bounds")
	ErrStartAndEndOutOfBounds = errors.New("annotations start and end out of bounds")
)

Functions

func Annotate

func Annotate(src []byte, anns Annotations, writeContent func(io.Writer, []byte)) ([]byte, error)

Annotates src with annotations in anns.

Annotating an empty byte array always returns an empty byte array.

Assumes anns is sorted (using sort.Sort(anns)).

func IsOutOfBounds

func IsOutOfBounds(err error) bool

Types

type Annotation

type Annotation struct {
	// Start and End byte offsets (not rune offsets).
	Start, End int

	Left, Right []byte
	WantInner   int
}

type Annotations

type Annotations []*Annotation

func (Annotations) Len

func (a Annotations) Len() int

func (Annotations) Less

func (a Annotations) Less(i, j int) bool

func (Annotations) Swap

func (a Annotations) Swap(i, j int)

Source Files

Jump to

Keyboard shortcuts

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