asp.net实现C#代码加亮显示
发布日期:2021-06-30 19:17:45 浏览次数:2 分类:技术文章

本文共 1096 字,大约阅读时间需要 3 分钟。

 

以下是代码片段:

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("/n"));
if(codeType=="C#")
{
textBuffer.Write("<Csharp>/r/n");
foreach(string sourceLine in sr)
{
textBuffer.Write(FixCSLine(sourceLine)) ;
textBuffer.Write("/r/n");
}
textBuffer.Write("</Csharp>");
}
else if(codeType=="JScript.Net")
{
textBuffer.Write("<JScript.Net>/r/n");
foreach(string sourceLine in sr)
{
textBuffer.Write(FixJSLine(sourceLine)) ;
textBuffer.Write("/r/n");
}
textBuffer.Write("</JScript.Net>");
}
else if(codeType=="VB")
{
textBuffer.Write("<VB>/r/n");
foreach(string sourceLine in sr)
{
textBuffer.Write(FixVBLine(sourceLine)) ;
textBuffer.Write("/r/n");
}
textBuffer.Write("</VB>");
}

转载地址:https://linuxstyle.blog.csdn.net/article/details/211973 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Asp.Net下的DataGrid的多层表头
下一篇:iframe自动调整高度能在IE5里实现吗

发表评论

最新留言

不错!
[***.144.177.141]2024年04月21日 14时20分10秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

freeswitch设置账号密码和端口 /conf/autoload_configs/event_socket.conf.xml 2019-04-30
freeswitch添加坐席/usr/local/freeswitch/conf/directory/default 2019-04-30
JavaScript原生开关灯效果 2019-04-30
企业邮箱如何申请注册,邮箱申请如何免费注册? 2019-04-30
微信企业邮箱,手机邮箱格式地址怎么写? 2019-04-30
公司如何申请企业邮箱,公司邮箱怎么申请,公司企业邮箱哪个好? 2019-04-30
电子邮箱账号怎么申请,怎样申请邮箱账号呢 2019-04-30
邮箱怎么发邮件,邮件发信量多少,职场新人怎么发汇报邮件呢? 2019-04-30
maven 多层次pom 新引入包,编译成功,还是没有将包引入到本地 2019-04-30
leetCode2 两数相加 2019-04-30
【工具使用】使用pip与conda安装、更新与卸载Pytorch和torchvision 2019-04-30
【深度学习笔记】batchsize, time step(iteration), epoch 区别与联系 2019-04-30
【解决错误】ModuleNotFoundError No module named matplotlib 2019-04-30
【工具使用】Google免费云环境Colaboratory使用 2019-04-30
【深度学习笔记】卷积层,全连接层,池化层的相关输出参数计算 2019-04-30
【NLP学习笔记】文本分类概述 2019-04-30
【深度学习笔记】文本分类 2019-04-30
【转载】炼丹实验室:深度学习网络调参技巧 2019-04-30
【论文阅读笔记】Graph Convolutional Networks for Text Classification 2019-04-30
【论文阅读笔记】文本分类论文汇总 2019-04-30