📄 codeblockhighlighter.cs
字号:
namespace CommunityServer.FreeTextBoxWrapper
{
using Aylar.Highlight;
using Aylar.Highlight.Extensions;
using System;
using System.Text.RegularExpressions;
internal class CodeBlockHighlighter : Aylar.Highlight.Extensions.CodeBlockHighlighter
{
protected string CodeMatchHandler(Match m)
{
Highlighter highlighter1 = new Highlighter();
string text1 = m.Groups["language"].Value;
string text2 = m.Groups["code"].Value;
string text3 = m.Groups["image"].Value;
string text4 = highlighter1.Highlight(text2, text1).Replace("\n\n", "<br />").Replace("\n", "<br />");
return string.Format("<code>{0}</code>", text4);
}
public string Highlight(string inCode, bool highlightBBCode)
{
Regex regex1;
if (highlightBBCode)
{
regex1 = new Regex("\\[code[\\s]+language=\"(?'language'[^\"]*?)\"\\](?'code'[\\w\\W]*?)\\[\\/code\\]");
}
else
{
regex1 = new Regex("<code[\\s]+language=\"(?'language'[^\"]*?)\">(?'code'[\\w\\W]*?)<\\/code>");
}
MatchEvaluator evaluator1 = new MatchEvaluator(this.CodeMatchHandler);
return regex1.Replace(inCode, evaluator1);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -