syntaxhighlighter

在页面上漂亮的显示源码

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <!--注意页面跳转的原因-->
    <meta charset="utf-8" HTTP-EQUIV="Refresh" CONTENT="5;URL=http://www.baidu.com">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" >
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link rel="stylesheet" type="text/css" href="static/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="static/css/default.css" />
    <link type="text/css" rel="stylesheet" href="styles/index.css"/>
    <script type="text/javascript" src="static/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="static/js/highlight.pack.js"></script>
</head>
<body>


                <div class="title">

                    <div class="codes">
					<pre><code>
            <!-- 注释:这是一段注释。注释不会在浏览器中显示,但确实存在于代码中 -->
            <!-- 文档类型声明:告诉浏览器本篇文档是那种类型的文档,浏览器则会根据这个声明解析文档 -->
            &lt;!DOCTYPE html>
            &lt;html>
            &lt;head lang="en">
            &lt;meta charset="UTF-8">
            &lt;title>&lt;/title>
            &lt;/head>
            &lt;body>
                        &lt;h1 style="font-size: 12px;">我的字号被修改了&lt;/h1>
            &lt;/body>
            &lt;/html>
                        </code>
        </pre>
                    </div>
                    </div>

                    <script type="text/javascript">
    $(document).ready(function() {
        $('pre code').each(function(i, block) {
            hljs.highlightBlock(block);
        });
    });
</script>
</body>
</html>

另一种风格

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Hello SyntaxHighlighter</title>
    <script type="text/javascript" src="scripts/shCore.js"></script>
    <script type="text/javascript" src="scripts/shBrushJScript.js"></script>
    <link type="text/css" rel="stylesheet" href="styles/shCoreDefault.css"/>
    <link type="text/css" rel="stylesheet" href="styles/index.css"/>
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>

<body>
<div class="title">
    <div class="codes">
        <pre class="brush: js;">
            <!-- 注释:这是一段注释。注释不会在浏览器中显示,但确实存在于代码中 -->
            <!-- 文档类型声明:告诉浏览器本篇文档是那种类型的文档,浏览器则会根据这个声明解析文档 -->
            &lt;!DOCTYPE html>
            &lt;html>
            &lt;head lang="en">
                <meta charset="UTF-8">
                <title></title>
            &lt;/head>
            &lt;body>
                <h1 style="font-size: 12px;">我的字号被修改了</h1>
            &lt;/body>
            &lt;/html>
        </pre>
    </div>
</div>
</body>
</html>

css

相关推荐