codehighlightingmodule.cs

来自「Freetextbox是优秀的在线编辑器」· CS 代码 · 共 37 行

CS
37
字号
namespace CommunityServer.FreeTextBoxWrapper
{
    using CommunityServer.Components;
    using System;
    using System.Xml;

    public class CodeHighlightingModule : ICSModule
    {
        private void csa_BeforeProcessPost(IContent content, CSPostEventArgs e)
        {
            if (((e.ApplicationType == ApplicationType.Weblog) || (e.ApplicationType == ApplicationType.Forum)) && (((e.State == ObjectState.Create) || (e.State == ObjectState.Update)) || (e.State == ObjectState.Runtime)))
            {
                string text1;
                CodeBlockHighlighter highlighter1 = new CodeBlockHighlighter();
                string text2 = string.Format("{0}", content.GetType());
                if (((text1 = text2) != null) && (text1 == "CommunityServer.Components.IndexPost"))
                {
                    IndexPost post1 = content as IndexPost;
                    post1.FormattedBody = highlighter1.Highlight(post1.FormattedBody, true);
                }
                else
                {
                    Post post2 = content as Post;
                    post2.FormattedBody = highlighter1.Highlight(post2.FormattedBody, true);
                }
            }
        }

        public void Init(CSApplication csa, XmlNode node)
        {
            csa.PreRenderPost += new CSPostEventHandler(this.csa_BeforeProcessPost);
        }

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?