Twitter bootstrap twitter引导上的语法突出显示
我正试图使用Google prettify突出一些语法,但到目前为止,它还不起作用Twitter bootstrap twitter引导上的语法突出显示,twitter-bootstrap,prettify,Twitter Bootstrap,Prettify,我正试图使用Google prettify突出一些语法,但到目前为止,它还不起作用 //一些源代码 福班{ 公共整型条{get;set;} } 有没有一个解决方案可以让这项工作不与bootstrap中已经存在的pre标记过多地混淆?编辑:对于twitter bootstrap 2.0.x,它可以与2.1.x一起工作 使用这两个文件,而不是使用文档中描述的方法 这对我有用 <!DOCTYPE html> <html lang="en"> <head>
//一些源代码
福班{
公共整型条{get;set;}
}
有没有一个解决方案可以让这项工作不与bootstrap中已经存在的pre标记过多地混淆?编辑:对于twitter bootstrap 2.0.x,它可以与2.1.x一起工作 使用这两个文件,而不是使用文档中描述的方法 这对我有用
<!DOCTYPE html>
<html lang="en">
<head>
<link href="css/bootstrap.css" type="text/css" rel="stylesheet" />
<link href="prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="prettify.js"></script>
</head>
<body onload="prettyPrint()" bgcolor="white">
<pre class="prettyprint linenums languague-css">
// Some source code
class Foo {
public int Bar { get; set; }
}
</pre>
</body>
</html>
//一些源代码
福班{
公共整型条{get;set;}
}
链接到2个文件prettify.css后,prettify.js将此代码添加到页脚
<script>
// @prettify
!function ($) {
$(function(){
window.prettyPrint && prettyPrint()
})
}(window.jQuery);
// #prettify
</script>
//美化
!函数($){
$(函数(){
window.prettyPrint&&prettyPrint()
})
}(window.jQuery);
//美化
不确定为什么不建议修改:
<script>
// Activate Google Prettify in this page
addEventListener('load', prettyPrint, false);
$(document).ready(function(){
// Add prettyprint class to pre elements
$('pre').addClass('prettyprint');
}); // end document.ready
</script>
//在此页面中激活Google Prettify
addEventListener('load',预打印,false);
$(文档).ready(函数(){
//将prettyprint类添加到pre元素
$('pre').addClass('prettyprint');
}); // 结束文件.ready
即使您直接使用GitHub路径,上面的代码示例也能工作。在2.1.1中,问题是关于2.0.4建议:您应该使用window.prettyPrint&&prettyPrint()
on标记,而不是不再可用的“onload”链接我在找到下载链接