Pages

2013年7月19日 星期五

如何在blog顯示code碼


  1. 在範本中修改html檔,在<header>中插入以下程式碼:
  2. <link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" rel="stylesheet" type="text/css"></link>
    <script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript">
    </script>
    
  3. 在範本中修改html檔,在<body>中加入
  4. onload='prettyPrint();' 
    
  5. 在範本中修改html檔中收尋 /* Post 並加入以下CSS的修改檔
  6. .post .code { 
      display: block; /* fixes a strange ie margin bug */
      font-family: Courier New; 
      font-size: 10pt; 
      overflow:auto; 
      background: #f0f0f0 url(http://yourweb_images_home/Code_BG.gif) left top repeat-y;
      border: 1px solid #ccc;
      padding: 10px 10px 10px 21px;
      max-height:200px;
      line-height: 1.2em;
    }
    
  7. 在文章的HTML檔在想顯示程式碼中加入以下標籤
  8. <pre class="prettyprint code">
    你的code碼
    </pre>
    
參考自:文章
不錯的參考資料:HTML Encode 網頁

沒有留言:

張貼留言

 
 
Blogger Templates