engine

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package engine reads a document with a profile (PROFILE_FORMAT.md): it consumes the element events of package xmlread, as the generic reader does, and makes the blocks the profile's rules say. Elements with no rule are read generically and counted.

Index

Constants

View Source
const (
	// MaxTableColumns bounds the columns of a table.
	MaxTableColumns = 1024
	// MaxRowSpan bounds how many rows one cell spans.
	MaxRowSpan = 65535
	// MaxNamesCounted bounds the distinct names counted in the
	// xml.unmapped_* warnings; the rest are counted together.
	MaxNamesCounted = 1000
	// MaxParts bounds the parts a profile's part rules start.
	MaxParts = 100000
)

Fixed bounds. What they cut is reported with limit.exceeded.

View Source
const (
	// AttrAnchorParent is the identifier of the nearest enclosing element
	// a rule names with "anchor", on a block with no identifier of its own.
	AttrAnchorParent = "anchor_parent"
	// AttrHeaderSource is "profile" on a table whose header row is the
	// profile's fixed text.
	AttrHeaderSource = "header_source"
	// AttrTitle is a link's title ("title") in its stored record.
	AttrTitle = "title"
	// AttrHref is the address of a link, on its record in the stored part.
	AttrHref = "href"
)

Keys of Block.Attrs the engine writes.

View Source
const (
	WarnUnmappedElements   = "xml.unmapped_elements"
	WarnUnmappedAttributes = "xml.unmapped_attributes"
	WarnSkipped            = "xml.skipped_elements"
)

Warning codes of the engine.

View Source
const MaxNamesListed = 100

MaxNamesListed bounds the names a warning lists.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {

	// Meta collects the metadata the rules give.
	Meta gofastcore.Metadata

	// Counts for the whole reading.
	ValuesCut, ColumnsCut, SpansCut, TextCut, PartsCut int
	// RowSpanCut counts cells whose row span was cut to MaxRowSpan.
	RowSpanCut int
	// PendingCut counts blocks cut because more than MaxPendingBlocks
	// attribute notes waited for them.
	PendingCut        int
	Controls, Invalid int
	// contains filtered or unexported fields
}

Engine is the profile consumer. It implements xmlread.Handler.

func New

func New(p *profile.Profile, out *generic.Out, opts Options) *Engine

New returns an engine reading with p into out, whose Part is the first part.

func (*Engine) Attr

func (e *Engine) Attr(i int, q profile.QName) (string, bool)

func (*Engine) Comment

func (e *Engine) Comment(r *xmlread.Reader, t []byte, final bool, start, end int64)

Comment implements xmlread.Handler: a comment is a note marked stored, at its place.

func (*Engine) Counts

func (e *Engine) Counts() (controls, invalid int)

Counts returns the control characters removed and invalid bytes met in all the text made.

func (*Engine) EndElement

func (e *Engine) EndElement(r *xmlread.Reader, el *xmlread.Element, start, end int64)

EndElement implements xmlread.Handler.

func (*Engine) Finish

func (e *Engine) Finish(end int64)

Finish ends the reading at offset end.

func (*Engine) HasToken

func (e *Engine) HasToken(i int, q profile.QName, tok string) bool

HasToken implements profile.TokenPath: an element's tested value is split into its tokens once, the first time a rule tests it.

func (*Engine) Len

func (e *Engine) Len() int

func (*Engine) Name

func (e *Engine) Name(i int) profile.QName

func (*Engine) PartWarnings

func (e *Engine) PartWarnings(p *gofastcore.Part)

PartWarnings writes the engine's warnings about part p.

func (*Engine) Parts

func (e *Engine) Parts() []*gofastcore.Part

Parts returns the parts made, the stored part last if there is one.

func (*Engine) StartElement

func (e *Engine) StartElement(r *xmlread.Reader, el *xmlread.Element)

StartElement implements xmlread.Handler.

func (*Engine) Stop

func (e *Engine) Stop() bool

Stop implements xmlread.Handler.

func (*Engine) Text

func (e *Engine) Text(r *xmlread.Reader, t []byte, start, end int64)

Text implements xmlread.Handler.

type Options

type Options struct {
	Spans    bool
	NoImages bool
}

Options are the engine's settings.

Jump to

Keyboard shortcuts

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