网站首页

SyntaxHihglighter添加用法!

发布时间:2015-03-26 10:39:19编辑:admin阅读(

    SyntaxHihglighter它可以在网页中对各种程序源代码语法进行加亮显示。支持当前流行的各种编程语言:C#、CSS、C++、Delphi、Java、JavaScript、PHP、Python、Ruby、SQL、Visual Basic、XML / HTML 下载地址:http://www.dreamprojections.com/syntaxhighlighter/ 或http://code.google.com/p/syntaxhighlighter/ 首页解压引入需要的JS和css。代码如下:

    <script type="text/javascript" src="scripts/shCore.js"></script>
        <script type="text/javascript" src="scripts/shBrushBash.js"></script>
        <script type="text/javascript" src="scripts/shBrushCpp.js"></script>
        <script type="text/javascript" src="scripts/shBrushCSharp.js"></script>
        <script type="text/javascript" src="scripts/shBrushCss.js"></script>
        <script type="text/javascript" src="scripts/shBrushDelphi.js"></script>
        <script type="text/javascript" src="scripts/shBrushDiff.js"></script>
        <script type="text/javascript" src="scripts/shBrushGroovy.js"></script>
        <script type="text/javascript" src="scripts/shBrushJava.js"></script>
        <script type="text/javascript" src="scripts/shBrushJScript.js"></script>
        <script type="text/javascript" src="scripts/shBrushPhp.js"></script>
        <script type="text/javascript" src="scripts/shBrushPlain.js"></script>
        <script type="text/javascript" src="scripts/shBrushPython.js"></script>
        <script type="text/javascript" src="scripts/shBrushRuby.js"></script>
        <script type="text/javascript" src="scripts/shBrushScala.js"></script>
        <script type="text/javascript" src="scripts/shBrushSql.js"></script>
        <script type="text/javascript" src="scripts/shBrushVb.js"></script>
        <script type="text/javascript" src="scripts/shBrushXml.js"></script>
        <link type="text/css" rel="stylesheet" href="styles/shCore.css"/>
        <link type="text/css" rel="stylesheet" href="styles/shThemeDefault.css"/>
        <script type="text/javascript">
            SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';
            SyntaxHighlighter.all();
        </script>

    然后调用调用代码就是:

    <pre class="brush: c-sharp;">   
        需要高亮的代码!    
    </pre>

    是不是好简单!