codebuffer

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package codebuffer is a package that provides a method to read trough a reader and separate the contents into code and text parts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeBuffer

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

CodeBuffer is a construct to walk over a text separating code from text blocks.

func New

func New(r io.Reader, startTokens, endTokens []rune) *CodeBuffer

New creates a new CodeBuffer with the specified reader.

func (*CodeBuffer) Iterator

func (c *CodeBuffer) Iterator() (Iterator, error)

Iterator returns an iterator that can be used to walk trough the CodeBuffer.

type InReadingState

type InReadingState struct{}

InReadingState is a error that will be returned when the CodeBuffer is busy on another thread.

func (InReadingState) Error

func (InReadingState) Error() string

Error returns the error text for InReadingState.

type Iterator

type Iterator interface {
	Next() bool
	Value() *Part
	Error() error
}

Iterator represents an iterator that can be used to walk trough the CodeBuffer.

type Part

type Part struct {
	Type    PartType
	Content []byte
}

Part represents one part of the text.

type PartType

type PartType uint8

PartType represents a part type.

const (
	// TextPartType represents a text part.
	TextPartType PartType = iota
	// CodePartType represents a code part.
	CodePartType
)

Jump to

Keyboard shortcuts

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