term

package
v0.4.0-beta.7 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Continue ExecutionResult = "Continue"
	Skip                     = "Skip"
	Stop                     = "Stop"
)

Variables

View Source
var BlockquoteAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("cite"),
)

BlockquoteAttributeFilter defines attribute names which blockquote elements can have

View Source
var CodeAttributeFilter = GlobalAttributeFilter

CodeAttributeFilter defines attribute names which code elements can have.

View Source
var ColorsEnabled bool
View Source
var ConsoleRenderer = &consoleRendererExt{}

Strikethrough is an extension that allow you to use invisibleBlock expression like '~~text~~' .

View Source
var DefaultWriter = &defaultWriter{}

DefaultWriter is a default implementation of the Writer.

View Source
var EmphasisAttributeFilter = GlobalAttributeFilter

EmphasisAttributeFilter defines attribute names which emphasis elements can have.

View Source
var GlobalAttributeFilter = util.NewBytesFilter(
	[]byte("accesskey"),
	[]byte("autocapitalize"),
	[]byte("class"),
	[]byte("contenteditable"),
	[]byte("contextmenu"),
	[]byte("dir"),
	[]byte("draggable"),
	[]byte("dropzone"),
	[]byte("hidden"),
	[]byte("id"),
	[]byte("itemprop"),
	[]byte("lang"),
	[]byte("slot"),
	[]byte("spellcheck"),
	[]byte("style"),
	[]byte("tabindex"),
	[]byte("title"),
	[]byte("translate"),
)

GlobalAttributeFilter defines attribute names which any elements can have.

View Source
var HeadingAttributeFilter = GlobalAttributeFilter

HeadingAttributeFilter defines attribute names which heading elements can have

View Source
var ImageAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("align"),
	[]byte("border"),
	[]byte("crossorigin"),
	[]byte("decoding"),
	[]byte("height"),
	[]byte("importance"),
	[]byte("intrinsicsize"),
	[]byte("ismap"),
	[]byte("loading"),
	[]byte("referrerpolicy"),
	[]byte("sizes"),
	[]byte("srcset"),
	[]byte("usemap"),
	[]byte("width"),
)

ImageAttributeFilter defines attribute names which image elements can have.

View Source
var LinkAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("download"),

	[]byte("hreflang"),
	[]byte("media"),
	[]byte("ping"),
	[]byte("referrerpolicy"),
	[]byte("rel"),
	[]byte("shape"),
	[]byte("target"),
)

LinkAttributeFilter defines attribute names which link elements can have.

View Source
var ListAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("start"),
	[]byte("reversed"),
)

ListAttributeFilter defines attribute names which list elements can have.

View Source
var ListItemAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("value"),
)

ListItemAttributeFilter defines attribute names which list item elements can have.

View Source
var ParagraphAttributeFilter = GlobalAttributeFilter

ParagraphAttributeFilter defines attribute names which paragraph elements can have.

View Source
var ThematicAttributeFilter = GlobalAttributeFilter.Extend(
	[]byte("align"),
	[]byte("color"),
	[]byte("noshade"),
	[]byte("size"),
	[]byte("width"),
)

ThematicAttributeFilter defines attribute names which hr elements can have.

Functions

func NewRenderer

func NewRenderer(context *rundown_renderer.Context, opts ...Option) renderer.NodeRenderer

NewRenderer returns a new Renderer with given options.

func RenderAttributes

func RenderAttributes(w util.BufWriter, node ast.Node, filter util.BytesFilter)

RenderAttributes renders given node's attributes. You can specify attribute names to render by the filter. If filter is nil, RenderAttributes renders all attributes.

func WithConsoleWidth

func WithConsoleWidth(width int) interface {
	renderer.Option
	Option
}

The mutator is responsible for changing the inside of a RundownInline block before it's written to the output, but after it's been rendered.

func WithLevel

func WithLevel(level int) interface {
	renderer.Option
	Option
}

The mutator is responsible for changing the inside of a RundownInline block before it's written to the output, but after it's been rendered.

func WithLevelChange

func WithLevelChange(changer func(level int)) interface {
	renderer.Option
	Option
}

The mutator is responsible for changing the inside of a RundownInline block before it's written to the output, but after it's been rendered.

func WithRundownHandler

