Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Contains classes for working with markup in Yarn lines.
A marker processor that handles the built-in markers [select] [plural] , and [ordinal] .
Parses text and produces markup information.
An exception representing something going wrong when parsing markup.
A type of MarkupValue .
A type of Yarn.Markup.MarkupAttributeMarker .
Provides a mechanism for producing replacement text for a marker.
Represents a range of text in a marked-up string.
The result of parsing a line of marked-up text.
A property associated with a MarkupAttribute .
A value associated with a MarkupProperty .
A bundle of results from processing replacement markers.
Class in Yarn.Markup
Inherits from System.Object
A marker processor that handles the built-in markers [select] [plural] , and [ordinal] .
public class BuiltInMarkupReplacer : IAttributeMarkerProcessorProduces replacement text for a marker.
Method in BuiltInMarkupReplacer
Produces replacement text for a marker.
Yarn.Markup.MarkupAttribute marker
The marker to process into replacement text.
System.Text.StringBuilder childBuilder
A System.Text.StringBuilder that contains the child text contained within marker . Use the methods on this stringbuilder to produce any text needed from this marker.
System.Collections.Generic.List<Yarn.Markup.MarkupAttribute> childAttributes
The child attributes of marker .
string localeCode
A BCP-47 locale code that represents the locale in which any processing should take place.
The collection of diagnostics produced during processing, and the number of invisible characters created during processing.
Interface in Yarn.Markup
Provides a mechanism for producing replacement text for a marker.
Produces replacement text for a marker.
LineParser.RegisterMarkerProcessor(string,IAttributeMarkerProcessor): Registers an object as a marker processor for a given marker name.
LineParser.DeregisterMarkerProcessor(string): Removes any marker processor associated with a given marker name.
Field in LineParser
The name of the implicitly-generated character attribute.
public const string CharacterAttribute = "character";LineParser.CharacterAttributeNameProperty: The name of the 'name' property, on the implicitly-generated character attribute.
Field in LineParser
The name of the 'name' property, on the implicitly-generated character attribute.
public const string CharacterAttributeNameProperty = "name";LineParser.CharacterAttribute: The name of the implicitly-generated character attribute.
Field in LineParser
The name of the attribute to use to indicate that no marker processing should occur.
public const string NoMarkupAttribute = "nomarkup";Field in LineParser
The name of the property in replacement attributes that contains the text of the attribute.
public const string ReplacementMarkerContents = "contents";Field in LineParser
The name of the property to use to signify that trailing whitespace should be trimmed if a tag had preceding whitespace or begins the line. This property must be a bool value.
public const string TrimWhitespaceProperty = "trimwhitespace";Method in LineParser
Removes any marker processor associated with a given marker name.
public void DeregisterMarkerProcessor(string attributeName)string attributeName
The name of the marker.
Method in LineParser
Replaces all substitution markers in a text with the given substitution list.
This method replaces substitution markers - for example, {0}
with the corresponding entry in substitutions . If text contains a substitution marker whose index is not present in substitutions , it is ignored.
string text
The text containing substitution markers.
System.Collections.Generic.IList<string> substitutions
The list of substitutions.
text , with the content from substitutions inserted.
Constructor in MarkupDiagnostic
Initialises a new instance of the MarkupDiagnostic struct.
string message
The diagnostic text.
int column
The zero-based first column of the diagnostic's range.
Method in MarkupDiagnostic
public override readonly bool Equals(object obj)object obj
Method in MarkupDiagnostic
public readonly bool Equals(MarkupDiagnostic other)Property in MarkupDiagnostic
Gets the zero-based column index of the start of the range at which this diagnostic appears.
public int Column { get; }Method in MarkupAttribute
Creates a new MarkupAttribute based on the current instance whose Position is shifted towards the end of the string by shift characters.
int shift
The number of characters to shift by.
A new MarkupAttribute with an updated Position .
Method in MarkupAttribute
Gets a boolean property named name from this attribute, if present.
string name
The name of the property.
bool result
On return, the property's value if found, or false if not.
true if a property named name was found; false otherwise.
Method in MarkupAttribute
Gets an integer property named name from this attribute, if present.
string name
The name of the property.
int result
On return, the property's value if found, or zero if not.
true if a property named name was found; false otherwise.
Method in MarkupAttribute
Gets a float property named name from this attribute, if present.
string name
The name of the property.
float result
On return, the property's value if found, or zero if not.
true if a property named name was found; false otherwise.
Method in MarkupAttribute
Gets a string property named name from this attribute, if present.
string name
The name of the property.
string result
On return, the property's value if found, or null if not.
true if a property named name was found; false otherwise.
Property in MarkupAttribute
Gets the number of text elements in the plain text that this attribute covers.
public int Length { get; internal set; }Property in MarkupAttribute
Gets the name of the attribute.
public string Name { get; internal set; }Property in MarkupAttribute
Gets the position in the plain text where this attribute begins.
public int Position { get; internal set; }Property in MarkupAttribute
Gets the properties associated with this attribute.
public IReadOnlyDictionary<string, MarkupValue> Properties { get; internal set; }Class in Yarn.Markup
Inherits from System.Exception
An exception representing something going wrong when parsing markup.
public class MarkupParseException : ExceptionLineParser: Parses text and produces markup information.
Constructor in MarkupParseResult
Initializes a new instance of the MarkupParseResult struct.
string text
The plain text.
System.Collections.Generic.List<Yarn.Markup.MarkupAttribute> attributes
The list of attributes.
Property in MarkupParseResult
The list of MarkupAttribute s in this parse result.
public List<MarkupAttribute> Attributes { get; }Property in MarkupParseResult
The original text, with all parsed markers removed.
public string Text { get; }Property in MarkupProperty
Gets the name of the property.
public string Name { get; private set; }Property in MarkupProperty
Gets the value of the property.
public MarkupValue Value { get; private set; }Method in MarkupValue
public readonly string ToString(IFormatProvider formatProvider)System.IFormatProvider formatProvider
Property in MarkupValue
Gets the bool value of this property.
public bool BoolValue { get; internal set; }This property is only defined when the property's Type is Bool .
Property in MarkupValue
Gets the float value of this property.
public float FloatValue { get; internal set; }This property is only defined when the property's Type is Float .
Property in MarkupValue
Gets the string value of this property.
public string StringValue { get; internal set; }This property is only defined when the property's Type is String .
Property in MarkupValue
Gets the value's type.
public MarkupValueType Type { get; internal set; }Field in ReplacementMarkerResult
The collection of diagnostics produced during processing, if any.
public List<LineParser.MarkupDiagnostic> Diagnostics;Method in LineParser
Registers an object as a marker processor for a given marker name.
When a marker processor is registered for a marker name, the parser will ask the processor for text to insert into the plain text. This allows users of the LineParser class to dynamically replace text in a line. The nomarkup tag is implemented in this way by the LineParser class directly; the Dialogue class uses this mechanism to implement the select , plural and ordinal markers.
string attributeName
The name of the marker that should use this marker processor.
Yarn.Markup.IAttributeMarkerProcessor markerProcessor
The object that should be invoked when markers with this name are encountered.
Method in LineParser
Parses a string of text and produces a markup parse result.
string input
The text to parse.
string localeCode
The locale to use when processing markers, as a BCP-47 locale tag.
squish
If false , markers that are split as part of the markup parsing process will not be re-merged before returning the result.
sort
If true , markers will be sorted based on their position in the input.å
bool addImplicitCharacterAttribute
If true, the parser will attempt to detect a character name in the text and add a [character] attribute for it.
A markup parse result.
Method in MarkupParseResult
Returns the substring of Text covered by attribute Position and Length properties.
If the attribute's Length property is zero, this method returns the empty string.
This method does not check to see if attribute is an attribute belonging to this MarkupParseResult. As a result, if you pass an attribute that doesn't belong, it may describe a range of text that does not appear in Text. If this occurs, an System.IndexOutOfRangeException will be thrown.
Yarn.Markup.MarkupAttribute attribute
The attribute to get the text for.
The text contained within the attribute.
Struct in Yarn.Markup
Inherits from System.ValueType
A property associated with a MarkupAttribute .
You do not create instances of this struct yourself. It is created by objects that can parse markup, such as LineParser .
Yarn.Markup.LineParser.ParseString(System.String,System.String,System.Boolean,System.Boolean,System.Boolean):
Method in MarkupParseResult
Deletes an attribute from this markup.
This method deletes the range of text covered by attributeToDelete , and updates the other attributes in this markup as follows:
Attributes that start and end before the deleted attribute are unmodified.
Attributes that start before the deleted attribute and end inside it are truncated to remove the part overlapping the deleted attribute.
Attributes that have the same position and length as the deleted attribute are deleted, if they apply to any text.
Attributes that start and end within the deleted attribute are deleted.
Attributes that start within the deleted attribute, and end outside it, have their start truncated to remove the part overlapping the deleted attribute.
Attributes that start after the deleted attribute have their start point adjusted to account for the deleted text.
This method does not modify the current object. A new MarkupParseResult is returned.
If attributeToDelete is not an attribute of this MarkupParseResult, the behaviour is undefined.
Yarn.Markup.MarkupAttribute attributeToDelete
The attribute to remove.
A new MarkupParseResult object, with the plain text modified and an updated collection of attributes.
Method in IAttributeMarkerProcessor
Produces replacement text for a marker.
Yarn.Markup.MarkupAttribute marker
The marker to process into replacement text.
System.Text.StringBuilder childBuilder
A System.Text.StringBuilder that contains the child text contained within marker . Use the methods on this stringbuilder to produce any text needed from this marker.
System.Collections.Generic.List<Yarn.Markup.MarkupAttribute> childAttributes
The child attributes of marker .
string localeCode
A BCP-47 locale code that represents the locale in which any processing should take place.
The collection of diagnostics produced during processing, and the number of invisible characters created during processing.
Property in MarkupValue
Gets the integer value of this property.
public int IntegerValue { get; internal set; }This property is only defined when the property's Type is Integer .
Constructor in ReplacementMarkerResult
Convenience constructor for replacement markup results.
System.Collections.Generic.List<Yarn.Markup.LineParser.MarkupDiagnostic> diagnostics
The diagnostics generated during processing
int invisibleCharacters
the number of invisible characters generated during processing.
Field in ReplacementMarkerResult
The number of invisible characters added into the line during processing.
This will vary depending on what the replacement markup needs to do.
When only inserting rich-text tags, this should be the length of all inserted text. For example "this is text with [bold]some bold[/bold] elements" translated into Unity style rich-text become "this is text with <b>some bold</b> elements". In this case then the value of InvisibleCharacters would be seven.
When only modifying the content of the children text, such as making all text upper case, this should be 0. For example "this is text with [upper]some uppercased[/upper] elements" is transformed into "this is text with SOME UPPERCASED elements". The number of invisible character will be zero.
When adding new content into the line (regardless of being added at the start, end, or middle) this should be zero but the replacement processor should make sure to shift along it's children attributes where appropriate. For example "this is text with [emph]some emphasised[/emph] elements" transformed into "this is text with !!some emphasised!! elements" the value of InvisibleCharacters would be zero. In this case however the childAttributes in ProcessReplacementMarker(MarkupAttribute,System.Text.StringBuilder,List<MarkupAttribute>,string) would need to be shifted down two.
Constructor in ReplacementMarkerResult
Convenience form of ReplacementMarkerResult(List<LineParser.MarkupDiagnostic>,int) for when there are no diagnostics.
public ReplacementMarkerResult(int invisibleCharacters)int invisibleCharacters
the number of invisible characters generated during processing.
public ReplacementMarkerResult ProcessReplacementMarker(MarkupAttribute marker, StringBuilder childBuilder, List<MarkupAttribute> childAttributes, string localeCode)public interface IAttributeMarkerProcessorpublic static string ExpandSubstitutions(string text, IList<string> substitutions)public MarkupDiagnostic(string message, int column = -1)public readonly MarkupAttribute Shift(int shift)public readonly bool TryGetProperty(string name, out bool result)public readonly bool TryGetProperty(string name, out int result)public bool TryGetProperty(string name, out float result)public readonly bool TryGetProperty(string name, [NotNullWhen(true)] out string? result)public MarkupParseResult(string text, List<MarkupAttribute> attributes)public void RegisterMarkerProcessor(string attributeName, IAttributeMarkerProcessor markerProcessor)public MarkupParseResult ParseString(string input, string localeCode, bool addImplicitCharacterAttribute = true)public readonly string TextForAttribute(MarkupAttribute attribute)public struct MarkupPropertypublic readonly MarkupParseResult DeleteRange(MarkupAttribute attributeToDelete)public ReplacementMarkerResult ProcessReplacementMarker(MarkupAttribute marker, System.Text.StringBuilder childBuilder, List<MarkupAttribute> childAttributes, string localeCode);public ReplacementMarkerResult(List<LineParser.MarkupDiagnostic> diagnostics, int invisibleCharacters)public int InvisibleCharacters;Class in Yarn.Markup
Inherits from System.Object
Parses text and produces markup information.
public sealed class LineParser : IDisposableThe name of the implicitly-generated character attribute.
The name of the 'name' property, on the implicitly-generated character attribute.
The name of the attribute to use to indicate that no marker processing should occur.
The name of the property in replacement attributes that contains the text of the attribute.
The name of the property to use to signify that trailing whitespace should be trimmed if a tag had preceding whitespace or begins the line. This property must be a bool value.
Removes any marker processor associated with a given marker name.
Represents a diagnostic message produced during markup parsing.
Struct in LineParser
Inherits from System.ValueType
Represents a diagnostic message produced during markup parsing.
public struct MarkupDiagnostic : IEquatable<MarkupDiagnostic>Initialises a new instance of the struct.
Gets the zero-based column index of the start of the range at which this diagnostic appears.
Gets the text of the diagnostic.
Method in MarkupAttribute
Gets a property named name from this attribute, if present.
public readonly bool TryGetProperty(string name, out MarkupValue result)string name
The name of the property.
result
On return, the property's value if found, or zero if not.
true if a property named name was found; false otherwise.
Struct in Yarn.Markup
Inherits from System.ValueType
The result of parsing a line of marked-up text.
public struct MarkupParseResultYou do not create instances of this struct yourself. It is created by objects that can parse markup, such as Dialogue .
Initializes a new instance of the struct.
Deletes an attribute from this markup.
Returns the substring of covered by attribute Position and Length properties.
The list of s in this parse result.
The original text, with all parsed markers removed.
Yarn.Markup.LineParser.ParseString(System.String,System.String,System.Boolean,System.Boolean,System.Boolean):
Method in MarkupParseResult
Gets the first attribute with the specified name, if present.
public readonly bool TryGetAttributeWithName(string name, out MarkupAttribute attribute)string name
The name of the attribute to get.
attribute
When this method returns, contains the attribute with the specified name, if the attribute is found; otherwise, the default . This parameter is passed uninitialized.
true if the MarkupParseResult contains an attribute with the specified name; otherwise, false .
Struct in Yarn.Markup
Inherits from System.ValueType
Represents a range of text in a marked-up string.
public struct MarkupAttributeYou do not create instances of this struct yourself. It is created by objects that can parse markup, such as LineParser .
Yarn.Markup.LineParser.ParseString(System.String,System.String,System.Boolean,System.Boolean,System.Boolean):
Enum in Yarn.Markup
Inherits from System.Enum
A type of MarkupValue .
public enum MarkupValueType
{
Integer,
Float,
String,
Bool
#pragma warning restore CA1720
}Struct in Yarn.Markup
Inherits from System.ValueType
A bundle of results from processing replacement markers.
public struct ReplacementMarkerResult: Provides a mechanism for producing replacement text for a marker.
Replaces all substitution markers in a text with the given substitution list.
Parses a string of text and produces a markup parse result.
Registers an object as a marker processor for a given marker name.
Gets the first attribute with the specified name, if present.
A bool.
A float.
An integer.
A string.
Convenience constructor for replacement markup results.
Convenience form of ReplacementMarkerResult(List<LineParser.MarkupDiagnostic>,int) for when there are no diagnostics.
The collection of diagnostics produced during processing, if any.
The number of invisible characters added into the line during processing.
Gets the properties associated with this attribute.
Creates a new MarkupAttribute based on the current instance whose Position is shifted towards the end of the string by shift characters.
Gets a boolean property named name from this attribute, if present.
Gets an integer property named name from this attribute, if present.
Gets a float property named name from this attribute, if present.
Gets a string property named name from this attribute, if present.
Gets a property named name from this attribute, if present.
Gets the number of text elements in the plain text that this attribute covers.
Gets the name of the attribute.
Gets the position in the plain text where this attribute begins.
Enum in Yarn.Markup
Inherits from System.Enum
A type of Yarn.Markup.MarkupAttributeMarker .
public enum TagType
{
Open,
Close,
SelfClosing,
CloseAll
}A closing marker. For example, [/a] .
The close-all marker, [/] .
An open marker. For example, [a] .
A self-closing marker. For example, [a/] .
Struct in Yarn.Markup
Inherits from System.ValueType
A value associated with a MarkupProperty .
public struct MarkupValueYou do not create instances of this struct yourself. It is created by objects that can parse markup, such as LineParser .
Yarn.Markup.LineParser.ParseString(System.String,System.String,System.Boolean,System.Boolean,System.Boolean):
Gets the bool value of this property.
Gets the float value of this property.
Gets the integer value of this property.
Gets the string value of this property.
Gets the value's type.