内部head
标签我有:
<link rel="stylesheet" href="google-code-prettify/prettify.css">
<script src="google-code-prettify/prettify.js"></script>
我有身体标签内的某处:
<div id='code-context'>
<pre class="prettyprint"><code class="language-js"></code></pre>
</div>
在我的主 css 文件中,我有一些pre
应该code
覆盖美化:
#code-context pre, #code-context code {
font-family: 'Ubuntu Mono', monospace;
width: 80ch;
white-space: pre-wrap;
}
我故意不包括在内<body onload="prettyPrint()">
。加载页面时隐藏,因此#code-context
没有必要。在用户触发 jQuery 函数后,代码变得可见:
$('#code-context').show();
var fileSource = "code-to-display.js";
$('code').load(fileSource);
$('.prettyprinted').removeClass('prettyprinted');
prettyPrint();
console.log('succeded!');
我在控制台中收到消息(这意味着一切正常),但实际上我得到的是所有代码的边框,并且代码本身没有颜色编码。
帮助?