func WithRundownHandler(handler RundownHandler) interface {
	renderer.Option
	Option
}

The mutator is responsible for changing the inside of a RundownInline block before it's written to the output, but after it's been rendered.

Types

type AnsiScreenWriter

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

Writes terminal output to the screen, while allowing for per-line alterations.

func NewAnsiScreenWriter

func NewAnsiScreenWriter(reader io.Reader, writer io.Writer) *AnsiScreenWriter

func (*AnsiScreenWriter) AfterFlush

func (f *AnsiScreenWriter) AfterFlush(cb func())

func (*AnsiScreenWriter) BeforeFlush

func (f *AnsiScreenWriter) BeforeFlush(cb func())

func (*AnsiScreenWriter) CHA

func (f *AnsiScreenWriter) CHA(pos int) error

Cursor Horizontal position Absolute

func (*AnsiScreenWriter) CNL

func (f *AnsiScreenWriter) CNL(count int) error

Cursor to Next Line

func (*AnsiScreenWriter) CPL

func (f *AnsiScreenWriter) CPL(count int) error

Cursor to Previous Line

func (*AnsiScreenWriter) CUB

func (f *AnsiScreenWriter) CUB(count int) error

Cursor Backward

func (*AnsiScreenWriter) CUD

func (f *AnsiScreenWriter) CUD(count int) error

CUrsor Down

func (*AnsiScreenWriter) CUF

func (f *AnsiScreenWriter) CUF(count int) error

Cursor Forward

func (*AnsiScreenWriter) CUP

func (f *AnsiScreenWriter) CUP(x int, y int) error

CUrsor Position

func (*AnsiScreenWriter) CUU

func (f *AnsiScreenWriter) CUU(count int) error

Cursor Up

func (*AnsiScreenWriter) DA

func (f *AnsiScreenWriter) DA(values []string) error

Device Attributes

func (*AnsiScreenWriter) DCH

func (f *AnsiScreenWriter) DCH(count int) error

Delete Character

func (*AnsiScreenWriter) DECCOLM

func (f *AnsiScreenWriter) DECCOLM(enable bool) error

132 Column Mode

func (*AnsiScreenWriter) DECOM

func (f *AnsiScreenWriter) DECOM(enable bool) error

Origin Mode

func (*AnsiScreenWriter) DECSTBM

func (f *AnsiScreenWriter) DECSTBM(x, y int) error

Set Top and Bottom Margins

func (*AnsiScreenWriter) DECTCEM

func (f *AnsiScreenWriter) DECTCEM(enable bool) error

Text Cursor Enable Mode

func (*AnsiScreenWriter) DL

func (f *AnsiScreenWriter) DL(count int) error

Delete Line

func (*AnsiScreenWriter) ED

func (f *AnsiScreenWriter) ED(count int) error

Erase in Display

func (*AnsiScreenWriter) EL

func (f *AnsiScreenWriter) EL(count int) error

Erase in Line

func (*AnsiScreenWriter) Execute

func (f *AnsiScreenWriter) Execute(b byte) error

Execute C0 commands

func (*AnsiScreenWriter) Flush

func (f *AnsiScreenWriter) Flush() error

Flush updates from previous commands

func (*AnsiScreenWriter) HVP

func (f *AnsiScreenWriter) HVP(x int, y int) error

Horizontal and Vertical Position (depends on PUM)

func (*AnsiScreenWriter) ICH

func (f *AnsiScreenWriter) ICH(count int) error

Insert Character

func (*AnsiScreenWriter) IL

func (f *AnsiScreenWriter) IL(count int) error

Insert Line

func (*AnsiScreenWriter) IND

func (f *AnsiScreenWriter) IND() error

Index

func (*AnsiScreenWriter) PrefixEachLine

func (f *AnsiScreenWriter) PrefixEachLine(prefix string)

func (*AnsiScreenWriter) Print

func (f *AnsiScreenWriter) Print(b byte) error

Print

func (*AnsiScreenWriter) Process

func (f *AnsiScreenWriter) Process()

func (*AnsiScreenWriter) RI

func (f *AnsiScreenWriter) RI() error

Reverse Index

func (*AnsiScreenWriter) SD

func (f *AnsiScreenWriter) SD(count int) error

Pan Up

