markup

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package markup contains the code used to parse the markup tags in a line of dialogue, along with markup processors that can be used to eg. handle plurals and ordinals. It is called automatically by dialogue runners so users of ysgo generally shouldn't have to directly deal with this package.

Index

Constants

View Source
const (
	// All the types that an attribute property can hold.
	ValueTypeInteger = ValueType(iota)
	ValueTypeFloat
	ValueTypeString
	ValueTypeBool
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Position       int
	Length         int
	Name           string
	Properties     map[string]Value
	SourcePosition int
}

Attribute holds data about a section of text between two markup tags.

type LineParser

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

LineParser can parse the markup from a line of text. It's pretty much a direct port of the LineParser.cs file of YarnSpinner from C# to Go.

func (*LineParser) ParseMarkup

func (lineParser *LineParser) ParseMarkup(input string) (*ParseResult, error)

ParseMarkup parses a line of text to extract the markup metadata.

type ParseResult

type ParseResult struct {
	Text       string
	Attributes []Attribute
}

ParseResult is the result of parsing a line of text into interpolated text and a set of markup attributes.

func (*ParseResult) Attribute

func (parseResult *ParseResult) Attribute(name string) (Attribute, bool)

Attribute returns the value of the attribute with the given name, if there is one.

func (*ParseResult) TextForAttribute

func (parseResult *ParseResult) TextForAttribute(attribute Attribute) string

TextForAttribute returns the part of the parsed line of text that is covered by the given attribute.

type Value

type Value struct {
	IntegerValue int
	FloatValue   float64
	StringValue  string
	BoolValue    bool
	ValueType    ValueType
}

Value holds the value of an attribute property.

type ValueType

type ValueType int8

ValueType represents what type the value of an attribute property holds.

Jump to

Keyboard shortcuts

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