muparser

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedContentTypes = []string{
	"application/pdf",
}

TODO: Support non-PDF file formats.

Functions

func ReadPagesFromXML

func ReadPagesFromXML(r io.Reader) ([]content.Page, error)

ReadPagesFromXML reads structured text from an XML file written by mutool.

Types

type Block

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

Block is a holder for one or multiple lines of text.

func (*Block) Bounds

func (b *Block) Bounds() geometry.Rect

func (*Block) Kind

func (*Block) Kind() content.Block

func (*Block) Lines

func (b *Block) Lines() []content.Line

func (*Block) RangeBounds

func (b *Block) RangeBounds(start, end int) geometry.Rect

func (*Block) Text

func (b *Block) Text() string

type Line

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

Line is a single line of text without newlines.

func (*Line) Bounds

func (l *Line) Bounds() geometry.Rect

func (*Line) Kind

func (*Line) Kind() content.Line

func (*Line) RangeBounds

func (l *Line) RangeBounds(start, end int) geometry.Rect

func (*Line) Text

func (l *Line) Text() string

type Page

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

Page holds recognized elements on a single page.

func (*Page) Elements

func (p *Page) Elements() []content.Element

func (*Page) Number

func (p *Page) Number() int

func (*Page) Size

func (p *Page) Size() geometry.Size

type Parser

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

func New

func New(path string, tool ToolWrapper) *Parser

New creates a new mutool-based parser. mutool requires a regular and seekable file.

func (*Parser) ParsePages

func (p *Parser) ParsePages(ctx context.Context, r pagerange.Range) ([]content.Page, error)

ParsePages uses mutool to parse a file and returns the page contents.

func (*Parser) RenderPage

func (p *Parser) RenderPage(ctx context.Context, pageNum int, r renderformat.Renderer) error

func (*Parser) Validate

func (p *Parser) Validate(ctx context.Context) error

type ToolWrapper

type ToolWrapper interface {
	Validate(context.Context, string) error
	StructuredText(context.Context, string, pagerange.Range) (*stext.Document, error)
	Draw(context.Context, string, int, renderformat.Renderer) error
}

Jump to

Keyboard shortcuts

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