utils

package
v0.0.0-...-0e8dd81 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const MathMLNamespace = "http://www.w3.org/1998/Math/MathML"

MathMLNamespace is the xml namespace of mathml

Variables

This section is empty.

Functions

func ContainsInt64

func ContainsInt64(haystack []int64, needle int64) bool

ContainsInt64 checks if a slice of int64s contains an element

func FilterInt64

func FilterInt64(slice []int64, filter func(int64) bool) (res []int64)

FilterInt64 filters a slice of int64 elements and returns only those

func Getenv

func Getenv(key, fallback string) string

Getenv gets an environment variable as a string with a fallback

func GetenvInt

func GetenvInt(key string, fallback int) int

GetenvInt is the same as Getenv, except that it turns values into int64 it panics iff the variable exists but is not a valid int64

func HashFile

func HashFile(filename string) (hash string, err error)

HashFile computes the hash of a segment

func IterateFiles

func IterateFiles(dir string, extension string, callback func(string) error) (err error)

IterateFiles iterates over files in a directory with a given extension

func MaxInt

func MaxInt(values ...int) (max int)

MaxInt returns the maximum value of a list of integers

func MaxInt64

func MaxInt64(values ...int64) (max int64)

MaxInt64 returns the maximum value of a list of integers

func OutputJSONOrErr

func OutputJSONOrErr(res interface{}, err error)

OutputJSONOrErr outputs res as json if no error message is provided

func ProcessLinePairs

func ProcessLinePairs(filename string, allowLeftover bool, parser func(string, string) error) (err error)

ProcessLinePairs process lines from filename in pairs

Types

type BooleanYesNo

type BooleanYesNo bool

BooleanYesNo represents a boolean that is xml encoded as "yes" or "no"

func (BooleanYesNo) MarshalText

func (byesno BooleanYesNo) MarshalText() (text []byte, err error)

MarshalText turns a BooleanYesNo into a string

func (*BooleanYesNo) UnmarshalText

func (byesno *BooleanYesNo) UnmarshalText(text []byte) (err error)

UnmarshalText unmarshals text into a string

type MathML

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

MathML represents a MathML Element with semantics and annotation component

func ParseMathML

func ParseMathML(source string) (math *MathML, err error)

ParseMathML parses a new MathML Element

func (*MathML) Copy

func (math *MathML) Copy() *MathML

Copy makes a copy of this struct, allowing NavigateAnnotation() to not change the original object

func (*MathML) NavigateAnnotation

func (math *MathML) NavigateAnnotation(xpth string) (err error)

NavigateAnnotation navigates within an <annotation> element and updates the semantics accordingly if the xpth is invalid or an error occurs, annotation and semantics remain unchanged

func (*MathML) OutputXML

func (math *MathML) OutputXML() string

OutputXML turns this node into an <m:math> element It hard-codes the "m" namespace and uses it for all elements by default. When no semantics element exists, it returns an <m:semantics> with only an annotation child.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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