为什么Syntax Highlighter不能垂直渲染

时间:2014-01-29 14:40:21

标签: javascript html css syntax-highlighting

嗯,我不知道这种语法高亮的东西,但不知何故,我设法使用美化代码将语法高亮度脚本提交到我的一个博客中。但不知何故,代码而不是完全显示在垂直行中显示为带有完整代码的单行。这是我使用的代码:

<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>

我在本文http://geniusknight.weebly.com/6/post/2014/01/how-to-display-responsive-adsense-ads-on-non-responsive-sites.html中使用了它。我在这里做错了什么,或者是我错过了一些参数,或者它是否与weebly有关,也在头部我把美化的css。

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

1 个答案:

答案 0 :(得分:0)

使用空格

在pre标签中使用css修复了它
<pre style="width:95%;white-space:pre-wrap;" class="prettyprint">