Example #1
0
        void ProcessText()
        {
            while (currentPos < completeText.Length)
            {
                //Look for starting tag at current pos
                //if found... parse value if needed and add to active tags
                RTTag openFound = GetTagInPos();
                if (openFound != null)
                {
                    activeTags.Add(openFound);
                    continue;
                }

                //Look for ending tag at current pos
                //If found... remove from active tags
                int closeFound = ClosingTagFound();
                if (closeFound != -1)
                {
                    for (int i = activeTags.Count - 1; i >= 0; i--)
                    {
                        if (activeTags[i].tag == closeFound)
                        {
                            activeTags.RemoveAt(i);
                            break;
                        }
                    }
                    continue;
                }

                //if no start and no end
                //add character at current pos to processed text list
                AddCurrentToList();
            }
        }
Example #2
0
 string GetOpenTag(RTTag tg)
 {
     if (tg.tag < 2)
     {
         return(RTOpenTag[tg.tag]);
     }
     return(RTOpenTag[tg.tag] + tg.value + ">");
 }
Example #3
0
 RTTag GetTagInPos()
 {
     for (int i = 0; i < RTOpenTag.Length; i++)
     {
         if (completeText.Length - currentPos < RTOpenTag[i].Length)
         {
             continue;
         }
         if (completeText.Substring(currentPos, RTOpenTag[i].Length) == RTOpenTag[i])
         {
             //Opening tag found... parsing
             if (i < 2)
             {
                 currentPos += RTOpenTag[i].Length;
                 RTTag rtg = new RTTag();
                 rtg.tag   = i;
                 rtg.value = "";
                 return(rtg);
             }
             else
             {
                 //Find close ">" and parse internal value
                 int pos = completeText.IndexOf(">", currentPos);
                 if (pos > currentPos)
                 {
                     int   valueLength = pos - (currentPos + RTOpenTag[i].Length);
                     RTTag rtg         = new RTTag();
                     rtg.tag    = i;
                     rtg.value  = completeText.Substring(currentPos + RTOpenTag[i].Length, valueLength);
                     currentPos = pos + 1;
                     return(rtg);
                 }
             }
         }
     }
     return(null);
 }