asp.net实现C#代码加亮显示 - 编程吧

上一篇 | 下一篇

asp.net实现C#代码加亮显示

发布: 2007-1-11 11:04 | 作者: 佚名 | 来源: 网页教学网 | 查看: 118次

以下是代码片段:
StringWriter textBuffer = new StringWriter();
Match match= Regex.Match(HTMLStr,@"",RegexOptions.IgnoreCase | RegexOptions.Compiled);
if(match==null)
{
Response.Write(HTMLStr);
return;
}

string codeType = match.Groups["codeType"].Value;
string content = match.Groups["codeContent"].Value;
if(codeType==String.Empty || content==String.Empty)
{
Response.Write(HTMLStr);
return;
}
// MessageBox.Show(codeType);
// MessageBox.Show(content);
string[] sr = content.Split(Convert.ToChar(" "));
if(codeType=="C#")
{
textBuffer.Write("<Csharp> ");
foreach(string sourceLine in sr)
{
textBuffer.Write(FixCSLine(sourceLine)) ;
textBuffer.Write(" ");
}
textBuffer.Write("</Csharp>");
}
else if(codeType=="JScript.Net")
{
textBuffer.Write("<JScript.Net> ");
foreach(string sourceLine in sr)
{
textBuffer.Write(FixJSLine(sourceLine)) ;
textBuffer.Write(" ");
}
textBuffer.Write("</JScript.Net>");
}
else if(codeType=="VB")
{
textBuffer.Write("<VB> ");
foreach(string sourceLine in sr)
{
textBuffer.Write(FixVBLine(sourceLine)) ;
textBuffer.Write(" ");
}
textBuffer.Write("</VB>");
}

TAG: 编程

字号: | 推荐给好友

 

评分:0

我来说两句

seccode