【问题标题】:Syntax highlighting with Prettify and Twitter Bootstrap使用 Prettify 和 Twitter Bootstrap 突出显示语法
【发布时间】:2012-11-20 11:37:16
【问题描述】:

我试图在我的 <pre></pre> 标签中获得语法高亮显示,但我使用的是 Bootstrap。我现在正在使用 Prettify,但它不起作用。如果你有修复请分享!

我现在的基本代码,刚刚清理完毕。

<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="prettify.js"></script>

<pre>
    <?php
        function hw(){
            echo "Hallo World";
        }
    ?>
</pre>

【问题讨论】:

  • 你已经重写了 CSS 结构,美化 css 和你现有的 css 有一些共同的类,尝试识别它们并将它们分开。
  • 美化没有 CSS 文件..
  • Prettify 没有 css 文档。
  • @AndreasMyrupLarsen, code.google.com/p/google-code-prettify/source/browse/trunk/src/… 是 CSS 文件。它应该是所有打包版本的一部分。

标签: twitter-bootstrap syntax-highlighting google-code-prettify


【解决方案1】:

你缺少一个告诉美化内容是代码的类,你可能需要转义你的 PHP 标记:

    <pre class="prettyprint">
        &lt;?php
            function hw(){
                echo "Hallo World";
            }
        ?&gt;
    </pre>

另外,请确保您在某处致电 prettyPrint()

README 文件建议

<body onload="prettyPrint()">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-22
    相关资源
    最近更新 更多