我的许多Wordpress博客(http://subinsb.com/) 帖子中包含的代码片段blockquote 元素。我需要突出显示这些代码片段。我试过使用GeSHi, Prettify Code Syntax, CodeColorer 但它们都不适用于blockquote 元素。是否有任何插件支持代码高亮显示blockquotes ?
或
如何自定义当前突出显示插件以突出显示blockquote元素?
我的许多Wordpress博客(http://subinsb.com/) 帖子中包含的代码片段blockquote 元素。我需要突出显示这些代码片段。我试过使用GeSHi, Prettify Code Syntax, CodeColorer 但它们都不适用于blockquote 元素。是否有任何插件支持代码高亮显示blockquotes ?
或
如何自定义当前突出显示插件以突出显示blockquote元素?
首先,你应该使用标准pre
和code
元素而不是块引号。但如果有太多的东西需要改变,可能会有一个解决办法。
如果只对代码使用块引号,那么可以使用一点jQuery将其转换为pre
标记,但请确保在加载Prettify之前执行此操作。
我不知道这些插件是如何工作的,但我可以用Prettify直接帮你完成。
从下载here 并将其列在您的网站上。
然后使用此jQuery转换blockquote
到pre
并触发美化。
$("blockquote").replaceWith(function() { return "<pre>" + $(this).html() + "</pre>"} );
prettyPrint();
我找到了另一种使用blockquote元素突出显示代码的方法。转到Wordpress Template Editor (外观->编辑器)
在正上方添加以下行</head>
<script src=\'https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js\' type=\'text/javascript\'></script>
<script src=\'https://google-code-prettify.googlecode.com/svn/loader/prettify.js\' type=\'text/javascript\'></script>
<link href=\'https://google-code-prettify.googlecode.com/svn/loader/prettify.css\' rel=\'stylesheet\'></script>
<script>jQuery(".site-content").ready(function(){jQuery("blockquote").each(function(){jQuery(this).html(prettyPrintOne(jQuery(this).html()));});});</script>
食品法典wp_list_comments 各州$reverse_top_level (boolean) (optional) Setting this to true will display the most recent comment first then going back in order.对我来说,这实际上是相反的方式。false 选项将最新注释显示为第一条注释,并且true 选项,或者如果根本没有使用该选项,则将是最后一个选项。如果使用或未使用注释分页,则同样适用。类似行为