func (*AnsiScreenWriter) SGR

func (f *AnsiScreenWriter) SGR(values []int) error

Set Graphics Rendition

func (*AnsiScreenWriter) SU

func (f *AnsiScreenWriter) SU(count int) error

Pan Down

func (*AnsiScreenWriter) VPA

func (f *AnsiScreenWriter) VPA(pos int) error

Vertical line Position Absolute

type BulletSequenceStyle

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

func NewBulletSequence

func NewBulletSequence(marker string, level string) BulletSequenceStyle

func (BulletSequenceStyle) Begin

func (s BulletSequenceStyle) Begin() string

func (BulletSequenceStyle) End

func (s BulletSequenceStyle) End() string

func (BulletSequenceStyle) Wrap

func (s BulletSequenceStyle) Wrap(str string) string

type Color

type Color aurora.Color

func (Color) Begin

func (c Color) Begin() string

func (Color) End

func (c Color) End() string

func (Color) Wrap

func (c Color) Wrap(str string) string

type Config

type Config struct {
	TempDir        string
	RundownHandler RundownHandler
	Level          int
	ConsoleWidth   int
	LevelChange    func(level int)
}

A Config struct has configurations for the HTML based renderers.

func NewConfig

func NewConfig() Config

NewConfig returns a new Config with defaults.

func (*Config) SetOption

func (c *Config) SetOption(name renderer.OptionName, value interface{})

SetOption implements renderer.NodeRenderer.SetOption.

type ExecutionResult

type ExecutionResult string

type IntegerSequenceStyle

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

func NewIntegerSequence

func NewIntegerSequence(start int, level string) *IntegerSequenceStyle

func (*IntegerSequenceStyle) Begin

func (s *IntegerSequenceStyle) Begin() string

func (*IntegerSequenceStyle) End

func (s *IntegerSequenceStyle) End() string

func (*IntegerSequenceStyle) Wrap

func (s *IntegerSequenceStyle) Wrap(str string) string

type Option

type Option interface {
	SetConsoleOption(*Config)
}

An Option interface sets options for HTML based renderers.

type Renderer

type Renderer struct {
	Config

	Context *rundown_renderer.Context
	// contains filtered or unexported fields
}

A Renderer struct is an implementation of renderer.NodeRenderer that renders nodes as Console strings

func (*Renderer) CurrentLevel

func (r *Renderer) CurrentLevel() int

func (*Renderer) RegisterFuncs

func (r *Renderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer)

RegisterFuncs implements NodeRenderer.RegisterFuncs .

func (*Renderer) SetLevel

func (r *Renderer) SetLevel(level int)

type RundownHandler

type RundownHandler interface {
	Mutate([]byte, ast.Node) ([]byte, error)
	OnRundownNode(node ast.Node, entering bool) (ast.WalkStatus, error)
	OnExecute(node *rundown_ast.ExecutionBlock, source []byte, out util.BufWriter) (ExecutionResult, error)
}

type Spinner

type Spinner interface {
	Active() bool
	Start()
	Stop()
	Success(message string)
	Error(message string)
	Skip(message string)
	SetMessage(message string)
	NewStep(message string)
	HideAndExecute(f func())
	CurrentHeading() string
	StampShadow()
}

type Style

type Style interface {
	Wrap(str string) string
	Begin() string
	End() string
}

type StyleStack

type StyleStack struct {
	Styles []Style
}

func NewStyleStack

func NewStyleStack() *StyleStack

func (*StyleStack) Peek

func (s *StyleStack) Peek() Style

func (*StyleStack) Pop

func (s *StyleStack) Pop() Style

func (*StyleStack) Push

func (s *StyleStack) Push(style Style) Style

type Writer

type Writer interface {
	// Write writes the given source to writer with resolving references and unescaping
	// backslash escaped characters.
	Write(writer util.BufWriter, source []byte)

	// RawWrite writes the given source to writer without resolving references and
	// unescaping backslash escaped characters.
	RawWrite(writer util.BufWriter, source []byte)
}

A Writer interface writes textual contents to a writer.

Directories

Path Synopsis
Package spinner is a simple package to add a spinner / progress indicator to any terminal application.
Package spinner is a simple package to add a spinner / progress indicator to any terminal application.

Jump to

Keyboard shortcuts

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