Found a bug with it, but the tag </v> should cancel all tags already. I'll publish another update that fixes this.
I thought about using custom events for this, but the usage of events is very different than what we're after. I really think it'll be better to use preparsing.
I wrote up some working code that does what you need:
using UnityEngine;
using System.Collections;
public class STMPreparse3 : MonoBehaviour {
public string textTag = "transcribe";
public void Parse(STMTextContainer x)
{
string startTag = "<" + textTag + ">";
string endTag = "</" + textTag + ">";
int startingPoint = x.text.IndexOf(startTag);
int endingPoint = startingPoint > -1 ? x.text.IndexOf(endTag, startingPoint) : -1; //get tag after starting tag point
//optional, where this tag ends
if(endingPoint == -1)
{
endingPoint = x.text.Length;
}
else
{
//remove tag
x.text = x.text.Remove(endingPoint, endTag.Length);
//ending point is already accurate
}
//if this tag exists in STM's string...
if(startingPoint > -1)
{
//remove tag
x.text = x.text.Remove(startingPoint, startTag.Length);
//push backwards
endingPoint -= startTag.Length;
//actually modify text
Replace(x, startingPoint, endingPoint);
}
}
void Replace(STMTextContainer x, int startingPoint, int endingPoint)
{
//int originalLength = x.text.Length;
int skippedChars = startingPoint;
//go thru string
for(int i=startingPoint; i<endingPoint; i++) //for each letter in the original string...
{
string replaceValue = x.text[skippedChars].ToString(); //default value
//replace specific characters with sequences
//for this example, compare all letters as uppercase letters
switch(x.text[skippedChars].ToString().ToUpper())
{
case "A": replaceValue = "aaa"; break;
case "B": replaceValue = "bbb"; break;
//etc etc...
}
//remove original character
x.text = x.text.Remove(skippedChars, 1);
//replace with sequence
x.text = x.text.Insert(skippedChars, replaceValue);
//1 by default, but adds up if more characters are inserted
skippedChars += replaceValue.Length;
}
}
}
This code ignores other tags (which shouldn't overlap with this edge case anyway), but you can define a starting and ending point using <transcribe> and </transcribe> or whatever you change the textTag value to.