2014-01-29 37 views
0

嗯,我沒有這個語法高亮啄的知識,但不知何故,我設法提出了語法高亮顯示腳本到使用美化代碼我的博客之一。但不知何故,代碼不會完全顯示在垂直行中,而是顯示爲具有完整代碼的單行。下面是我使用的代碼:我曾經在這裏本文http://geniusknight.weebly.com/6/post/2014/01/how-to-display-responsive-adsense-ads-on-non-responsive-sites.html爲什麼語法高亮不是垂直渲染

<link rel="stylesheet" href="http://www.geniusknight.weebly.com/files/theme/prettify.css"/> 
<pre class="prettyprint"> 
&lt;!--Responsive Ads on Non responsive sites code starts--&gt; 
&lt;div id="google-ads-1"&gt;&lt;/div&gt; 
&lt;script type="text/javascript"&gt; 
    /* Replace ca-pub-XXX with your AdSense Publisher ID */ 
    google_ad_client = "ca-pub-XXX"; 

    /* Replace YYY with the AdSense Ad Slot ID */ 
    google_ad_slot = "YYY"; 

    /* Replace ZZZ with the custom height of your Ad Unit */ 
    google_ad_height = "ZZZ"; 

    ad = document.getElementById('google-ads-1'); 

    if (ad.getBoundingClientRect().width) { 
     google_ad_width = ad.getBoundingClientRect().width; 
    } else { 
     google_ad_width = ad.offsetWidth; // for old IE 
    } 

    if (google_ad_width>1200) {   
     google_ad_width = 1200; 
    } else if (google_ad_width<120) { 
     google_ad_width = 120; 
    } 

    if (google_ad_height>1200) {   
     google_ad_height = 1200; 
    } else if (google_ad_height<50) { 
     google_ad_height = 50; 
    } 

    if ((google_ad_width>300) && (google_ad_height>300)) {   
     google_ad_height = 300; 
    } 

    document.write (
    '<ins class="adsbygoogle" style="display:inline-block;width:' 
     + google_ad_width + 'px;height:' 
     + google_ad_height + 'px" data-ad-client="' 
     + google_ad_client + '" data-ad-slot="' 
     + google_ad_slot + '"></ins>' 
    ); 
    (adsbygoogle = window.adsbygoogle || []).push({}); 
&lt;/script&gt; 
&lt;script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"&gt; 
&lt;/script&gt; 
&lt;!--tutorial at geniusknight.weebly.com --&gt; 
</pre> 
<script src="http://www.geniusknight.weebly.com/files/theme/prettify.js"></script> 
<script>prettyPrint();</script> 

。我在這裏做錯了什麼,或者是我錯過了一些參數,或者是在做什麼事情,也可以在頭腦中進行美化css。

<link rel="stylesheet" href="http://www.geniusknight.weebly.com/files/theme/prettify.css" /> 
+0

使用CSS在預標記您使用的是最新版本?舊版本有一個渲染錯誤http://stackoverflow.com/questions/5830408/google-prettify-removes-line-breaks – epascarello

+0

哦,我明白了!你能請我重定向到最新版本。請! :) – Geniusknight

+0

https://code.google.com/p/google-code-prettify/ – epascarello

回答

0

好了它的固定使用空格

<pre style="width:95%;white-space:pre-wrap;" class="prettyprint">