Exemplo n.º 1
0
        /// <summary>
        /// Called to evaluate the HTML fragment corresponding to each
        /// matching token in the code.
        /// </summary>
        /// <param name="match">The <see cref="Match"/> resulting from a
        /// single regular expression match.</param>
        /// <returns>A string containing the HTML code fragment.</returns>
        protected override string MatchEval(Match match)
        {
            if (match.Groups[1].Success)            //JavaScript code
            {
                string s = match.ToString();
                return(jsf.FormatSubCode(match.ToString()));
            }
            if (match.Groups[2].Success)            //comment
            {
                StringReader  reader = new StringReader(match.ToString());
                string        line;
                StringBuilder sb = new StringBuilder();
                while ((line = reader.ReadLine()) != null)
                {
                    if (sb.Length > 0)
                    {
                        sb.Append("\n");
                    }
                    sb.Append("<span class=\"rem\">");
                    sb.Append(line);
                    sb.Append("</span>");
                }
                return(sb.ToString());
            }
            if (match.Groups[3].Success)            //asp tag
            {
                return("<span class=\"asp\">" + match.ToString() + "</span>");
            }
            if (match.Groups[4].Success)            //asp C# code
            {
                return(csf.FormatSubCode(match.ToString()));
            }
            if (match.Groups[5].Success) // php code
            {
                return(psf.FormatSubCode(match.ToString()));
            }
            if (match.Groups[6].Success)            //tag delimiter
            {
                return("<span class=\"kwrd\">" + match.ToString() + "</span>");
            }
            if (match.Groups[7].Success)            //html tagname
            {
                return("<span class=\"html\">" + match.ToString() + "</span>");
            }
            if (match.Groups[8].Success)            //attributes
            {
                return(attribRegex.Replace(match.ToString(),
                                           new MatchEvaluator(this.AttributeMatchEval)));
            }
            if (match.Groups[9].Success)            //entity
            {
                return("<span class=\"attr\">" + match.ToString() + "</span>");
            }


            return(match.ToString());
        }
Exemplo n.º 2
0
 protected override string MatchEval(Match match)
 {
     if (match.Groups[1].Success)
     {
         match.ToString();
         return(jsf.FormatSubCode(match.ToString()));
     }
     if (match.Groups[2].Success)
     {
         StringReader  stringReader  = new StringReader(match.ToString());
         StringBuilder stringBuilder = new StringBuilder();
         string        str;
         while ((str = stringReader.ReadLine()) != null)
         {
             if (stringBuilder.Length > 0)
             {
                 stringBuilder.Append("\n");
             }
             stringBuilder.Append("<span class=\"rem\">");
             stringBuilder.Append(str);
             stringBuilder.Append("</span>");
         }
         return(stringBuilder.ToString());
     }
     if (match.Groups[3].Success)
     {
         return("<span class=\"asp\">" + match.ToString() + "</span>");
     }
     if (match.Groups[4].Success)
     {
         return(csf.FormatSubCode(match.ToString()));
     }
     if (match.Groups[5].Success)
     {
         return("<span class=\"kwrd\">" + match.ToString() + "</span>");
     }
     if (match.Groups[6].Success)
     {
         return("<span class=\"html\">" + match.ToString() + "</span>");
     }
     if (match.Groups[7].Success)
     {
         return(attribRegex.Replace(match.ToString(), new MatchEvaluator(AttributeMatchEval)));
     }
     if (match.Groups[8].Success)
     {
         return("<span class=\"attr\">" + match.ToString() + "</span>");
     }
     return(match.ToString());
 }