public void Parse(STMTextContainer x)
 {
     parserEnabled = true;
     //go thru each letter, searching ruby
     for (int i = 0; i < x.text.Length; i++)
     {
         //ignore other tags
         if (x.text[i] == '<')
         {
             parserEnabled = false;
         }
         if (parserEnabled)
         {
             //search ruby to see if this letter is a match
             for (int j = 0; j < ruby.Length; j++)
             {
                 if (x.text[i] == ruby[j].ch)
                 {
                     x.text = x.text.Insert(i, "<e=rt," + ruby[j].text + ">");
                     //skip over this new tag
                     i += 7 + ruby[j].text.Length;
                 }
             }
         }
         //parse text again
         if (x.text[i] == '>')
         {
             parserEnabled = true;
         }
     }
 }
Esempio n. 2
0
 public void Parse(STMTextContainer x)
 {
     //go thru each letter, searching ruby
     for (int i = 0; i < x.text.Length; i++)
     {
         //search ruby to see if this letter is a match
         for (int j = 0; j < ruby.Length; j++)
         {
             if (x.text[i] == ruby[j].ch)
             {
                 x.text = x.text.Insert(i, "<e=rt," + ruby[j].text + ">");
                 //skip over this new tag
                 i += 7 + ruby[j].text.Length;
             }
         }
     }
 }
Esempio n. 3
0
    void Replace(STMTextContainer x, int startingPoint, int endingPoint)
    {
        //int originalLength = x.text.Length;
        int  skippedChars = startingPoint;
        bool parsingOn    = true;

        //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

            if (replaceValue == "<")
            {
                //turn off parsing
                parsingOn = false;
            }
            else if (replaceValue == ">")
            {
                //turn back on
                parsingOn = true;
            }
            //is this a letter that should be replaced?
            if (parsingOn)
            {
                //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;
        }
    }
Esempio n. 4
0
    public void Parse(STMTextContainer x)
    {
        string startTag = "<" + textTag + ">";
        string endTag   = "</" + textTag + ">";

        int startingPoint;
        int endingPoint;

        do
        {
            startingPoint = x.text.IndexOf(startTag);
            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);
            }
        }
        //repeat while the tag still exists in the string
        while(startingPoint > -1);
    }
Esempio n. 5
0
 public void Parse(STMTextContainer x)
 {
     x.text = x.text + addToEnd;
 }
Esempio n. 6
0
 public void Parse(STMTextContainer x)
 {
     x.text = addToStart + x.text;
 }